Compare commits

...

336 Commits

Author SHA1 Message Date
51fe936e5f ... 2017-12-06 12:18:06 +03:00
d8b177411f x2t - options for check macro in file 2017-12-05 16:56:50 +03:00
717b628055 ... 2017-12-05 14:37:10 +03:00
e4f94646b6 x2t version up 2017-12-05 10:54:43 +03:00
dcec7447e4 XlsFormat - apply theme style from format office 2010 and later 2017-12-04 19:24:27 +03:00
5f12552f78 XlsFormat - theme 2017-12-03 16:09:35 +03:00
d293769c1f XlsFormat .. 2017-12-02 17:31:10 +03:00
b45e772a50 remove stub for hyperlink without link 2017-12-01 18:34:04 +03:00
fdb7716abc builder error (save to pdf & open file by url) 2017-12-01 14:23:21 +03:00
f72d6dfe0e XlsFormat-... 2017-11-30 20:04:08 +03:00
23029a6a92 Change cef number 2017-11-30 16:28:48 +03:00
eda8e4d13f add c_oSerCellTypes::ValueText for cell value; Read1 error with empty length 2017-11-30 14:18:46 +03:00
64f578e59f XlsFormat - ... 2017-11-29 19:32:21 +03:00
16c57b50cc XlsFormat - table parts 2017-11-29 14:48:02 +03:00
83c0ba9dab XlsFormat - table parts 2017-11-28 19:41:16 +03:00
a2443dadeb use external directory for fonts 2017-11-28 19:17:30 +03:00
789bb1d4b3 add open/save bookmarks 2017-11-28 17:49:14 +03:00
4138ae5ce2 add save to odp 2017-11-28 17:29:12 +03:00
239b5dbf11 fix bug #36451 (ole object old style in master slide) 2017-11-28 17:01:03 +03:00
c046776b9c Merge branch 'hotfix/v5.0.5' into develop
# Conflicts:
#	X2tConverter/src/cextracttools.h
2017-11-27 18:14:40 +03:00
055a02570b XlsFormat - ... 2017-11-27 17:44:55 +03:00
1e2e5996f3 . 2017-11-23 19:40:37 +03:00
875717acd4 Add m_sSavePassword (m_sPassword - only for open) 2017-11-23 18:40:31 +03:00
033feeaf9d fix bug #18178 2017-11-23 18:16:44 +03:00
de336e5f96 Merge remote-tracking branch 'origin/hotfix/v5.0.5' into develop 2017-11-23 17:43:20 +03:00
82b3dbdae6 OdfFormatReader - fix users files 2017-11-23 17:42:09 +03:00
d1227f7759 x2t - add native commands for crypt file 2017-11-23 17:28:28 +03:00
4d134387f9 . 2017-11-23 17:15:06 +03:00
3f8600dfb7 XlsFormat - attachedToolbar,refactoring 2017-11-23 15:34:55 +03:00
511f043d63 . 2017-11-23 14:26:49 +03:00
69a41343c2 build with clang++ 2017-11-23 10:55:04 +03:00
578327bab6 XlsFormat - split sheets by type (ala original file) 2017-11-22 20:05:03 +03:00
52908908a5 fix linux build 2017-11-22 11:44:33 +03:00
24d9b99a44 Merge remote-tracking branch 'origin/hotfix/v5.0.5' into develop 2017-11-21 18:10:56 +03:00
dce58b628f fix bug #36322 2017-11-21 18:10:05 +03:00
f42cb4580c fix users files
XlsFormat olap hierarchy
...
2017-11-21 17:02:22 +03:00
52777e36cb refactoring 2017-11-21 12:49:32 +03:00
7b7e9f3e6e . 2017-11-20 16:21:58 +03:00
d39fa156e7 fix build 2017-11-20 15:47:40 +03:00
48bf40919c fix... 2017-11-17 19:33:38 +03:00
fd53a987be fix bug #36272 2017-11-17 19:02:51 +03:00
b4d298542a fix bug #36251 2017-11-17 15:58:19 +03:00
bae854027b fix bug #36380
Problem with picture in footnote
2017-11-17 13:18:20 +03:00
9723c379dd . 2017-11-17 12:44:51 +03:00
e8d8b2e56c . 2017-11-17 12:27:58 +03:00
adb84b0f05 x2t version up 2017-11-17 12:01:51 +03:00
a4ee30d031 fix bug #36201 2017-11-17 11:44:07 +03:00
e05194b277 Move ASCDOCUMENTSCORE to separated target 2017-11-16 18:14:37 +03:00
21f7f6ed5b fix bug #36335 2017-11-15 13:28:19 +03:00
80863ae25b v5.0.4 2017-11-13 17:46:10 +03:00
07562a9582 v5.0.4 2017-11-13 17:44:36 +03:00
6da196e426 fix bug #36311 2017-11-13 11:48:28 +03:00
d220cc8c79 removed stubs on writing tblLayout 2017-11-09 19:56:04 +03:00
f53c3d9f50 Merge pull request #51 from ONLYOFFICE/feature/pre5.0.4
pdf reader bug
2017-11-07 10:40:46 +03:00
fa98f22e3d fixed crush on Revision: 069544bf6c 2017-11-03 19:07:29 +03:00
e01c09bcc9 XlsFormat - olap .. 2017-11-03 15:36:15 +03:00
069544bf6c tab leader 2017-11-02 19:09:00 +03:00
b0f0f656af Merge pull request #50 from ONLYOFFICE/feature/bug36176
fix bug 36176
2017-11-02 18:00:26 +03:00
99191e65b0 XlsFormat - fix connections (oleDb, query...) 2017-11-02 15:39:18 +03:00
fb41720817 for bug 35900 (CWorkbookPr::toXml) 2017-11-02 13:31:14 +03:00
406c290be4 . 2017-11-01 15:40:15 +03:00
5ae4d7f819 XlsFormat - ... 2017-11-01 13:43:24 +03:00
e69c1677b2 v5.0.3 2017-10-31 18:49:25 +03:00
4d836c180a XlsFormat - mso storage (customXml) 2017-10-31 17:40:49 +03:00
e08b6542d4 XlsFormat - ctrlProps 2017-10-31 15:15:44 +03:00
e1340c63ec pdf reader bug 2017-10-30 15:06:43 +03:00
4b122c0b94 . 2017-10-30 13:47:16 +03:00
867438833b fix bug 36176 2017-10-30 13:40:57 +03:00
8b80aa94b7 XlsFormat - .. 2017-10-27 19:51:00 +03:00
f960fc60bb removed all stubs for FldChar 2017-10-27 19:05:06 +03:00
64213746b0 XlsFormat - query tables 2017-10-26 18:18:09 +03:00
09941c67ac . 2017-10-26 17:16:29 +03:00
c2605bb582 x2t - vps 2017-10-26 12:55:06 +03:00
ab2703c825 XlsFormat - vps 2017-10-26 11:04:35 +03:00
08ce8cb3f5 XlsFormat ... 2017-10-26 10:47:36 +03:00
5efe043ab3 refactoring 2017-10-25 18:34:05 +03:00
f2af1ccd36 refactoring 2017-10-25 18:22:51 +03:00
113d5b4ca3 refactoring 2017-10-25 18:10:59 +03:00
d3461dd3cb refactor 2017-10-25 17:54:27 +03:00
e95a0fb765 XlsFormat - activeX objects 2017-10-25 11:48:53 +03:00
c5ce1e27e4 x2t version up 2017-10-21 14:01:11 +03:00
7ecc7fa1df compaund file stream in unicode 2017-10-21 13:28:29 +03:00
c46cd9e6e5 Merge pull request #48 from ONLYOFFICE/hotfix/v5.0.3
Hotfix/v5.0.3
2017-10-20 17:45:01 +03:00
e299e59d11 fix write compaund files 2017-10-20 15:52:09 +03:00
1e0f4d6fdb XlsFormat - developers controls (buttons, options, ....), fix vba stream 2017-10-19 17:39:00 +03:00
4dae8f50fa Merge pull request #47 from ONLYOFFICE/feature/ooxmlsign
Feature/ooxmlsign
2017-10-18 19:08:30 +03:00
9cc5ed1db0 . 2017-10-18 19:03:58 +03:00
6d1dd9c420 ms crypto bug 2017-10-18 18:58:04 +03:00
a038e1562f XlsFormat - control objects 2017-10-18 14:38:31 +03:00
549e3dc579 Merge pull request #46 from ONLYOFFICE/feature/crypt
crypto fix padding size
2017-10-17 13:01:29 +03:00
8440b18223 crypto fix padding size 2017-10-17 12:57:47 +03:00
9c7a03fdc5 OdfFormatWriter - add ole objects 2017-10-17 11:40:37 +03:00
9272b27a69 crypto fix padding size 2017-10-16 19:37:18 +03:00
ef57330a79 . 2017-10-16 19:20:28 +03:00
d35619eeae Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  x2t binary - fix convert ole without vml drawing
  OdsFormat - fix absolute anchor for ole
  XlsFormat - activeX, controls & ole embedded & links
  xml string as second command-line param(first - path to xml)
  .
  --all-fonts-path param
  Added empty files
  v8 (windows correct)
  Added docbuilder target
2017-10-16 17:53:40 +03:00
b38c552cc5 fixed serialize 2017-10-16 17:53:31 +03:00
1b91ee579c x2t binary - fix convert ole without vml drawing 2017-10-16 14:22:53 +03:00
337c92e522 OdsFormat - fix absolute anchor for ole 2017-10-16 12:22:30 +03:00
8fe1eb7525 XlsFormat - activeX, controls & ole embedded & links 2017-10-16 11:28:46 +03:00
1deb2a6905 Merge 2017-10-13 14:44:53 +03:00
470eddf2b1 Merge 2017-10-13 14:43:33 +03:00
69a787411c xml string as second command-line param(first - path to xml) 2017-10-13 13:51:27 +03:00
22f986295f . 2017-10-12 18:17:16 +03:00
86d2bde83b x2t version up 2017-10-12 12:01:44 +03:00
07041d60f6 . 2017-10-12 11:54:47 +03:00
a5466ab740 XlsFormatReader - external data (dde, workbook, ..) 2017-10-12 11:41:21 +03:00
dfd54ff53f _MSC_VER >= 1900 build 2017-10-11 16:30:37 +03:00
6ec7d77e19 speed logger 2017-10-09 15:21:16 +03:00
3813be21c7 --all-fonts-path param 2017-10-09 15:11:30 +03:00
356ccba104 fixed bug#35998 2017-10-06 14:09:56 +03:00
68c8c0cb29 Merge pull request #42 from ONLYOFFICE/feature/docbuilder
Feature/docbuilder
2017-10-06 11:57:57 +03:00
3044d1122a OdfFormatReader - fix pilot tables (groups & references) 2017-10-06 11:36:00 +03:00
fb00ba7ecb fix users file 2017-10-06 11:35:03 +03:00
ab0c5703a5 Added empty files 2017-10-06 11:04:59 +03:00
e22b63347f v8 (windows correct) 2017-10-05 18:13:52 +03:00
9dd115ec56 v5.0.1 2017-10-05 14:48:07 +03:00
438ba3aded v5.0.1 2017-10-05 14:46:28 +03:00
29b002ca80 Added docbuilder target 2017-10-04 14:56:03 +03:00
34083d996b preload cef library 2017-10-03 16:10:20 +03:00
244d549cf8 --save-use-only-names mode 2017-10-03 11:07:01 +03:00
ef96571879 outlineLvl 2017-10-02 17:18:50 +03:00
7a27150de6 OdfFormatReader - fix math after testing 2017-10-02 17:11:12 +03:00
2197fddb7b RtfFormatReader - fix ole 2017-09-29 19:29:05 +03:00
d31344d7d3 correct metafile bounds 2017-09-29 17:29:21 +03:00
f7617b42cb Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-29 15:57:28 +03:00
8312cce2c3 . 2017-09-29 15:56:39 +03:00
dc89e1d484 Merge branch 'hotfix/v5.0.1' of https://github.com/ONLYOFFICE/core into hotfix/v5.0.1 2017-09-29 15:33:18 +03:00
17f4903347 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-29 15:31:52 +03:00
ebdfb2f785 OOxmlFormat - fix users files 2017-09-29 15:28:46 +03:00
ec2901bf48 RtfFormat - fix users file 2017-09-29 14:24:57 +03:00
f9e87624c0 . 2017-09-29 13:31:08 +03:00
5f0e6349cc . 2017-09-29 11:06:48 +03:00
3bdf44b8c7 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-29 10:56:48 +03:00
d586698025 x2t version up 2017-09-29 10:54:08 +03:00
eb6fb03ca5 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-28 19:27:08 +03:00
ad40f51dee OdsFormatReader - fix after testing 2017-09-28 19:26:35 +03:00
5e60456fc1 fix for crash sample.docx file 2017-09-28 17:30:13 +03:00
1f9e3f4fd8 OdpFormatReader - fix after testing 2017-09-27 19:49:10 +03:00
334620cd5a hidePivotFieldList in Editor.bin 2017-09-26 17:19:58 +03:00
4a5fca5ccf hidePivotFieldList in Editor.bin 2017-09-26 17:18:05 +03:00
828df16fe5 OdfFormat - fix transactions 2017-09-26 16:41:43 +03:00
66dae03919 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  fix bug #35895
  x2t version up
  OdfFormatReader - fix after testing
2017-09-26 16:37:52 +03:00
114a01f364 event for drag&drop content in ios11 2017-09-26 16:37:43 +03:00
2ddaf33156 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-09-25 19:07:39 +03:00
1af37af850 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-25 19:06:43 +03:00
b58026ea66 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormatReader - fix after testing
  .
  PptFormat - support vba macros
  DocFormat - vba macros
2017-09-25 18:54:39 +03:00
09a8a6794a log for errors 2017-09-25 18:54:31 +03:00
941cbe4f9b fix bug #35895 2017-09-25 17:10:50 +03:00
668d0c2abf x2t version up 2017-09-25 16:53:39 +03:00
66db5b09e6 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-25 16:49:31 +03:00
e7dae4b381 OdfFormatReader - fix after testing 2017-09-25 16:46:32 +03:00
7dbbacf336 OdfFormatReader - fix after testing 2017-09-22 20:00:21 +03:00
f43a0bbfe2 . 2017-09-21 17:06:44 +03:00
746c228261 PptFormat - support vba macros 2017-09-21 16:59:38 +03:00
d8c7d41462 DocFormat - vba macros 2017-09-20 17:58:41 +03:00
4a9abce180 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  x2t version up
2017-09-20 14:21:11 +03:00
a78711a19c fix build for ios11 2017-09-20 14:21:04 +03:00
b69051a5b4 . 2017-09-20 10:04:34 +03:00
04e4f1adae Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-20 10:03:11 +03:00
6e15370af2 x2t version up 2017-09-19 19:46:10 +03:00
57465b60bf Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormatReader - support pilot(pivot) tables add flat open office formats ...
2017-09-19 19:33:48 +03:00
24d58fe189 fix for build 2017-09-19 19:33:41 +03:00
56bb39f716 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-19 18:21:33 +03:00
60bcca0090 OdfFormatReader - support pilot(pivot) tables
add flat open office formats
...
2017-09-19 18:20:33 +03:00
92ce863bdf v5.0.0 2017-09-19 17:04:56 +03:00
48d4b72d4b Merge pull request #39 from ONLYOFFICE/release/v5.0.0
xhtml bug
2017-09-18 10:35:39 +03:00
85de7ec7a6 xhtml bug 2017-09-15 19:07:14 +03:00
9e6d4950c2 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  store Editor.xlsx without m_bSaveXFile flag
  .
  font names project (full work)
  .
  fix open html file with incorrect extension
  .
  .
  .
  pivot table build on server
  XlsFormat pivots - fix after testing
  build error (not windows)
  first version zip reader (doctrenderer)
2017-09-14 17:08:28 +03:00
cb4befa078 up 2017-09-14 17:08:19 +03:00
ac1292a17a Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-09-14 13:35:25 +03:00
007a984c36 store Editor.xlsx without m_bSaveXFile flag 2017-09-13 19:35:56 +03:00
d3d3180402 . 2017-09-13 19:06:32 +03:00
fa9c096f3c font names project (full work) 2017-09-13 17:20:50 +03:00
e1ec9d942e . 2017-09-13 13:14:32 +03:00
4acaa75b06 Merge branch 'release/v5.0.0' of https://github.com/ONLYOFFICE/core into release/v5.0.0 2017-09-12 18:17:02 +03:00
431115ef48 fix open html file with incorrect extension 2017-09-12 18:16:26 +03:00
2d66d9902e . 2017-09-12 18:15:26 +03:00
206dd12a47 . 2017-09-12 16:14:08 +03:00
e8d3059fe8 . 2017-09-12 16:07:20 +03:00
f624f731de fix for build 2017-09-12 15:23:45 +03:00
ed373b7e2d pivot table build on server 2017-09-12 14:11:57 +03:00
a67eb5644d XlsFormat pivots - fix after testing 2017-09-12 13:11:41 +03:00
5040220d82 build error (not windows) 2017-09-12 10:42:54 +03:00
4f0b889f04 first version zip reader (doctrenderer) 2017-09-11 18:44:52 +03:00
c94768902b Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-09-11 17:07:26 +03:00
f575947c03 XlsFormat - fix 3d chart, fix empty chart, .. 2017-09-08 18:37:08 +03:00
16bdbafa75 fix for build 2017-09-08 10:40:25 +03:00
089871d3ae . 2017-09-07 19:35:58 +03:00
765677d952 XlsFormat - pivots errors value, .. 2017-09-07 19:34:52 +03:00
6afc38c899 XlsFormat - fix after tesing, pivot external links, pivot consolidations 2017-09-07 18:28:16 +03:00
a43639587f Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  fix cfb
  fix cryptopp
2017-09-07 18:08:40 +03:00
46d022388d up 2017-09-07 18:08:28 +03:00
31363e8f83 fix bug #35783 2017-09-07 14:11:16 +03:00
e1286e4b73 PptFormat - fix bug rotation shape 2017-09-07 13:22:02 +03:00
0366bcb341 fix cfb 2017-09-07 12:36:36 +03:00
452f717e0e . 2017-09-07 11:40:51 +03:00
ab3add9577 fix cryptopp 2017-09-07 11:39:50 +03:00
54939bca61 revert project 2017-09-07 10:27:18 +03:00
7ccde9c777 XlsFormat pivots - fix after testing 2017-09-06 19:52:28 +03:00
6bdfa26c7e up 2017-09-06 18:27:38 +03:00
a5bae64959 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  x2t version up
  XlsFormat pivots .. fix after testing
  ppsm
  dotm2docx_dir, xltm2xlsx_dir, potm2pptx_dir in params.xml
  .
  getIsNoBase64 true by default
  docm->docx with params.xml
  XlsFormat - support macros x2t  - oom->oox
  fix derypt file
  .
  fix bug after testing
  fix bugs after testing
  variations for oox formats
2017-09-06 16:00:07 +03:00
4d04a0d649 up 2017-09-06 15:59:57 +03:00
fb7af5b902 update crypto++ to 5.6.5 2017-09-06 15:59:48 +03:00
77172fb39c Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-09-06 14:34:25 +03:00
78ecdc676c . 2017-09-05 18:27:29 +03:00
bbccdf009b x2t version up 2017-09-05 14:52:58 +03:00
4b26066377 XlsFormat pivots .. fix after testing 2017-09-05 13:59:00 +03:00
8742163d51 ppsm 2017-09-05 13:48:57 +03:00
212753f831 dotm2docx_dir, xltm2xlsx_dir, potm2pptx_dir in params.xml 2017-09-01 15:58:10 +03:00
903236d890 . 2017-09-01 15:35:38 +03:00
15bd732b22 getIsNoBase64 true by default 2017-09-01 14:51:27 +03:00
3e86bf7644 docm->docx with params.xml 2017-09-01 14:45:40 +03:00
d6cd7c30f5 XlsFormat - support macros
x2t  - oom->oox
2017-09-01 13:29:13 +03:00
89b384abfe fix derypt file 2017-09-01 10:52:35 +03:00
f54baf3aa8 . 2017-08-31 18:50:01 +03:00
b2184f7167 fix bug after testing 2017-08-31 16:27:11 +03:00
3a10eabfe9 fix bugs after testing 2017-08-31 15:33:49 +03:00
f9e80f3602 variations for oox formats 2017-08-31 15:09:17 +03:00
80b1e5e886 . 2017-08-25 19:42:58 +03:00
d1a7800f36 restore commit DocBuilder 2017-08-25 17:22:36 +03:00
e223ffd0db Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-08-25 17:14:15 +03:00
b140f4b521 fix revert up (from release) 2017-08-25 17:11:59 +03:00
2d570818be fix docx under office 2007 2017-08-25 12:07:18 +03:00
1462f08825 Added multithread flag 2017-08-24 19:37:22 +03:00
92fb4ac40b . 2017-08-24 19:21:00 +03:00
2bf55b7c8b Merge pull request #38 from ONLYOFFICE/release/v5.0.0
Release/v5.0.0
2017-08-24 19:01:31 +03:00
cf2159cd54 Merge commit '50f47caea96d96f16cbb301b4283beabc29798d1' into develop 2017-08-24 17:59:14 +03:00
decfeec7a1 Merge branch 'release/v5.0.0' of https://github.com/ONLYOFFICE/core into release/v5.0.0 2017-08-24 17:52:28 +03:00
50f47caea9 fix write video/audio in oox 2017-08-24 17:51:43 +03:00
89cd81ecfd Added 'deploy' target 2017-08-24 17:25:23 +03:00
8df6286e80 Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-08-24 16:23:10 +03:00
e947c91a7b . 2017-08-24 16:22:03 +03:00
ef53ac4c63 RtfFormatReader - fix styles (change equals id & name) 2017-08-24 16:05:47 +03:00
f50dd716ad . 2017-08-24 14:37:52 +03:00
54d0260ea2 Merge remote-tracking branch 'origin/release/v5.0.0' into develop
# Conflicts:
#	XlsxSerializerCom/Writer/BinaryReader.h
2017-08-24 13:40:13 +03:00
2577365e08 RtfFormatWriter - small refactoring + fix users file 2017-08-24 13:34:08 +03:00
792a722063 Revert "up"
This reverts commit a7a78a09c1.
2017-08-24 12:09:29 +03:00
00df026108 fix open docx by office2007 2017-08-23 19:05:21 +03:00
56a4e80c83 XlsFormat - tabletyled pivot tables 2017-08-23 13:23:49 +03:00
a7a78a09c1 up 2017-08-23 11:29:42 +03:00
6f93eeae69 disable base64 on save to T format 2017-08-23 10:11:05 +03:00
be45d169d7 small refactoring writing vba in doct, xlst 2017-08-22 12:50:01 +03:00
0fc749f839 Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-08-21 19:14:46 +03:00
03267ba2ec fix users file 2017-08-21 19:10:24 +03:00
b0adc188a2 fix users files 2017-08-21 18:23:08 +03:00
048fbc4b18 fix users file 2017-08-21 16:37:33 +03:00
c0a061f2cb Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-08-21 12:10:37 +03:00
0296a6ef33 fix bug #35681 2017-08-21 12:09:32 +03:00
dcee112745 Merge branch 'release/v5.0.0' of https://github.com/ONLYOFFICE/core into release/v5.0.0 2017-08-21 11:27:30 +03:00
65709f9cc2 fix bug #35660 2017-08-21 11:26:18 +03:00
bf5c41b9a0 fix bug #35680 2017-08-21 11:22:08 +03:00
66b45dba7c fix users file 2017-08-18 17:31:36 +03:00
65e7372cf7 Merge remote-tracking branch 'origin/release/v5.0.0' into develop 2017-08-18 16:07:56 +03:00
2ce5708599 Odf, xls, doc - fix users files 2017-08-18 15:51:55 +03:00
1ea27ad7f8 Added multithread flag 2017-08-18 15:45:06 +03:00
48d94d24eb cache xlsx file to support pivot in xls, ods...; don't send jwt signature; and save in doctrenderer; 2017-08-18 14:49:56 +03:00
f5c569ab2a DocFormatReader ... 2017-08-18 12:01:45 +03:00
2e61fcfdd9 read/write pptm 2017-08-17 20:18:57 +03:00
3df883cbe8 return errors 2017-08-17 09:38:03 +03:00
0ed3f740b7 read/write docm 2017-08-16 18:05:59 +03:00
af2e76aea6 OdfFormatWriter - fix convert notes 2017-08-16 16:21:19 +03:00
6593230d48 . 2017-08-15 19:56:00 +03:00
e02c72b564 x2t version up. read/write xlsm. 2017-08-15 17:23:17 +03:00
c2964f92af . 2017-08-15 16:10:34 +03:00
15fb3a4f4e Revert "."
This reverts commit cff1836571.
2017-08-15 16:09:09 +03:00
cff1836571 . 2017-08-15 16:08:40 +03:00
cb57db3c8a . 2017-08-15 16:05:27 +03:00
d22fb105b6 OoxFormat - vbaProject, ... 2017-08-15 15:18:28 +03:00
89aba918bc OoxFormat - read/write vbaProject in binary 2017-08-14 19:24:21 +03:00
47c1e6f637 Merge branch 'develop' of github.com:ONLYOFFICE/core into develop 2017-08-14 16:36:45 +03:00
f5284c967b . 2017-08-14 16:32:41 +03:00
d465e29a0f v4.4.3 2017-08-14 16:30:52 +03:00
f43ef621cb OoxFormat - add vba & activeX controls 2017-08-14 16:26:30 +03:00
2f9a8eb77f OdfFormatReader - pilots converting .. 2017-08-11 09:47:20 +03:00
a70087e1f2 no base 64 data 2017-08-09 19:44:57 +03:00
c3da9a66a1 OdfFormatReader - convert pilots ... 2017-08-09 18:23:25 +03:00
f907a90be7 . 2017-08-09 18:22:42 +03:00
f65a27cf86 Build the v8 in multithreaded mode 2017-08-09 17:06:52 +03:00
ed59c2b998 . 2017-08-09 14:55:02 +03:00
925bca7149 OdfFormatWriter - small refactoring, fix chart size (from xls) 2017-08-09 13:36:00 +03:00
c9f2315186 CASCHTMLRenderer3 CloseFile IsNoBase64 2017-08-08 19:05:58 +03:00
5818f4997b htmlrenderer no base64 2017-08-08 18:59:16 +03:00
691042c507 OdfFormatReader - convert pilot tables 2017-08-08 18:24:33 +03:00
d8f34224ca OdfFormatReader - pilot tables 2017-08-08 15:02:07 +03:00
dfe4541f43 . 2017-08-08 12:37:40 +03:00
3fa3a52c89 . 2017-08-07 17:14:41 +03:00
665783a6c5 palette alpha 2017-08-07 15:27:24 +03:00
0b15c31487 fix bug #35485 2017-08-07 15:12:14 +03:00
44fdbf6df4 OdfFormatWriter - fix notes layouts 2017-08-07 14:00:23 +03:00
582fce4ca1 fix bug #35466 2017-08-07 11:13:27 +03:00
bde723c5cb internal onlyoffice field for comment time 2017-08-03 15:08:01 +03:00
97fb316248 internal onlyoffice field for comment time 2017-08-03 15:07:11 +03:00
a607282285 refactoring... 2017-08-02 17:27:41 +03:00
62ea2bbc46 Editor.bin without base64 2017-07-27 14:49:57 +03:00
4071fa315b Added building hunspell 2017-07-26 13:22:00 +03:00
82eae7fc3e hunspell dynamic link 2017-07-26 11:18:25 +03:00
8efed345b0 fix bug #35412 2017-07-24 17:32:31 +03:00
f5dcb1bed7 Merge branch 'hotfix/v4.4.2' into develop
Conflicts:
	ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp
2017-07-24 15:46:05 +03:00
89ce79dafc v4.4.2 2017-07-24 15:25:00 +03:00
6b4695fc3a . 2017-07-24 15:06:01 +03:00
bed884007c PptxFormat - slide sections 2017-07-23 16:38:57 +03:00
1aa0b03901 XlsFormat - fix pivots after testing 2017-07-21 19:41:26 +03:00
e2ada4ca61 Merge commit '08e97b4a68950d969dce001f8e1ead84086c0244' into develop 2017-07-21 18:40:26 +03:00
d87649f08e no message 2017-07-21 18:37:34 +03:00
3982ac06d2 Merge pull request #35 from ONLYOFFICE/feature/lena_fix_2
fix not compiled
2017-07-21 17:38:16 +03:00
0a5d0af882 fix not compiled 2017-07-21 17:36:56 +03:00
08e97b4a68 Merge pull request #34 from ONLYOFFICE/feature/lenas-fixes
Feature/lenas fixes
2017-07-21 16:21:05 +03:00
c4447d7396 fix bug #35395 2017-07-21 16:12:28 +03:00
c55af15ccd . 2017-07-21 15:47:36 +03:00
333d2fdbf0 fix 2017-07-21 15:36:47 +03:00
a2bbb1640c project for mac debug 2017-07-20 17:46:38 +03:00
7388bf871f refactoring 2017-07-20 17:41:28 +03:00
493238d656 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-07-20 16:40:01 +03:00
ea8dc009c9 OdfFormatReader - pilot(pivot) tables 2017-07-20 16:39:23 +03:00
9ade820313 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  fix unsize shape text rect
  XlsFormat - pivot charts
  fix bug #35396. version up.
  .
  OdfFormatWriter - data label position XlsFormatReader - fix pivots
2017-07-20 16:38:41 +03:00
358c1613ad fix bug #35395 2017-07-20 16:38:30 +03:00
b3a83ad699 . 2017-07-20 13:28:58 +03:00
8d4e78ed40 fix unsize shape text rect 2017-07-20 13:28:52 +03:00
bde2c73f64 XlsFormat - pivot charts 2017-07-20 11:14:47 +03:00
66fe9e6447 Merge remote-tracking branch 'origin/hotfix/v4.4.2' into develop 2017-07-19 12:25:21 +03:00
f6d745cd25 Merge remote-tracking branch 'origin/hotfix/v4.4.2' into develop 2017-07-20 11:21:03 +03:00
002d30454c fix bug #35396. version up. 2017-07-20 11:19:07 +03:00
ae2e9a5f26 . 2017-07-19 12:22:58 +03:00
c985d1e0a2 OdfFormatWriter - data label position
XlsFormatReader - fix pivots
2017-07-18 19:25:39 +03:00
5aaf90ebf2 Merge remote-tracking branch 'origin/hotfix/v4.4.2' into develop 2017-07-17 19:43:41 +03:00
ebb9c89a0a fix bug #35389 2017-07-17 19:42:35 +03:00
c4765e9f2e fix bug #24236 2017-07-17 17:39:50 +03:00
3ff5233ea4 Merge remote-tracking branch 'origin/hotfix/v4.4.2' into develop 2017-07-17 13:16:07 +03:00
4c7ab6e616 OdfFormatWriter - fix convert named range with formulas 2017-07-17 13:13:29 +03:00
a88ad0c279 XlsFormat - fix calculations in pivot tables 2017-07-14 11:43:16 +03:00
cf5458c761 XlsFormat - pivot tables 2017-07-13 18:09:17 +03:00
9115edbd78 fix bug #35382. 2017-07-13 17:51:32 +03:00
3f18f96171 codegen change Pivot constants format 2017-07-13 17:13:38 +03:00
8a75916944 XlsFormat - pivots dB connections 2017-07-12 16:40:36 +03:00
da45eb4f33 XlsFormat - pivots... 2017-07-12 11:25:12 +03:00
59d75ed148 XlsFormat - fix pivots 2017-07-06 19:09:06 +03:00
1699 changed files with 158267 additions and 155288 deletions

3
.gitignore vendored
View File

@ -45,3 +45,6 @@ OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
*.tlb
*.idb
**/.hg
*.zip
*.tar.gz
**/*.build/

View File

@ -501,7 +501,7 @@ namespace DocFileFormat
facet.widen((char*)bytes, (char*)bytes + size, &result[0]);
for (long i=0; i < result.length(); i++)
for (size_t i=0; i < result.length(); i++)
{
STLCollection->push_back(result[i]);
}
@ -536,7 +536,7 @@ namespace DocFileFormat
delete [] pStrUtf16;
return GetSTLCollectionFromLocale(STLCollection, bytes,size);
}
for (long i=0; i < nLength; i++)
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf16[i]);
}
@ -566,7 +566,7 @@ namespace DocFileFormat
delete [] pStrUtf32;
return GetSTLCollectionFromLocale(STLCollection, bytes, size);
}
for (long i=0; i < nLength; i++)
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf32[i]);
}
@ -652,7 +652,7 @@ namespace DocFileFormat
NSUnicodeConverter::CUnicodeConverter oConverter;
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, size, sCodePage.c_str());
for (long i=0; i < unicode_string.size(); i++)
for (size_t i = 0; i < unicode_string.size(); i++)
{
STLCollection->push_back(unicode_string[i]);
}

View File

@ -393,7 +393,7 @@ namespace XMLTools
else
{
std::string s(m_str.begin(), m_str.end());
file.WriteFile((unsigned char*)s.c_str(), s.length());
file.WriteFile((unsigned char*)s.c_str(), (DWORD)s.length());
}
file.CloseFile();
return true;

View File

@ -321,7 +321,7 @@ namespace DocFileFormat
case sprmCFtcBi :
{//default from FontTable
SHORT nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
size_t nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
if( nIndex < _doc->FontTable->Data.size() )
{
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
@ -373,7 +373,7 @@ namespace DocFileFormat
case sprmOldCFtc:
case sprmCRgFtc0:
{ // font family
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex < _doc->FontTable->Data.size() )
{
@ -388,7 +388,8 @@ namespace DocFileFormat
case sprmCRgFtc1:
{
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex >= 0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute( L"w:eastAsia" );
@ -403,7 +404,8 @@ namespace DocFileFormat
case sprmCRgFtc2:
{
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
{
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute( L"w:hAnsi" );

View File

@ -68,12 +68,12 @@ namespace DocFileFormat
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 (unsigned int i = 0; i < count; ++i)
for (size_t i = 0; i < count; ++i)
{
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index ));
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
m_pXmlWriter->WriteAttribute( L"w:author",
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ));
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->GetUserInitials());

View File

@ -157,6 +157,7 @@ namespace OpenXmlRelationshipTypes
static const wchar_t* OleObject = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
static const wchar_t* GlossaryDocument = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument";
static const wchar_t* Package = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
static const wchar_t* VbaProject = L"http://schemas.microsoft.com/office/2006/relationships/vbaProject";
}
namespace MicrosoftWordRelationshipTypes

View File

@ -65,7 +65,7 @@ namespace DocFileFormat
{
ConversionContext context( doc, docx );
//Write styles.xml
//Write styles.xml
if (doc->Styles)
{
StyleSheetMapping styleSheetMapping( &context );
@ -88,9 +88,7 @@ namespace DocFileFormat
return S_FALSE;
}
}
//Write numbering.xml
//Write numbering.xml
if (doc->listTable)
{
NumberingMapping numberingMapping( &context );
@ -110,7 +108,7 @@ namespace DocFileFormat
}
}
//Write fontTable.xml
//Write fontTable.xml
if (doc->FontTable)
{
FontTableMapping fontTableMapping( &context );
@ -130,7 +128,7 @@ namespace DocFileFormat
}
}
//write the footnotes
//write the footnotes
FootnotesMapping footnotesMapping( &context );
doc->Convert( &footnotesMapping );
@ -147,7 +145,7 @@ namespace DocFileFormat
}
}
//write the endnotes
//write the endnotes
EndnotesMapping endnotesMapping( &context );
doc->Convert( &endnotesMapping );
@ -164,7 +162,7 @@ namespace DocFileFormat
}
}
//write the comments
//write the comments
CommentsMapping commentsMapping( &context );
doc->Convert( &commentsMapping );
@ -181,13 +179,13 @@ namespace DocFileFormat
}
}
//write settings.xml at last because of the rsid list
//write settings.xml at last because of the rsid list
if (doc->DocProperties)
{
SettingsMapping settingsMapping( &context );
doc->DocProperties->Convert( &settingsMapping );
}
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 975000 );
@ -204,7 +202,7 @@ namespace DocFileFormat
return S_OK;
}
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress)
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
{
long result = S_FALSE;
@ -219,7 +217,7 @@ namespace DocFileFormat
if (result == S_OK)
{
docx.SaveDocument();
docx.SaveDocument(bMacros);
if (progress)progress->OnProgress(progress->caller, DOC_ONPROGRESSEVENT_ID, 1000000);

View File

@ -48,7 +48,7 @@ namespace DocFileFormat
std::wstring m_sTempFolder;
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress);
long 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);

View File

@ -88,7 +88,7 @@ namespace DocFileFormat
int DocumentMapping::getCurrentSection(int cp)
{
//if cp is the last char of a section, the next section will start at cp +1
int current = 0;
size_t current = 0;
for (std::vector<int>::iterator iter = m_document->SectionPlex->CharacterPositions.begin() + 1; iter != m_document->SectionPlex->CharacterPositions.end(); ++iter)
{
@ -107,7 +107,7 @@ namespace DocFileFormat
{
if ( !m_document->ListPlex ) return -1;
for (int i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
for (size_t i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
{
if ((fc >= m_document->ListPlex->CharacterPositions[i-1]) && (fc_end <= m_document->ListPlex->CharacterPositions[i]))
{
@ -290,17 +290,15 @@ namespace DocFileFormat
std::vector<wchar_t>* chpxChars = m_document->GetChars(fcChpxStart, fcChpxEnd, cp);
//search for bookmarks in the chars
std::vector<int> bookmarks = searchBookmarks(chpxChars, cp);
//if there are bookmarks in this run, split the run into several runs
if (!bookmarks.empty())
std::vector<int> annot = searchAnnot(chpxChars, cp);
if (!annot.empty())
{
std::list<std::vector<wchar_t>>* runs = splitCharList(chpxChars, &bookmarks);
std::list<std::vector<wchar_t>>* runs = splitCharList(chpxChars, &annot);
if (runs)
{
for (std::list<std::vector<wchar_t> >::iterator iter = runs->begin(); iter != runs->end(); ++iter)
{
if (writeBookmarks(cp))
if (writeAnnotations(cp))
{
cp = writeRun(&(*iter), *cpeIter, cp);
}
@ -311,7 +309,30 @@ namespace DocFileFormat
}
else
{
cp = writeRun(chpxChars, *cpeIter, cp);
//search for bookmarks in the chars
std::vector<int> bookmarks = searchBookmarks(chpxChars, cp);
//if there are bookmarks in this run, split the run into several runs
if (!bookmarks.empty())
{
std::list<std::vector<wchar_t>>* runs = splitCharList(chpxChars, &bookmarks);
if (runs)
{
for (std::list<std::vector<wchar_t> >::iterator iter = runs->begin(); iter != runs->end(); ++iter)
{
if (writeBookmarks(cp))
{
cp = writeRun(&(*iter), *cpeIter, cp);
}
}
RELEASEOBJECT(runs);
}
}
else
{
cp = writeRun(chpxChars, *cpeIter, cp);
}
}
RELEASEOBJECT(chpxChars);
@ -361,7 +382,7 @@ namespace DocFileFormat
int DocumentMapping::writeRun (std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp)
{
int cp = initialCp;
int result_cp = cp + chars->size();
int result_cp = cp + (int)chars->size();
if ((_skipRuns <= 0) && (chars->size() > 0))
{
@ -543,7 +564,7 @@ namespace DocFileFormat
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
std::wstring f;
if (cpFieldEnd < m_document->Text->size())
if (cpFieldEnd < (int)m_document->Text->size())
f = std::wstring( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) );
std::wstring EMBED ( L" EMBED" );
@ -639,11 +660,11 @@ namespace DocFileFormat
if (search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end())
{
int d = f1.find(PAGEREF);
int d = (int)f1.find(PAGEREF);
_writeWebHidden = true;
std::wstring _writeTocLink =f1.substr(d + 9);
d = _writeTocLink.find(L" ");
d = (int)_writeTocLink.find(L" ");
_writeTocLink = _writeTocLink.substr(0, d);
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
@ -881,7 +902,7 @@ namespace DocFileFormat
{
int shape_type = oPicture.shapeContainer->getShapeType();
if (shape_type != msosptPictureFrame) picture = false;
if (shape_type != msosptPictureFrame) picture = false;//шаблон 1.doc картинка в колонтитуле
}
if (picture)
@ -948,19 +969,17 @@ namespace DocFileFormat
}
else if (TextMark::AnnotationReference == code)
{
if (typeid(*this) != typeid(CommentsMapping))
{
m_pXmlWriter->WriteNodeBegin( L"w:commentReference", true );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
else
if (typeid(*this) == typeid(CommentsMapping))
{
m_pXmlWriter->WriteNodeBegin( L"w:annotationRef", true );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
else
{
m_pXmlWriter->WriteNodeBegin( L"w:commentReference", true );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
_commentNr++;
}
else if (!FormatUtils::IsControlSymbol(c) && ((int)c != 0xFFFF))
{
@ -1042,6 +1061,30 @@ namespace DocFileFormat
return ret;
}
// Searches for bookmarks in the list of characters.
std::vector<int> DocumentMapping::searchAnnot(std::vector<wchar_t>* chars, int initialCp)
{
std::vector<int> ret;
if (m_document->AnnotStartPlex->IsValid())
{
int cp = initialCp;
size_t count = chars->size();
for (size_t i = 0; i < count; ++i)
{
if ((m_document->AnnotStartPlex->IsCpExists(cp)) || (m_document->AnnotEndPlex->IsCpExists(cp)))
{
ret.push_back(i);
}
++cp;
}
}
return ret;
}
ParagraphPropertyExceptions* DocumentMapping::findValidPapx(int fc)
{
@ -1133,7 +1176,8 @@ namespace DocFileFormat
TableInfo tai( papx );
//build the table grid
std::vector<short>* grid = buildTableGrid( cp, nestingLevel );
std::vector<short> grid, grid_write;
buildTableGrid( cp, nestingLevel, grid, grid_write );
//find first row end
int fcRowEnd = findRowEndFc( cp, nestingLevel );
@ -1144,7 +1188,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"w:tbl" );
//Convert it
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, grid );
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid, &grid_write );
row1Tapx.Convert( tpMapping );
@ -1157,7 +1201,7 @@ namespace DocFileFormat
//only convert the cells with the given nesting level
while ( tai.iTap == nestingLevel )
{
cp = writeTableRow( cp, grid, nestingLevel );
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
//?fc = m_document->FindFileCharPos(cp );
fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
papx = findValidPapx( fc );
@ -1170,7 +1214,7 @@ namespace DocFileFormat
//convert until the end of table is reached
while ( tai.fInTable )
{
cp = writeTableRow( cp, grid, nestingLevel );
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
fc = m_document->FindFileCharPos( cp );
papx = findValidPapx( fc );
@ -1181,18 +1225,16 @@ namespace DocFileFormat
//close w:tbl
m_pXmlWriter->WriteNodeEnd( L"w:tbl" );
RELEASEOBJECT( grid );
return cp;
}
// Builds a list that contains the width of the several columns of the table.
std::vector<short>* DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel)
bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write)
{
ParagraphPropertyExceptions* backup = _lastValidPapx;
std::vector<short> boundaries;
std::vector<short>* grid = new std::vector<short>();
std::vector<short> boundaries_all;
int cp = initialCp;
int fc = m_document->FindFileCharPos( cp );
@ -1209,25 +1251,43 @@ namespace DocFileFormat
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{
//find the tDef SPRM
if ( iter->OpCode == sprmTDefTable || iter->OpCode == sprmOldTDefTable)
DWORD code = iter->OpCode;
switch(iter->OpCode)
{
unsigned char itcMac = iter->Arguments[0];
for (int i = 0; i < itcMac; i++)
case sprmTDefTable:
case sprmOldTDefTable:
{
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
unsigned char itcMac = iter->Arguments[0];
if ( find( boundaries.begin(), boundaries.end(), boundary1 ) == boundaries.end() )
while(boundaries.size() < itcMac + 1)
boundaries.push_back(-0x7fff);
short boundary0 = -0x7fff;
for (unsigned char i = 0; i < itcMac; i++)
{
boundaries.push_back( boundary1 );
}
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1)
{
if ( boundaries[i] == -0x7fff || boundaries[i+1] == -0x7fff)
{
boundaries[i] = boundary1;
boundaries[i+1] = boundary2;
}
}
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary1 ) == boundaries_all.end() )
{
boundaries_all.push_back( boundary1 );
}
if ( find( boundaries.begin(), boundaries.end(), boundary2 ) == boundaries.end() )
{
boundaries.push_back( boundary2 );
}
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() )
{
boundaries_all.push_back( boundary2 );
}
boundary0 = boundary1;
}break;
}
}
}
@ -1243,19 +1303,25 @@ namespace DocFileFormat
}
//build the grid based on the boundaries
sort( boundaries.begin(), boundaries.end() );
sort( boundaries_all.begin(), boundaries_all.end() );
if ( !boundaries.empty() )
{
for ( unsigned int i = 0; i < ( boundaries.size() - 1 ); i++ )
for ( size_t i = 0; i < ( boundaries.size() - 1 ); i++ )
{
grid->push_back( boundaries[i + 1] - boundaries[i] );
grid_write.push_back( boundaries[i + 1] - boundaries[i] );
}
}
if ( !boundaries_all.empty() )
{
for ( size_t i = 0; i < ( boundaries_all.size() - 1 ); i++ )
{
grid.push_back( boundaries_all[i + 1] - boundaries_all[i] );
}
}
_lastValidPapx = backup;
return grid;
return true;
}
// Finds the FC of the next row end mark.
@ -1375,7 +1441,7 @@ namespace DocFileFormat
}
/// Writes the table row that starts at the given cp value and ends at the next row end mark
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, unsigned int nestingLevel)
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel)
{
int cp = initialCp;
int fc = m_document->FindFileCharPos( cp );
@ -1405,7 +1471,7 @@ namespace DocFileFormat
//Write until the first "inner trailer paragraph" is reached
while ( !( ( m_document->Text->at( cp ) == TextMark::ParagraphEnd ) && ( tai.fInnerTtp ) ) && tai.fInTable )
{
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
cellIndex++;
//each cell has it's own PAPX
@ -1422,7 +1488,7 @@ namespace DocFileFormat
while ( !( ( m_document->Text->at( cp ) == TextMark::CellOrRowMark ) && ( tai.fTtp ) )
&& tai.fInTable )
{
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
cellIndex++;
//each cell has it's own PAPX
@ -1445,18 +1511,15 @@ namespace DocFileFormat
}
/// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel )
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel )
{
int cp = initialCp;
int cp = initialCp;
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
//find cell end
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
//convert the properties
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex );
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex );
if ( tapx != NULL )
{
@ -1467,7 +1530,7 @@ namespace DocFileFormat
RELEASEOBJECT( tcpMapping );
//write the paragraphs of the cell
//write the paragraphs of the cell
while ( cp < cpCellEnd )
{
//cp = writeParagraph(cp);
@ -1498,7 +1561,7 @@ namespace DocFileFormat
}
}
//end w:tc
//end w:tc
m_pXmlWriter->WriteNodeEnd( L"w:tc" );
return cp;
@ -1540,7 +1603,6 @@ namespace DocFileFormat
return cpCellEnd;
}
//
bool DocumentMapping::writeBookmarks(int cp)
{
bool result = true;
@ -1561,7 +1623,27 @@ namespace DocFileFormat
return result;
}
bool DocumentMapping::writeAnnotations(int cp)
{
bool result = true;
for (size_t i = 0; i < m_document->AnnotStartEndCPs.size(); i++)
{
if (m_document->AnnotStartEndCPs[i].first == cp)
{
result = writeAnnotationStart(i + 1);
_commentNr = i + 1;
}
if (m_document->AnnotStartEndCPs[i].second == cp)
{
result = writeAnnotationEnd(i + 1);
_commentNr = i + 1;
}
}
return result;
}
bool DocumentMapping::writeBookmarkStart(short id)
{
// write bookmark start
@ -1585,8 +1667,6 @@ namespace DocFileFormat
bool DocumentMapping::writeBookmarkEnd(short id)
{
// write bookmark end
WideString* bookmarkName = static_cast<WideString*>( m_document->BookmarkNames->operator [] ( id ) );
if ( ( bookmarkName != NULL ) && ( *bookmarkName != L"_PictureBullets" ) )
@ -1602,7 +1682,27 @@ namespace DocFileFormat
return false;
}
bool DocumentMapping::writeAnnotationStart(short id)
{
XMLTools::XMLElement bookmarkElem(L"w:commentRangeStart");
bookmarkElem.AppendAttribute(L"w:id", FormatUtils::IntToWideString(id));
m_pXmlWriter->WriteString(bookmarkElem.GetXMLString());
return true;
}
bool DocumentMapping::writeAnnotationEnd(short id)
{
XMLTools::XMLElement bookmarkElem( L"w:commentRangeEnd" );
bookmarkElem.AppendAttribute( L"w:id", FormatUtils::IntToWideString( id ));
m_pXmlWriter->WriteString( bookmarkElem.GetXMLString());
return true;
}
// Checks if the CHPX is special
bool DocumentMapping::isSpecial(CharacterPropertyExceptions* chpx)
{

View File

@ -99,28 +99,33 @@ namespace DocFileFormat
void writeTextStart ( const std::wstring& textType, bool preserve_space);
void writeTextEnd ( const std::wstring& textType );
// Searches for bookmarks in the list of characters.
std::vector<int> searchBookmarks( std::vector<wchar_t>* chars, int initialCp );
std::vector<int> searchAnnot(std::vector<wchar_t>* chars, int initialCp);
ParagraphPropertyExceptions* findValidPapx( int fc );
// Splits a list of characters into several lists
std::list<std::vector<wchar_t> >* splitCharList( std::vector<wchar_t>* chars, std::vector<int>* splitIndices );
// Writes the table starts at the given cp value
int writeTable ( int initialCp, unsigned int nestingLevel );
// Builds a list that contains the width of the several columns of the table.
std::vector<short>* buildTableGrid( int initialCp, unsigned int nestingLevel );
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write );
// Finds the FC of the next row end mark.
int findRowEndFc ( int initialCp, int& rowEndCp, unsigned int nestingLevel );
// Finds the FC of the next row end mark.
int findRowEndFc ( int initialCp, unsigned int nestingLevel );
// Writes the table row that starts at the given cp value and ends at the next row end mark
int writeTableRow ( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
int writeTableRow ( int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel );
// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
bool writeBookmarks ( int cp );
bool writeBookmarkStart ( short id );
bool writeBookmarkEnd ( short id );
bool writeAnnotations ( int cp );
bool writeAnnotationStart( short id );
bool writeAnnotationEnd ( short id );
// Checks if the CHPX is special
bool isSpecial( CharacterPropertyExceptions* chpx );
// Finds the SEPX that is valid for the given CP.

View File

@ -75,6 +75,8 @@ namespace DocFileFormat
while ( ( cp - m_document->FIB->m_RgLw97.ccpText ) < (*m_document->IndividualFootnotesPlex)[id + 1] )
{
int cpStart = cp;
int fc = m_document->FindFileCharPos(cp);
if (fc < 0) break;
@ -93,6 +95,8 @@ namespace DocFileFormat
//this PAPX is for a normal paragraph
cp = writeParagraph( cp );
}
while (cp <= cpStart) //conv_fQioC665ib4ngHkDGY4__docx.doc
cp++;
}
m_pXmlWriter->WriteNodeEnd( L"w:footnote");

View File

@ -33,6 +33,8 @@
#include "IMapping.h"
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
namespace DocFileFormat
{
class IVisitable

View File

@ -50,8 +50,7 @@ namespace DocFileFormat
void MainDocumentMapping::Apply(IVisitable* visited)
{
m_document = static_cast<WordDocument*>(visited);
m_context->_docx->RegisterDocument();
// Header
m_pXmlWriter->WriteNodeBegin(L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin(L"w:document", TRUE );
@ -124,11 +123,14 @@ namespace DocFileFormat
TableInfo tai(papx);
if (tai.fInTable)
{
int cpStart = cp;
//this PAPX is for a table
//cp = writeTable( cp, tai.iTap );
Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) );
table.Convert(this);
cp = table.GetCPEnd();
while (cp <= cpStart) //conv_eznHsm8em2unSv6_2QE__docx.doc
cp++;
}
else
{

View File

@ -582,7 +582,7 @@ namespace DocFileFormat
// The style id is used for a reverse reference.
// It can happen that the reference points to the wrong style.
if (styleIndex != ListData::ISTD_NIL)
if (styleIndex != ListData::ISTD_NIL && styleIndex < m_document->Styles->Styles->size())
{
m_pXmlWriter->WriteNodeBegin( L"w:pStyle", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId(m_document->Styles->Styles->at(styleIndex))));

View File

@ -136,7 +136,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;
}
@ -144,12 +144,19 @@ 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;
}
}
if ((size_t)point.y > 0xffff)
{
point.y &= 0xffff;
}
if ((size_t)point.x > 0xffff)
{
point.x &= 0xffff;
}
m_arPoints.push_back(point);
}
}

View File

@ -63,8 +63,25 @@ namespace DocFileFormat
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
if (sh->shapeType) return sh->shapeType->GetTypeCode();
else return 0;
if (sh->shapeType)
{
return sh->shapeType->GetTypeCode();
}
else
{
for ( std::vector<Record*>::const_iterator iter1 = this->Children.begin(); iter1 != this->Children.end(); iter1++ )
{
ShapeOptions* sh_options = dynamic_cast<ShapeOptions*>( *iter1 );
if (sh_options)
{
if (sh_options->OptionsByID.end() != sh_options->OptionsByID.find(Pib))
{
return msosptPictureFrame;
}
}
}
return 0;
}
}
}
return 0;

View File

@ -46,35 +46,35 @@ OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorage
HRESULT res = S_OK;
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, "ObjectPool");
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, L"ObjectPool");
if (ObjectPoolStorage)
{
ObjectId = getOleEntryName( chpx );
std::string sObjectId( ObjectId.begin(), ObjectId.end() );
std::wstring sObjectId( ObjectId.begin(), ObjectId.end() );
{
std::string name = "ObjectPool/" + sObjectId + "/";
processOleStream( name + "Ole" );
std::wstring name = L"ObjectPool/" + sObjectId + L"/";
processOleStream( name + L"Ole" );
if ( bLinked )
{
processLinkInfoStream( name + "LinkInfo" );
processLinkInfoStream( name + L"LinkInfo" );
}
else
{
processCompObjStream( name + "CompObj" );
processCompObjStream( name + L"CompObj" );
}
processPICStream( name + "PIC" );
processPICStream( name + L"PIC" );
processEquationNativeStream( name + "Equation Native" );
processEquationNativeStream( name + L"Equation Native" );
}
delete ObjectPoolStorage;
}
}
void OleObject::processLinkInfoStream( const std::string& linkStream )
void OleObject::processLinkInfoStream( const std::wstring& linkStream )
{
try
{
@ -125,7 +125,7 @@ void OleObject::processLinkInfoStream( const std::string& linkStream )
}
}
void OleObject::processEquationNativeStream( const std::string& eqStream )
void OleObject::processEquationNativeStream( const std::wstring& eqStream )
{
try
{
@ -156,7 +156,7 @@ void OleObject::processEquationNativeStream( const std::string& eqStream )
}
}
void OleObject::processPICStream( const std::string& picStream )
void OleObject::processPICStream( const std::wstring& picStream )
{
try
{
@ -191,7 +191,7 @@ void OleObject::processPICStream( const std::string& picStream )
}
}
void OleObject::processCompObjStream( const std::string& compStream )
void OleObject::processCompObjStream( const std::wstring& compStream )
{
try
{
@ -206,11 +206,11 @@ void OleObject::processCompObjStream( const std::string& compStream )
//skip the CompObjHeader
reader.ReadBytes( 28, false );
int sz_obj = reader.GetSize() - reader.GetPosition();
unsigned int sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
{
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
@ -218,7 +218,7 @@ void OleObject::processCompObjStream( const std::string& compStream )
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
}
delete pCompStream;
}
@ -228,7 +228,7 @@ void OleObject::processCompObjStream( const std::string& compStream )
}
}
void OleObject::processOleStream( const std::string& oleStreamName )
void OleObject::processOleStream( const std::wstring& oleStreamName )
{
try
{

View File

@ -74,11 +74,11 @@ namespace DocFileFormat
private:
POLE::Storage *oleStorage;
void processLinkInfoStream ( const std::string& linkStream );
void processEquationNativeStream( const std::string& eqStream );
void processPICStream ( const std::string& picStream );
void processCompObjStream ( const std::string& compStream );
void processOleStream ( const std::string& oleStreamName );
void processLinkInfoStream ( const std::wstring& linkStream );
void processEquationNativeStream( const std::wstring& eqStream );
void processPICStream ( const std::wstring& picStream );
void processCompObjStream ( const std::wstring& compStream );
void processOleStream ( const std::wstring& oleStreamName );
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
};

View File

@ -73,7 +73,6 @@ namespace DocFileFormat
NSDirectory::CreateDirectory( m_strOutputPath + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"_rels" );
WriteRelsFile( DocumentRelationshipsFile );
WriteRelsFile( FootnotesRelationshipsFile );
@ -137,15 +136,17 @@ namespace DocFileFormat
{
NSFile::CFileBinary file;
file.CreateFileW(fileName);
file.WriteFile((BYTE*)data.c_str(), data.size());
file.WriteFile((BYTE*)data.c_str(), (_UINT32)data.size());
file.CloseFile();
return S_OK;
}
HRESULT OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure )
{
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
if (storageOut == NULL || docFile == NULL) return S_FALSE;
if (docFile == NULL) return S_FALSE;
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
if (storageOut == NULL) return S_FALSE;
if (storageOut->open(true, true)==false)
{
delete storageOut;
@ -155,20 +156,19 @@ namespace DocFileFormat
POLE::Storage *storageInp = docFile->GetStorage()->GetStorage();
{
std::string id(oleObjectFileStructure.objectID.begin(),oleObjectFileStructure.objectID.end());
POLE::Stream* oleStorage = new POLE::Stream(storageInp, id);
POLE::Stream* oleStorage = new POLE::Stream(storageInp, oleObjectFileStructure.objectID);
if (oleStorage)
{
std::string path = "ObjectPool/" + id;
std::list<std::string> entries = storageInp->entries(path);
for (std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++)
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
std::list<std::wstring> entries = storageInp->entries(path);
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++)
{
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + "/"+ (*it));
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + L"/"+ (*it));
if (stream_inp == NULL)continue;
int size = stream_inp->size();
POLE::uint64 size = stream_inp->size();
POLE::Stream *stream_out = new POLE::Stream(storageOut, *it, true, size);
@ -199,7 +199,14 @@ namespace DocFileFormat
{
return AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocument, L"");
}
int OpenXmlPackage::RegisterDocumentMacros()
{
return AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocumentMacro, L"");
}
int OpenXmlPackage::RegisterVbaProject()
{
return AddPart( L"word", L"vbaProject.bin", MicrosoftWordContentTypes::VbaProject, OpenXmlRelationshipTypes::VbaProject );
}
int OpenXmlPackage::RegisterFontTable()
{
return AddPart( L"word", L"fontTable.xml", WordprocessingMLContentTypes::FontTable, OpenXmlRelationshipTypes::FontTable );

View File

@ -118,6 +118,8 @@ namespace DocFileFormat
class OpenXmlPackage
{
public:
const WordDocument* docFile;
private:
ContentTypesFile DocumentContentTypesFile;
RelationshipsFile MainRelationshipsFile;
@ -137,8 +139,6 @@ namespace DocFileFormat
int _footerCounter;
int _oleCounter;
const WordDocument* docFile;
int AddHeaderPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
int AddFooterPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
int AddFootnotesPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
@ -166,6 +166,7 @@ namespace DocFileFormat
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
int RegisterDocument();
int RegisterDocumentMacros();
int RegisterFontTable();
int RegisterNumbering();
int RegisterSettings();
@ -179,5 +180,6 @@ namespace DocFileFormat
int RegisterOLEObject ( const IMapping* mapping, const std::wstring& objectType );
int RegisterPackage ( const IMapping* mapping, const std::wstring& objectType);
int RegisterExternalOLEObject( const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri );
int RegisterVbaProject();
};
}

View File

@ -154,7 +154,7 @@ namespace DocFileFormat
case sprmPFBiDi:
{
bool val = iter->argumentsSize > 0 ? iter->Arguments[0] : true;
bool val = iter->argumentsSize > 0 ? (iter->Arguments[0] != 0) : true;
appendFlagElement( _pPr, *iter, L"bidi", val);
_isBidi = val;
}break;
@ -427,7 +427,7 @@ namespace DocFileFormat
if (m_document->listTable)
{
m_document->listTable->appendNumbering( desc );
short numId = m_document->listTable->listNumbering.size();
short numId = static_cast<short>(m_document->listTable->listNumbering.size());
appendValueElement( &numPr, L"numId", numId, true );
}
}break;
@ -485,7 +485,7 @@ namespace DocFileFormat
{
XMLTools::XMLElement tabs( L"w:tabs" );
int pos = 0;
unsigned int pos = 0;
//read the removed tabs
unsigned char itbdDelMax = iter->Arguments[pos];

View File

@ -462,57 +462,60 @@ namespace DocFileFormat
void PropertiesMapping::appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc )
{
std::wstring pattern = getShadingPattern( desc );
if ( ( parent != NULL ) && ( desc.shadingSpecialValue == shadingSpecialValueNormal ))
{
XMLTools::XMLElement shd( L"w:shd" );
//fill color
XMLTools::XMLAttribute fill( L"w:fill" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvBackAuto )
{
fill.SetValue( L"auto" );
}
else
{
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
}
}
else
{
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( fill );
//foreground color
XMLTools::XMLAttribute color( L"w:color" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvForeAuto )
{
color.SetValue( L"auto" );
}
else
{
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
}
}
else
{
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( color );
//pattern
XMLTools::XMLAttribute val( L"w:val" );
val.SetValue( getShadingPattern( desc ));
val.SetValue( pattern);
shd.AppendAttribute( val );
if (pattern != L"nil")
{
//fill color
XMLTools::XMLAttribute fill( L"w:fill" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvBackAuto )
{
fill.SetValue( L"auto" );
}
else
{
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
}
}
else
{
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( fill );
//foreground color
XMLTools::XMLAttribute color( L"w:color" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvForeAuto )
{
color.SetValue( L"auto" );
}
else
{
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
}
}
else
{
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( color );
}
parent->RemoveChildByName( L"w:shd" );
parent->AppendChild( shd );
}

View File

@ -174,9 +174,9 @@ namespace DocFileFormat
//it's a Word 97 SPRM
short val = FormatUtils::BytesToInt16(bytes, 0, size);
icoFore = (val & 0x1F);
icoBack = ((val >> 5) & 0x1F);
ipat = (ShadingPattern) ((val >> 10) & 0x3F);
icoFore = GETBITS(val, 0, 4);
icoBack = GETBITS(val, 5, 9);
ipat = (ShadingPattern) GETBITS(val, 10, 15);
shadingType = shadingTypeShd80;
@ -209,7 +209,7 @@ namespace DocFileFormat
else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); }
else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); }
if (0x00 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); cvBackAuto = true; }
if (0x00 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); cvBackAuto = true; }
else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); }
else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); }
else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); }

View File

@ -41,7 +41,7 @@ namespace DocFileFormat
{
TC80()
{
horzMerge = wWidth = 0;
wWidth = horzMerge =0;
textFlow = Global::lrTb;
vertMerge = Global::fvmClear;
@ -95,13 +95,14 @@ namespace DocFileFormat
int pointer = 1;
// rgdxaCenter
for (int i = 0; i < numberOfColumns + 1; ++i)
{
rgdxaCenter.push_back(FormatUtils::BytesToInt16(bytes, pointer, size));
int pos = FormatUtils::BytesToInt16(bytes, pointer, size);
rgdxaCenter.push_back(pos);
pointer += 2;
}
// rgTc80
for (int i = 0; i < numberOfColumns; ++i)

View File

@ -81,7 +81,7 @@ namespace DocFileFormat
}
}
ByteStructure* operator [] ( unsigned int index ) const
ByteStructure* operator [] ( size_t index ) const
{
if ( index < this->Data.size() )
{

View File

@ -42,7 +42,6 @@ namespace DocFileFormat
{
}
~StructuredStorageReader()
{
if(m_pStorage)
@ -62,12 +61,18 @@ namespace DocFileFormat
}
return false;
}
bool GetStream (const char *path, POLE::Stream** ppStream)
bool isDirectory( const std::wstring& name )
{
if (( m_pStorage != NULL ) && ( path != NULL ))
if (!m_pStorage) return false;
return m_pStorage->isDirectory(name);
}
bool GetStream (const std::wstring & path, POLE::Stream** ppStream)
{
if (( m_pStorage != NULL ) && ( !path.empty() ))
{
*ppStream = new POLE::Stream(m_pStorage, path);
*ppStream = new POLE::Stream(m_pStorage, path.c_str());
}
if ((*ppStream) && ((*ppStream)->size() > 0))
return true;
@ -79,8 +84,78 @@ namespace DocFileFormat
{
return m_pStorage;
}
void copy( int indent, std::wstring path, POLE::Storage * storageOut, bool withRoot = true)
{
std::list<std::wstring> entries, entries_sort;
entries = m_pStorage->entries_with_prefix( path );
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
{
std::wstring name = *it;
std::wstring fullname = path + name;
if( m_pStorage->isDirectory( fullname ) )
{
entries_sort.push_back(name);
}
else
{
entries_sort.push_front(name);
}
}
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::wstring>::iterator it = entries_sort.begin(); it != entries_sort.end(); it++ )
{
std::wstring name = *it;
std::wstring fullname = path + name;
if( m_pStorage->isDirectory( fullname ) )
{
copy( indent + 1, fullname + L"/", storageOut, withRoot );
}
else
{
copy_stream(fullname, storageOut, withRoot);
}
}
}
private:
void copy_stream(std::wstring streamName, POLE::Storage * storageOut, bool withRoot = true)
{
POLE::Stream *stream = new POLE::Stream(m_pStorage, streamName);
if (!stream) return;
stream->seek(0);
POLE::int64 size_stream = stream->size();
if (withRoot == false)
{
int pos = (int)streamName.find(L"/");
if (pos >= 0)
streamName = streamName.substr(pos + 1);
}
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
if (!streamNew) return;
unsigned char* data_stream = new unsigned char[size_stream];
if (data_stream)
{
stream->read(data_stream, size_stream);
streamNew->write(data_stream, size_stream);
delete []data_stream;
data_stream = NULL;
}
streamNew->flush();
delete streamNew;
delete stream;
}
POLE::Storage* m_pStorage;
};

View File

@ -35,13 +35,13 @@
namespace DocFileFormat
{
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex) :
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex) :
PropertiesMapping(pWriter)
{
_width = 0;
_gridIndex = gridIndex;
_grid = tableGrid;
_grid = grid;
_cellIndex = cellIndex;
_brcTop = NULL;
@ -75,6 +75,8 @@ namespace DocFileFormat
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>(visited);
int nComputedCellWidth = 0;
_gridSpan = 1;
std::list<SinglePropertyModifier>::const_reverse_iterator rend = tapx->grpprl->rend();
for (std::list<SinglePropertyModifier>::const_reverse_iterator iter = tapx->grpprl->rbegin(); iter != rend; ++iter)
{
@ -87,7 +89,7 @@ namespace DocFileFormat
int cc = tdef.numberOfColumns;
_tGrid = tdef.rgdxaCenter;
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)]; // NOTE: fix for crash
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)];
appendValueElement( _tcPr, L"textDirection", FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ), false );
@ -111,13 +113,19 @@ namespace DocFileFormat
{
appendValueElement( _tcPr, L"noWrap", L"", true );
}
nComputedCellWidth = (short)( tdef.rgdxaCenter[(size_t)(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1) + 1] -
tdef.rgdxaCenter[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)] ); // NOTE: fix for crash
int ind = (std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1);
int ind1 = ind;
while (ind1 < tdef.rgdxaCenter.size() - 1)
{
int sz = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind1 ] ;
if (sz > 1)
break;
ind1++;
}
nComputedCellWidth = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind ] ;
if (!IsTableBordersDefined(tapx->grpprl))
{ //borders
{
RELEASEOBJECT(_brcTop);
_brcTop = new BorderCode(*_tcDef.brcTop);
@ -134,8 +142,7 @@ namespace DocFileFormat
break;
case sprmTCellPadding:
{ //margins
{
unsigned char first = iter->Arguments[0];
unsigned char lim = iter->Arguments[1];
unsigned char ftsMargin = iter->Arguments[3];
@ -165,7 +172,6 @@ namespace DocFileFormat
}
}
break;
case sprmTDefTableShd80:
{
if (!tapx->IsSkipShading97()) // если такой операнд единственный то учитываем его, иначе скипаем его
@ -270,24 +276,23 @@ namespace DocFileFormat
}
}
//width
XMLTools::XMLElement tcW ( L"w:tcW" );
XMLTools::XMLAttribute tcWType ( L"w:type", FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) );
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width ) );
XMLTools::XMLElement tcW ( L"w:tcW" );
tcW.AppendAttribute( tcWType );
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width > 1 ? _width : nComputedCellWidth) );
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) : L"dxa" );
tcW.AppendAttribute( tcWType );
tcW.AppendAttribute( tcWVal );
_tcPr->AppendChild( tcW );
//grid span
_gridSpan = 1;
if ( ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) )
{
//check the number of merged cells
int w = _grid->at( _gridIndex );
for ( unsigned int i = _gridIndex + 1; i < _grid->size(); i++ )
for ( size_t i = _gridIndex + 1; i < _grid->size(); i++ )
{
_gridSpan++;
@ -349,7 +354,7 @@ namespace DocFileFormat
void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex)
{
if (sprmArg)
if (sprmArg && cellIndex >= 0)
{
//shading descriptor can have 10 bytes (Word 2000) or 2 bytes (Word 97)
int shdLength = 2;

View File

@ -58,7 +58,7 @@ namespace DocFileFormat
public:
virtual ~TableCellPropertiesMapping();
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex);
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex);
virtual void Apply( IVisitable* visited );
inline int GetGridSpan() const
@ -71,9 +71,7 @@ namespace DocFileFormat
void apppendCellShading (unsigned char* sprmArg, int size, int cellIndex);
bool IsTableBordersDefined (const std::list<SinglePropertyModifier>* grpprl) const;
bool IsTableCellWidthDefined (const std::list<SinglePropertyModifier>* grpprl) const;
private:
int _gridIndex;
int _cellIndex;
@ -93,7 +91,6 @@ namespace DocFileFormat
BorderCode* _brcRight;
BorderCode* _brcBottom;
/// The grind span of this cell
int _gridSpan;
int _gridSpan;
};
}

View File

@ -106,7 +106,7 @@ namespace DocFileFormat
cellElements.clear();
}
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int nCellIndex)
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int nCellIndex)
{
if (NULL != mapping)
{
@ -116,14 +116,14 @@ namespace DocFileFormat
ParagraphPropertyExceptions* papxBackup = documentMapping->_lastValidPapx;
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
//start w:tc
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
//find cell end
//find cell end
int cpCellEnd = documentMapping->findCellEndCp(cp, depth);
//convert the properties
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, gridIndex, nCellIndex);
//start w:tc
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
//convert the properties
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, grid_write, gridIndex, nCellIndex);
if ( tapx != NULL )
{
@ -140,7 +140,7 @@ namespace DocFileFormat
(*iter)->Convert( mapping );
}
//end w:tc
//end w:tc
documentMapping->GetXMLWriter()->WriteNodeEnd( L"w:tc" );
}
@ -193,7 +193,7 @@ namespace DocFileFormat
cells.clear();
}
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid)
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write)
{
if ( mapping != NULL )
{
@ -234,7 +234,7 @@ namespace DocFileFormat
{
for ( std::list<TableCell>::iterator iter = cells.begin(); iter != cells.end(); iter++ )
{
iter->Convert( mapping, &tapx, grid, gridIndex, nCellIndex++ );
iter->Convert( mapping, &tapx, grid, grid_write, gridIndex, nCellIndex++);
}
}
@ -516,7 +516,8 @@ namespace DocFileFormat
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
//build the table grid
std::vector<short>* grid = documentMapping->buildTableGrid( cpStart, depth );
std::vector<short> grid, grid_write;
documentMapping->buildTableGrid( cpStart, depth, grid, grid_write );
//find first row end
int fcRowEnd = documentMapping->findRowEndFc( cpStart, depth );
@ -529,7 +530,7 @@ namespace DocFileFormat
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" );
//Convert it
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, grid );
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid, &grid_write );
row1Tapx.Convert( &tpMapping );
@ -538,13 +539,12 @@ namespace DocFileFormat
for ( std::list<TableRow>::iterator iter = rows.begin(); iter != rows.end(); iter++ )
{
iter->Convert( mapping, grid );
iter->Convert( mapping, &grid, &grid_write );
}
//close w:tbl
documentMapping->GetXMLWriter()->WriteNodeEnd( L"w:tbl" );
RELEASEOBJECT( grid );
}
}

View File

@ -58,7 +58,7 @@ namespace DocFileFormat
void AddItem( const ITableCellElement& _tableCellElement );
bool IsEmpty() const;
void Clear();
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int cellIndex );
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int cellIndex );
~TableCell();
private:
@ -81,7 +81,7 @@ namespace DocFileFormat
void AddCell( const TableCell& _tableCell );
bool IsEmpty() const;
void Clear();
void Convert( IMapping* mapping, const std::vector<short>* grid );
void Convert( IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write );
~TableRow();
private:

View File

@ -34,15 +34,13 @@
namespace DocFileFormat
{
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(NULL),
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(NULL),
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded ):
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid), _grid_write(grid_write),
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(styles),
_isTableStyleNeeded(isTableStyleNeeded)
{
_styles = styles;
_tblPr = new XMLTools::XMLElement( L"w:tblPr");
_tblBorders = new XMLTools::XMLElement( L"w:tblBorders");
_grid = grid;
}
TablePropertiesMapping::~TablePropertiesMapping()
{
@ -74,6 +72,9 @@ namespace DocFileFormat
short marginLeft = 0;
short marginRight = 0;
BYTE itcFirst = 0;
BYTE itcLim = 0;
for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ )
{
switch( iter->OpCode )
@ -120,7 +121,15 @@ namespace DocFileFormat
_tblPr->AppendChild( tblW );
}
break;
case sprmTMerge:
{
itcFirst = iter->Arguments[0];
itcLim = iter->Arguments[1];
}break;
case sprmTSplit:
{
}break;
case sprmOldTJc:
case sprmTJc:
case sprmTJcRow:
@ -144,7 +153,7 @@ namespace DocFileFormat
if ( _isTableStyleNeeded )
{
int ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
size_t ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
std::wstring id = ind < _styles->Styles->size() ? StyleSheetMapping::MakeStyleId( _styles->Styles->at( ind ) ) : L"";
@ -486,7 +495,7 @@ namespace DocFileFormat
bWriteGridCol = true;
else
{
for ( unsigned int i = 0, nSize = _grid->size(); i < nSize; i++ )
for ( size_t i = 0, nSize = _grid_write->size(); i < nSize; i++ )
{
if(_grid->at(i) % DocFileFormat::gc_nZeroWidth != 0)
{
@ -497,10 +506,10 @@ namespace DocFileFormat
}
if(true == bWriteGridCol)
{
for ( unsigned int i = 0; i < _grid->size(); i++ )
for ( size_t i = 0; i < _grid_write->size(); i++ )
{
XMLTools::XMLElement gridCol( L"w:gridCol");
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid->at( i ) ) );
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid_write->at( i ) ) );
gridCol.AppendAttribute( gridColW );
_tblGrid->AppendChild( gridCol );
}

View File

@ -71,7 +71,7 @@ namespace DocFileFormat
class TablePropertiesMapping: public PropertiesMapping, public IMapping
{
public:
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded = true );
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded = true );
virtual ~TablePropertiesMapping();
void Apply( IVisitable* visited );
@ -83,6 +83,7 @@ namespace DocFileFormat
StyleSheet* _styles;
std::vector<short>* _grid;
std::vector<short>* _grid_write;
BorderCode* brcLeft;
BorderCode* brcTop;

View File

@ -62,8 +62,9 @@ namespace DocFileFormat
for (std::list<SinglePropertyModifier>::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter)
{
if (oSpmIter->OpCode == sprmTDefTableShd || oSpmIter->OpCode == sprmTDefTableShd2nd ||
oSpmIter->OpCode == sprmTDefTableShd2nd || oSpmIter->OpCode == sprmTDefTableShd3rd)
if (oSpmIter->OpCode == sprmTDefTableShd ||
oSpmIter->OpCode == sprmTDefTableShd2nd ||
oSpmIter->OpCode == sprmTDefTableShd3rd)
{
m_bSkipShading97 = TRUE;
}

View File

@ -159,13 +159,13 @@ namespace DocFileFormat
OOX::CDocument docEmbedded(path, path);
bool res = false;
for (int i = 0 ; i < docEmbedded.m_arrItems.size(); i++)
for (size_t i = 0 ; i < docEmbedded.m_arrItems.size(); i++)
{
if (docEmbedded.m_arrItems[i]->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph *paragraph = dynamic_cast<OOX::Logic::CParagraph *>(docEmbedded.m_arrItems[i]);
for (int j = 0; (paragraph) && (j < paragraph->m_arrItems.size()); j++)
for (size_t j = 0; (paragraph) && (j < paragraph->m_arrItems.size()); j++)
{
if (paragraph->m_arrItems[j]->getType() == OOX::et_m_oMath)
{
@ -177,7 +177,7 @@ namespace DocFileFormat
{
OOX::Logic::COMathPara *mathPara = dynamic_cast<OOX::Logic::COMathPara *>(paragraph->m_arrItems[j]);
for (int k = 0; (mathPara) && (k < mathPara->m_arrItems.size()); k++)
for (size_t k = 0; (mathPara) && (k < mathPara->m_arrItems.size()); k++)
{
if (mathPara->m_arrItems[k]->getType() == OOX::et_m_oMath)
{

View File

@ -744,7 +744,7 @@ namespace DocFileFormat
text = FormatUtils::XmlEncode(text);
if (0 <= text.find(L"\n"))
if (std::wstring::npos != text.find(L"\n"))
{
m_textpath.AppendText(text);
}
@ -754,7 +754,7 @@ namespace DocFileFormat
case gtextFont:
{
std::wstring font = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex.get(), (iter->op)/2);
int i = font.size();
size_t i = font.size();
while (i > 0)
{
if (font[i-1] != 0) break;
@ -1905,13 +1905,13 @@ namespace DocFileFormat
switch (pSpa->wr)
{
case 0:
case 2: wrapType = L"square";
case 1: wrapType = L"topAndBottom";
case 3: wrapType = L"through";
case 2: wrapType = L"square"; break;
case 1: wrapType = L"topAndBottom"; break;
case 3: wrapType = L"through"; break;
case 4:
case 5: wrapType = L"tight";
case 5: wrapType = L"tight"; break;
default:
wrapType = L"none";
wrapType = L"none"; break;
}
}
@ -1963,7 +1963,7 @@ namespace DocFileFormat
{
int index = (DWORD)val - 0x80000000;
if (index >= 0 && index < m_arrGuides.size())
if (index >= 0 && index < (int)m_arrGuides.size())
{
new_val = m_arrGuides[index].param3;
}
@ -2087,6 +2087,7 @@ namespace DocFileFormat
nElemSize = 4;
bTruncated = true;
}
else nElemSize = 2;
long dwSize = nElems * nElemSize;
@ -2129,7 +2130,7 @@ namespace DocFileFormat
void VMLShapeMapping::ApplyPrimitives(DrawingPrimitives * primitives)
{
int index = 0;
size_t index = 0;
while(true)
{
@ -2141,7 +2142,7 @@ namespace DocFileFormat
static int currentTextBoxIndex = 1;
int VMLShapeMapping::ApplyPrimitive(DrawingPrimitives * primitives, int index)
size_t VMLShapeMapping::ApplyPrimitive(DrawingPrimitives * primitives, size_t index)
{
if (!primitives) return index++;
if (index >= primitives->size()) return index++;
@ -2164,7 +2165,7 @@ namespace DocFileFormat
//todooo нарисовать кастомный шейп
}
else
WritePrimitiveProps(primitive, (index==0?true:false));
WritePrimitiveProps(primitive, (index==0 ? true : false));
if (primitive->type == 0x0000)
@ -2240,11 +2241,11 @@ namespace DocFileFormat
{
//strStyle += L"left:" + FormatUtils::IntToWideString( x.ToPoints()) + L"pt;";
//strStyle += L"top:" + FormatUtils::IntToWideString( y.ToPoints()) + L"pt;";
strStyle += L"width:" + FormatUtils::IntToWideString( w.ToPoints()) + L"pt;";
strStyle += L"height:" + FormatUtils::IntToWideString( h.ToPoints()) + L"pt;";
strStyle += L"width:" + FormatUtils::IntToWideString( (int)w.ToPoints()) + L"pt;";
strStyle += L"height:" + FormatUtils::IntToWideString( (int)h.ToPoints()) + L"pt;";
strStyle += L"margin-left:" + FormatUtils::IntToWideString( x.ToPoints()) + L"pt;";
strStyle += L"margin-top:" + FormatUtils::IntToWideString( y.ToPoints()) + L"pt;";
strStyle += L"margin-left:" + FormatUtils::IntToWideString( (int)x.ToPoints()) + L"pt;";
strStyle += L"margin-top:" + FormatUtils::IntToWideString( (int)y.ToPoints()) + L"pt;";
std::wstring xMargin;
std::wstring yMargin;

View File

@ -73,7 +73,7 @@ namespace DocFileFormat
private:
void ApplyPrimitives (DrawingPrimitives * primitives );
int ApplyPrimitive (DrawingPrimitives * primitives, int index);
size_t ApplyPrimitive (DrawingPrimitives * primitives, size_t index);
void WritePrimitiveProps(DrawingPrimitive * primitive, bool root);

View File

@ -134,7 +134,7 @@ public:
if (position + count > stream->size())
{
if (position > stream->size()) count = 0;
else count = stream->size() - position;
else count = (unsigned int)(stream->size() - position);
}
rdBytes = new unsigned char[count];
}
@ -152,7 +152,7 @@ public:
virtual unsigned long GetPosition() const
{
return this->position;
return (unsigned long)this->position;
}
virtual unsigned long GetSize() const
@ -161,7 +161,7 @@ public:
if ( stream != NULL )
{
size = stream->size();
size = (unsigned long)stream->size();
}
return size;
@ -246,7 +246,7 @@ public:
/// The string must have the following structure:
/// unsigned char 1-4: Character count (cch)
/// unsigned char 5-cch+4: ANSI characters terminated by \0
std::wstring ReadLengthPrefixedAnsiString(int max_size)
std::wstring ReadLengthPrefixedAnsiString(unsigned int max_size)
{
std::wstring result;
@ -257,8 +257,8 @@ public:
if (cch > max_size)
{
//error ... skip to 0
int pos_orinal = GetPosition();
int pos = 0;
unsigned int pos_orinal = GetPosition();
unsigned int pos = 0;
stringBytes = ReadBytes( max_size, true );

View File

@ -52,7 +52,8 @@ namespace DocFileFormat
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),
AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL), encryptionHeader(NULL)
AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL),
AnnotStartPlex(NULL), AnnotEndPlex(NULL), encryptionHeader(NULL)
{
m_pCallFunc = pCallFunc;
m_sTempFolder = sTempFolder;
@ -94,7 +95,7 @@ namespace DocFileFormat
return AVS_ERROR_FILEFORMAT;
}
//-----------------------------------------------------------------------------------------------------------------
if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false)
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false)
{
Clear();
return AVS_ERROR_FILEFORMAT;
@ -120,16 +121,16 @@ namespace DocFileFormat
if (FIB->m_FibBase.fWhichTblStm)
{
if (!m_pStorage->GetStream ("1Table", &TableStream))
if (!m_pStorage->GetStream (L"1Table", &TableStream))
{
res = m_pStorage->GetStream ("0Table", &TableStream);
res = m_pStorage->GetStream (L"0Table", &TableStream);
}
}
else
{
if (!m_pStorage->GetStream ("0Table", &TableStream))
if (!m_pStorage->GetStream (L"0Table", &TableStream))
{
res = m_pStorage->GetStream ("1Table", &TableStream);
res = m_pStorage->GetStream (L"1Table", &TableStream);
}
}
@ -175,8 +176,8 @@ namespace DocFileFormat
POLE::Stream * Summary = NULL;
POLE::Stream * DocSummary = NULL;
m_pStorage->GetStream ("SummaryInformation", &Summary);
m_pStorage->GetStream ("DocumentSummaryInformation", &DocSummary);
m_pStorage->GetStream (L"SummaryInformation", &Summary);
m_pStorage->GetStream (L"DocumentSummaryInformation", &DocSummary);
document_code_page = ENCODING_WINDOWS_1250;
@ -205,7 +206,7 @@ namespace DocFileFormat
//-------------------------------------------------------------------------------------------------
try
{
m_pStorage->GetStream ("Data", &DataStream);
m_pStorage->GetStream (L"Data", &DataStream);
}
catch (...)
{
@ -215,7 +216,7 @@ namespace DocFileFormat
if (TableStream->size() < 1 && bOlderVersion)
{
RELEASEOBJECT(TableStream);
m_pStorage->GetStream ("WordDocument", &TableStream);
m_pStorage->GetStream (L"WordDocument", &TableStream);
}
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
@ -275,12 +276,17 @@ namespace DocFileFormat
TextboxIndividualPlex = new Plex<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
SectionPlex = new Plex<SectionDescriptor> (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, bOlderVersion);
BookmarkStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, bOlderVersion);
BookmarkEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkl, FIB->m_FibWord97.lcbPlcfBkl, bOlderVersion);
TextboxBreakPlex = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, bOlderVersion);
TextboxBreakPlexHeader = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, bOlderVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, bOlderVersion);
AnnotEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, bOlderVersion);
for (size_t i = 0; i < BookmarkStartPlex->Elements.size(); ++i)
{
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(BookmarkStartPlex->Elements[i]);
@ -289,7 +295,14 @@ 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)
{
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
if (pBookmark)
{
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[pBookmark->GetIndex()]));
}
}
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, bOlderVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, bOlderVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, bOlderVersion);
@ -470,26 +483,27 @@ namespace DocFileFormat
delete storageOut;
return false;
}
DecryptStream( 0, L"/", storageIn, storageOut, Decryptor);
std::list<std::string> listStream = storageIn->entries();
//std::list<std::string> listStream = storageIn->entries();
for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
{
if (storageIn->isDirectory(*it))
{
std::list<std::string> list_entry = storageIn->GetAllStreams(*it);
for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++)
{
DecryptStream(Decryptor, *it2, storageIn, storageOut);
}
}
else
{
DecryptStream(Decryptor, *it, storageIn, storageOut);
}
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
//{
// if (storageIn->isDirectory(*it))
// {
// std::list<std::string> list_entry = storageIn->GetAllStreams(*it);
//
// for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++)
// {
// DecryptStream(Decryptor, *it2, storageIn, storageOut);
// }
// }
// else
// {
// DecryptStream(Decryptor, *it, storageIn, storageOut);
// }
}
//}
storageOut->close();
delete storageOut;
@ -500,52 +514,60 @@ namespace DocFileFormat
m_pStorage->SetFile(m_sTempDecryptFileName.c_str());
if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false) return false;
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false) return false;
if (FIB->m_FibBase.fWhichTblStm)
{
if (!m_pStorage->GetStream ("1Table", &TableStream)) m_pStorage->GetStream ("0Table", &TableStream);
if (!m_pStorage->GetStream (L"1Table", &TableStream)) m_pStorage->GetStream (L"0Table", &TableStream);
}
else
{
if (!m_pStorage->GetStream ("0Table", &TableStream)) m_pStorage->GetStream ("1Table", &TableStream);
if (!m_pStorage->GetStream (L"0Table", &TableStream)) m_pStorage->GetStream (L"1Table", &TableStream);
}
return true;
}
bool WordDocument::CopyStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
void WordDocument::DecryptStream( int level, std::wstring path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
{
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
if (!stream) return false;
stream->seek(0);
int sz_stream = stream->size();
std::list<std::wstring> entries, entries_files, entries_dir;
entries = storageIn->entries_with_prefix( path );
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, sz_stream);
if (!streamNew) return false;
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
{
std::wstring name = *it;
std::wstring fullname = path + name;
if( storageIn->isDirectory( fullname ) )
{
entries_dir.push_back(name);
}
else
{
entries_files.push_front(name);
}
}
for( std::list<std::wstring>::iterator it = entries_dir.begin(); it != entries_dir.end(); ++it )
{
std::wstring fullname = path + *it;
DecryptStream( level + 1, fullname + L"/", storageIn, storageOut, Decryptor );
unsigned char* data_stream = new unsigned char[sz_stream];
stream->read(data_stream, sz_stream);
}
//if (bSortFiles)
entries_files.sort();
streamNew->write(data_stream, sz_stream);
RELEASEARRAYOBJECTS(data_stream);
streamNew->flush();
delete streamNew;
delete stream;
return true;
for( std::list<std::wstring>::iterator it = entries_files.begin(); it != entries_files.end(); ++it )
{
std::wstring fullname = path + *it;
DecryptStream(fullname, storageIn, storageOut, Decryptor );
}
}
bool WordDocument::DecryptStream(CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
bool WordDocument::DecryptStream(std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
{
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
if (!stream) return false;
stream->seek(0);
int size_stream = stream->size();
POLE::uint64 size_stream = stream->size();
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
if (!streamNew) return false;
@ -554,9 +576,9 @@ namespace DocFileFormat
stream->read(data_stream, size_stream);
unsigned char* data_store = NULL;
int size_data_store = 0;
int size_data_store = 0;
if ("WordDocument" == streamName)
if ( std::wstring::npos != streamName.find(L"WordDocument") )
{
size_data_store = 68;
data_store = new unsigned char[size_data_store];
@ -565,8 +587,10 @@ namespace DocFileFormat
if (data_store)
memcpy(data_store, data_stream, size_data_store);
int size_block = 0x200;
for (int pos = 0, block = 0 ; pos < size_stream; pos += size_block, block++)
size_t size_block = 0x200;
unsigned long block = 0;
for (POLE::uint64 pos = 0; pos < size_stream; pos += size_block, block++)
{
if (pos + size_block > size_stream)
size_block = size_stream - pos;
@ -659,6 +683,8 @@ namespace DocFileFormat
RELEASEOBJECT(SectionPlex);
RELEASEOBJECT(BookmarkStartPlex);
RELEASEOBJECT(BookmarkEndPlex);
RELEASEOBJECT(AnnotStartPlex);
RELEASEOBJECT(AnnotEndPlex);
RELEASEOBJECT(AutoTextPlex);
RELEASEOBJECT(ListPlex);
RELEASEOBJECT(Styles);

View File

@ -99,17 +99,17 @@ namespace DocFileFormat
bool bOlderVersion;
int document_code_page;
private:
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
bool DecryptStream (CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut);
bool CopyStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut);
inline StructuredStorageReader* GetStorage() const
{
return m_pStorage;
}
private:
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
bool DecryptStream (std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
void DecryptStream (int level, std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
inline OfficeArtContent* GetOfficeArt ()
{
return officeArtContent;
@ -162,7 +162,9 @@ namespace DocFileFormat
std::vector<int> * AllPapxVector;// A vector to quick find in AllPapx
std::map<int, int> PictureBulletsCPsMap;
std::vector<std::pair<int, int>> BookmarkStartEndCPs;
std::vector<std::pair<int, int>> AnnotStartEndCPs;
FileInformationBlock * FIB;
StyleSheet * Styles; // The style sheet of the document
@ -204,7 +206,10 @@ namespace DocFileFormat
Plex<SectionDescriptor> *SectionPlex; // A Plex containing all section descriptors
Plex<BookmarkFirst> *BookmarkStartPlex;
Plex<EmptyStructure> *BookmarkEndPlex;
Plex<EmptyStructure> *BookmarkEndPlex;
Plex<BookmarkFirst> *AnnotStartPlex;
Plex<EmptyStructure> *AnnotEndPlex;
Plex<ListNumCache> *ListPlex;
Plex<FieldCharacter> *FieldsPlex;

View File

@ -71,7 +71,7 @@ namespace ImageHelper
__BITMAPINFOHEADER * header = (__BITMAPINFOHEADER*)data;
if (!header) return result;
result == Global::msoblipDIB;
result = Global::msoblipDIB;
if (header->biWidth > 100000 || header->biHeight > 100000 || header->biSize != 40)
{
@ -180,10 +180,37 @@ namespace DocFileFormat
{
}
void WordprocessingDocument::SaveDocument()
void WordprocessingDocument::SaveDocument(bool &bMacros)
{
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ;
NSDirectory::CreateDirectory( pathWord );
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ;
NSDirectory::CreateDirectory( pathWord );
if (bMacros && docFile->GetStorage()->isDirectory(L"Macros"))
{
std::wstring sVbaProjectFile = pathWord + FILE_SEPARATOR_STR + L"vbaProject.bin";
POLE::Storage *storageVbaProject = new POLE::Storage(sVbaProjectFile.c_str());
if ((storageVbaProject) && (storageVbaProject->open(true, true)))
{
docFile->GetStorage()->copy(0, L"Macros/", storageVbaProject, false);
storageVbaProject->close();
delete storageVbaProject;
RegisterDocumentMacros();
RegisterVbaProject();
//output_document->get_xl_files().add_vba_project();
}
else bMacros = false;
}
else
bMacros = false;
if (!bMacros)
{
RegisterDocument();
}
WritePackage();

View File

@ -76,6 +76,7 @@ namespace DocFileFormat
public:
WordprocessingDocument(const std::wstring & _docxDirectory, const WordDocument* _docFile);
virtual ~WordprocessingDocument();
void SaveDocument();
void SaveDocument(bool &bMacros);
};
}

View File

@ -34,14 +34,14 @@
#include "../DocDocxConverter/Converter.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, ProgressCallback *ffCallBack )
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
{
HRESULT hr = S_FALSE;
DocFileFormat::Converter docToDocx;
docToDocx.m_sTempFolder = m_sTempFolder;
hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack);
hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack, bMacros);
return hr;
}

View File

@ -53,7 +53,7 @@ public:
std::wstring m_sTempFolder;
HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, ProgressCallback *ffCallBack = NULL);
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);
};

View File

@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_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"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -107,7 +107,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="C:\_WORK\trunk\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;_LIB;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
MinimalRebuild="true"
BasicRuntimeChecks="3"

View File

@ -2,34 +2,38 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocFormatLib", "..\DocFormatLib\Win32\DocFormatLib.vcproj", "{C5371405-338F-4B70-83BD-2A5CDF64F383}"
ProjectSection(ProjectDependencies) = postProject
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\..\DesktopEditor\graphics\graphics_vs2005.vcproj", "{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}"
ProjectSection(ProjectDependencies) = postProject
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeUtilsLib", "..\..\OfficeUtils\win32\OfficeUtilsLib.vcproj", "{F8274B05-168E-4D6E-B843-AA7510725363}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster", "..\..\DesktopEditor\raster\raster_vs2005.vcproj", "{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}"
ProjectSection(ProjectDependencies) = postProject
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "..\..\DesktopEditor\cximage\CxImage\cximage_vs2005.vcproj", "{BC52A07C-A797-423D-8C4F-8678805BBB36}"
ProjectSection(ProjectDependencies) = postProject
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
{818753F2-DBB9-4D3B-898A-A604309BE470} = {818753F2-DBB9-4D3B-898A-A604309BE470}
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jasper", "..\..\DesktopEditor\cximage\jasper\jasper_vs2005.vcproj", "{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}"
@ -54,17 +58,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XlsFormat", "..\..\ASCOffic
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocFormatTest", "DocFormatTest.vcproj", "{0F49D5D1-A8D3-4F97-8BC1-E2F65BB00C10}"
ProjectSection(ProjectDependencies) = postProject
{C5371405-338F-4B70-83BD-2A5CDF64F383} = {C5371405-338F-4B70-83BD-2A5CDF64F383}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{C5371405-338F-4B70-83BD-2A5CDF64F383} = {C5371405-338F-4B70-83BD-2A5CDF64F383}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\..\Common\DocxFormat\Projects\DocxFormat2005.vcproj", "{A100103A-353E-45E8-A9B8-90B87CC5C0B0}"

View File

@ -49,22 +49,32 @@
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
int _tmain(int argc, _TCHAR* argv[])
#pragma comment(lib, "Rpcrt4.lib")
HRESULT convert_single(std::wstring sSrcDoc)
{
if (argc < 2) return 1;
HRESULT hr = S_OK;
std::wstring sSrcDoc = argv[1];
std::wstring sDstDocx = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx";
std::wstring outputDir = NSDirectory::GetFolderPath(sDstDocx);
std::wstring outputDir = NSDirectory::GetFolderPath(sSrcDoc);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
COfficeDocFile docFile;
docFile.m_sTempFolder = outputDir;
HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", NULL);
bool bMacros = true;
HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", bMacros, NULL);
std::wstring sDstDocx;
if (bMacros)
{
sDstDocx = sSrcDoc + L"-my.docm";
}
else
{
sDstDocx = sSrcDoc + L"-my.docx";
}
if (hRes == S_OK)
{
COfficeUtils oCOfficeUtils(NULL);
@ -76,3 +86,33 @@ int _tmain(int argc, _TCHAR* argv[])
return hRes;
}
HRESULT convert_directory(std::wstring pathName)
{
HRESULT hr = S_OK;
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
for (size_t i = 0; i < arFiles.size(); i++)
{
convert_single(arFiles[i]);
}
return S_OK;
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
HRESULT hr = -1;
if (NSFile::CFileBinary::Exists(argv[1]))
{
hr = convert_single(argv[1]);
}
else if (NSDirectory::Exists(argv[1]))
{
hr = convert_directory(argv[1]);
}
return hr;
}

View File

@ -44,7 +44,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\..\Common\OfficeDrawing;&quot;..\..\..\..\..\DesktopEditor\freetype-2.5.2\include&quot;;..\..\..\..\..\Common\OfficeDrawing\Shapes"
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="false"
BasicRuntimeChecks="3"

View File

@ -40,11 +40,11 @@ namespace Writers
class DocumentWriter : public ContentWriter
{
XmlUtils::CStringWriter m_oWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
public:
std::wstring m_sDir;
public:
DocumentWriter( std::wstring sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir), m_oHeaderFooterWriter(oHeaderFooterWriter)
std::wstring m_sDir;
DocumentWriter( std::wstring sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir), m_oHeaderFooterWriter(oHeaderFooterWriter)
{
}
void Write()
@ -54,7 +54,24 @@ namespace Writers
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8( std::wstring(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
oFile.WriteStringUTF8( std::wstring(_T("<w:document 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\">")));
oFile.WriteStringUTF8( std::wstring(_T("<w:document \
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: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\">")));
oFile.WriteStringUTF8(m_oBackground.GetData());

View File

@ -31,7 +31,9 @@
*/
#ifndef FILE_WRITER
#define FILE_WRITER
#include "../../DesktopEditor/common/Path.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "NumberingWriter.h"
#include "fontTableWriter.h"
@ -75,6 +77,8 @@ namespace Writers
DocumentRelsWriter m_oDocumentRelsWriter;
WebSettingsWriter m_oWebSettingsWriter;
DefaultThemeWriter m_oTheme;
smart_ptr<OOX::VbaProject> m_pVbaProject;
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
bool m_bSaveChartAsImg;

View File

@ -60,16 +60,50 @@ namespace Writers
std::wstring rId;
SimpleTypes::EHdrFtr eType;
};
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:hdr 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_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<w:hdr 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:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 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\"?><w:ftr 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_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<w:ftr 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:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 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\" 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: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_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\" 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: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_End = _T("</w:endnotes>");
class HeaderFooterWriter

View File

@ -355,10 +355,13 @@ class Tab
public:
BYTE Val;
double Pos;
BYTE Leader;
bool bLeader;
Tab()
{
Val = shd_Nil;
Pos = 0;
bLeader = false;
}
};
class Tabs
@ -1583,6 +1586,7 @@ public:
std::wstring UserName;
std::wstring UserId;
std::wstring Date;
std::wstring OOData;
bool Solved;
std::wstring Text;
std::wstring m_sParaId;
@ -1696,7 +1700,7 @@ public:
std::vector<std::wstring> arSplit;
boost::algorithm::split(arSplit, pComment->UserName, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
for (int i = 0; i < arSplit.size(); i++)
for (size_t i = 0; i < arSplit.size(); i++)
{
sInitials += arSplit[i][0];
}
@ -1706,9 +1710,16 @@ public:
{
std::wstring sDate = XmlUtils::EncodeXmlString(pComment->Date);
sRes += L" w:date=\"";
sRes += sDate;
sRes += sDate;
sRes += L"\"";
}
if(false == pComment->OOData.empty())
{
std::wstring sData = XmlUtils::EncodeXmlString(pComment->OOData);
sRes += L" oodata=\"";
sRes += sData;
sRes += L"\"";
}
if(false == sInitials.empty())
{
sInitials = XmlUtils::EncodeXmlString(sInitials);
@ -1725,7 +1736,7 @@ public:
bool bFirst = true;
int nPrevIndex = 0;
for(size_t i = 0; i < sText.length(); i++)
for (int i = 0; i < (int)sText.length(); i++)
{
wchar_t cToken = sText[i];
if('\n' == cToken)
@ -2329,7 +2340,7 @@ public:
{
return Jc.empty() && TableInd.empty() && TableW.empty() && TableCellMar.empty() && TableBorders.empty() && Shd.empty() && tblpPr.empty()&& Style.empty() && Look.empty() && tblPrChange.empty() && TableCellSpacing.empty() && RowBandSize.empty() && ColBandSize.empty();
}
std::wstring Write(bool bBandSize, bool bLayout)
std::wstring Write()
{
std::wstring sRes;
sRes += L"<w:tblPr>";
@ -2353,13 +2364,8 @@ public:
sRes += (TableBorders);
if(false == Shd.empty())
sRes += (Shd);
if(bLayout)
{
if(false == Layout.empty())
sRes += (Layout);
else if(g_nCurFormatVersion < 4)
sRes += L"<w:tblLayout w:type=\"fixed\"/>";
}
if(false == Layout.empty())
sRes += (Layout);
if(false == TableCellMar.empty())
sRes += (TableCellMar);
if(false == Look.empty())
@ -2747,7 +2753,7 @@ public:
}
if(NULL != tblPr)
{
pCStringWriter->WriteString(tblPr->Write(false, true));
pCStringWriter->WriteString(tblPr->Write());
}
if(NULL != tblGridChange)
{

View File

@ -34,6 +34,14 @@
namespace BinDocxRW {
int Binary_VbaProjectTableReader::Read()
{
m_oFileWriter.m_pVbaProject = new OOX::VbaProject();
m_oFileWriter.m_pVbaProject->fromPPTY(&m_oBufferedStream);
return c_oSerConstants::ReadOk;
}
//-------------------------------------------------------------------------------------
Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, CComments* pComments):Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter),m_oHeaderFooterWriter(oFileWriter.m_oHeaderFooterWriter),m_pComments(pComments)
{
}
@ -93,9 +101,9 @@ int Binary_HdrFtrTableReader::ReadHdrFtrItem(BYTE type, long length, void* poRes
Binary_DocumentTableReader oBinary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, poHdrFtrItem->Header, m_pComments);
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrItemContent, this, &oBinary_DocumentTableReader);
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") +
FILE_SEPARATOR_STR + _T("_rels")+
FILE_SEPARATOR_STR + poHdrFtrItem->m_sFilename + _T(".rels");
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word" +
FILE_SEPARATOR_STR + L"_rels"+
FILE_SEPARATOR_STR + poHdrFtrItem->m_sFilename + L".rels";
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(fileRelsPath.GetPath());
}

View File

@ -273,6 +273,20 @@ private:
return res;
}
};
class Binary_VbaProjectTableReader : public Binary_CommonReader<Binary_VbaProjectTableReader>
{
Writers::FileWriter& m_oFileWriter;
public:
Binary_VbaProjectTableReader (NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter)
: Binary_CommonReader(poBufferedStream), m_oFileWriter(oFileWriter)
{
}
int Read ();
};
class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableReader>
{
Writers::FileWriter& m_oFileWriter;
@ -282,12 +296,12 @@ class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableRe
int nCurHeaderType;
public:
Writers::HeaderFooterWriter& m_oHeaderFooterWriter;
public:
Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, CComments* pComments);
int Read();
int ReadHdrFtrContent(BYTE type, long length, void* poResult);
int ReadHdrFtrFEO(BYTE type, long length, void* poResult);
int ReadHdrFtrItem(BYTE type, long length, void* poResult);
int ReadHdrFtrContent (BYTE type, long length, void* poResult);
int ReadHdrFtrFEO (BYTE type, long length, void* poResult);
int ReadHdrFtrItem (BYTE type, long length, void* poResult);
int ReadHdrFtrItemContent(BYTE type, long length, void* poResult);
};
class Binary_rPrReader : public Binary_CommonReader<Binary_rPrReader>
@ -551,7 +565,7 @@ public:
std::wstring strXml;
HRESULT hRes = m_oFileWriter.m_pDrawingConverter->GetRecordXml(nCurPos, length, XMLWRITER_RECORD_TYPE_TEXT_FILL, XMLWRITER_DOC_TYPE_WORDART, strXml);
if (S_OK == hRes)
orPr->Fill = _T("<w14:textFill>") + strXml + _T("</w14:textFill>");
orPr->Fill = L"<w14:textFill>" + strXml + L"</w14:textFill>";
m_oBufferedStream.Seek(nCurPos + length);
}
}
@ -560,35 +574,35 @@ public:
{
TrackRevision oDel;
oBinary_CommonReader2.ReadTrackRevision(length, &oDel);
orPr->Del = oDel.ToString(_T("w:del"));
orPr->Del = oDel.ToString(L"w:del");
}
break;
case c_oSerProp_rPrType::Ins:
{
TrackRevision oIns;
oBinary_CommonReader2.ReadTrackRevision(length, &oIns);
orPr->Ins = oIns.ToString(_T("w:ins"));
orPr->Ins = oIns.ToString(L"w:ins");
}
break;
case c_oSerProp_rPrType::MoveFrom:
{
TrackRevision oMoveFrom;
oBinary_CommonReader2.ReadTrackRevision(length, &oMoveFrom);
orPr->MoveFrom = oMoveFrom.ToString(_T("w:moveFrom"));
orPr->MoveFrom = oMoveFrom.ToString(L"w:moveFrom");
}
break;
case c_oSerProp_rPrType::MoveTo:
{
TrackRevision oMoveTo;
oBinary_CommonReader2.ReadTrackRevision(length, &oMoveTo);
orPr->MoveTo = oMoveTo.ToString(_T("w:moveTo"));
orPr->MoveTo = oMoveTo.ToString(L"w:moveTo");
}
break;
case c_oSerProp_rPrType::rPrChange:
{
TrackRevision oRPrChange;
res = Read1(length, &Binary_rPrReader::ReadrPrChange, this, &oRPrChange);
orPr->rPrChange = oRPrChange.ToString(_T("w:rPrChange"));
orPr->rPrChange = oRPrChange.ToString(L"w:rPrChange");
}
break;
default:
@ -647,9 +661,9 @@ public:
{
BYTE contextualSpacing = m_oBufferedStream.GetUChar();
if(0 != contextualSpacing)
pCStringWriter->WriteString(std::wstring(_T("<w:contextualSpacing w:val=\"true\"/>")));
pCStringWriter->WriteString(std::wstring(L"<w:contextualSpacing w:val=\"true\"/>"));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(std::wstring(_T("<w:contextualSpacing w:val=\"false\"/>")));
pCStringWriter->WriteString(std::wstring(L"<w:contextualSpacing w:val=\"false\"/>"));
}break;
case c_oSerProp_pPrType::Ind:
{
@ -657,9 +671,9 @@ public:
res = Read2(length, &Binary_pPrReader::ReadInd, this, &oTempWriter);
if(oTempWriter.GetCurSize() > 0)
{
pCStringWriter->WriteString(std::wstring(_T("<w:ind")));
pCStringWriter->WriteString(std::wstring(L"<w:ind"));
pCStringWriter->Write(oTempWriter);
pCStringWriter->WriteString(std::wstring(_T("/>")));
pCStringWriter->WriteString(std::wstring(L"/>"));
}
break;
}
@ -668,35 +682,35 @@ public:
BYTE jc = m_oBufferedStream.GetUChar();
switch(jc)
{
case align_Right: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"right\" />")));break;
case align_Left: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"left\" />")));break;
case align_Center: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"center\" />")));break;
case align_Justify: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"both\" />")));break;
case align_Right: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"right\" />"));break;
case align_Left: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"left\" />"));break;
case align_Center: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"center\" />"));break;
case align_Justify: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"both\" />"));break;
}
}break;
case c_oSerProp_pPrType::KeepLines:
{
BYTE KeepLines = m_oBufferedStream.GetUChar();
if(0 != KeepLines)
pCStringWriter->WriteString(std::wstring(_T("<w:keepLines/>")));
pCStringWriter->WriteString(std::wstring(L"<w:keepLines/>"));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(std::wstring(_T("<w:keepLines w:val=\"false\"/>")));
pCStringWriter->WriteString(std::wstring(L"<w:keepLines w:val=\"false\"/>"));
}break;
case c_oSerProp_pPrType::KeepNext:
{
BYTE KeepNext = m_oBufferedStream.GetUChar();
if(0 != KeepNext)
pCStringWriter->WriteString(std::wstring(_T("<w:keepNext/>")));
pCStringWriter->WriteString(std::wstring(L"<w:keepNext/>"));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(std::wstring(_T("<w:keepNext w:val=\"false\"/>")));
pCStringWriter->WriteString(std::wstring(L"<w:keepNext w:val=\"false\"/>"));
}break;
case c_oSerProp_pPrType::PageBreakBefore:
{
BYTE pageBreakBefore = m_oBufferedStream.GetUChar();
if(0 != pageBreakBefore)
pCStringWriter->WriteString(std::wstring(_T("<w:pageBreakBefore/>")));
pCStringWriter->WriteString(std::wstring(L"<w:pageBreakBefore/>"));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(std::wstring(_T("<w:pageBreakBefore w:val=\"false\"/>")));
pCStringWriter->WriteString(std::wstring(L"<w:pageBreakBefore w:val=\"false\"/>"));
break;
}
case c_oSerProp_pPrType::Spacing:
@ -705,7 +719,7 @@ public:
res = Read2(length, &Binary_pPrReader::ReadSpacing, this, &oSpacing);
if(oSpacing.bLine || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
{
pCStringWriter->WriteString(std::wstring(_T("<w:spacing")));
pCStringWriter->WriteString(std::wstring(L"<w:spacing"));
BYTE bLineRule = linerule_Auto;
//проверяется bLine, а не bLineRule чтобы всегда писать LineRule, если есть w:line
if(oSpacing.bLine)
@ -745,9 +759,9 @@ public:
if(oSpacing.bAfterAuto)
{
if(true == oSpacing.AfterAuto)
pCStringWriter->WriteString(std::wstring(_T(" w:afterAutospacing=\"1\"")));
pCStringWriter->WriteString(std::wstring(L" w:afterAutospacing=\"1\""));
else
pCStringWriter->WriteString(std::wstring(_T(" w:afterAutospacing=\"0\"")));
pCStringWriter->WriteString(std::wstring(L" w:afterAutospacing=\"0\""));
}
if(oSpacing.bBefore)
{
@ -758,11 +772,11 @@ public:
if(oSpacing.bBeforeAuto)
{
if(true == oSpacing.BeforeAuto)
pCStringWriter->WriteString(std::wstring(_T(" w:beforeAutospacing=\"1\"")));
pCStringWriter->WriteString(std::wstring(L" w:beforeAutospacing=\"1\""));
else
pCStringWriter->WriteString(std::wstring(_T(" w:beforeAutospacing=\"0\"")));
pCStringWriter->WriteString(std::wstring(L" w:beforeAutospacing=\"0\""));
}
pCStringWriter->WriteString(std::wstring(_T("/>")));
pCStringWriter->WriteString(std::wstring(L"/>"));
}
break;
}
@ -776,7 +790,7 @@ public:
}
else
{
std::wstring sShd(_T("<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>"));
std::wstring sShd(L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>");
pCStringWriter->WriteString(sShd);
}
break;
@ -787,10 +801,10 @@ public:
if(0 != WidowControl)
{
if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(std::wstring(_T("<w:widowControl/>")));
pCStringWriter->WriteString(std::wstring(L"<w:widowControl/>"));
}
else
pCStringWriter->WriteString(std::wstring(_T("<w:widowControl w:val=\"off\" />")));
pCStringWriter->WriteString(std::wstring(L"<w:widowControl w:val=\"off\" />"));
break;
}
case c_oSerProp_pPrType::Tab:
@ -800,7 +814,7 @@ public:
size_t nLen = oTabs.m_aTabs.size();
if(nLen > 0)
{
pCStringWriter->WriteString(std::wstring(_T("<w:tabs>")));
pCStringWriter->WriteString(std::wstring(L"<w:tabs>"));
for(size_t i = 0; i < nLen; ++i)
{
Tab& oTab = oTabs.m_aTabs[i];
@ -808,14 +822,30 @@ public:
std::wstring sVal;
switch(oTab.Val)
{
case g_tabtype_right: sVal=_T("right"); break;
case g_tabtype_center: sVal=_T("center"); break;
case g_tabtype_clear: sVal=_T("clear"); break;
default: sVal=_T("left"); break;
case g_tabtype_right: sVal = L"right"; break;
case g_tabtype_center: sVal = L"center"; break;
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(nTab) + L"\"");
if (oTab.bLeader)
{
std::wstring sLeader;
switch(oTab.Leader)
{
case SimpleTypes::tabtlcDot : sLeader = (L"dot");break;
case SimpleTypes::tabtlcHeavy : sLeader = (L"heavy");break;
case SimpleTypes::tabtlcHyphen : sLeader = (L"hyphen");break;
case SimpleTypes::tabtlcMiddleDot : sLeader = (L"middleDot");break;
case SimpleTypes::tabtlcNone : sLeader = (L"none");break;
case SimpleTypes::tabtlcUnderscore : sLeader = (L"underscore");break;
default : sLeader = (L"none");break;
}
pCStringWriter->WriteString(L" w:leader=\"" + sLeader + L"\"");
}
pCStringWriter->WriteString(L"/>");
}
pCStringWriter->WriteString(std::wstring(_T("</w:tabs>")));
pCStringWriter->WriteString(std::wstring(L"</w:tabs>"));
}
}break;
case c_oSerProp_pPrType::ParaStyle:
@ -826,9 +856,9 @@ public:
}break;
case c_oSerProp_pPrType::numPr:
{
pCStringWriter->WriteString(std::wstring(_T("<w:numPr>")));
pCStringWriter->WriteString(std::wstring(L"<w:numPr>"));
res = Read2(length, &Binary_pPrReader::ReadNumPr, this, poResult);
pCStringWriter->WriteString(std::wstring(_T("</w:numPr>")));
pCStringWriter->WriteString(std::wstring(L"</w:numPr>"));
}break;
case c_oSerProp_pPrType::pPr_rPr:
{
@ -871,6 +901,11 @@ public:
pCStringWriter->WriteString(oSectPr.Write());
pCStringWriter->WriteString(std::wstring(_T("</w:sectPr>")));
}break;
case c_oSerProp_pPrType::outlineLvl:
{
long outlineLvl = m_oBufferedStream.GetLong();
pCStringWriter->WriteString(L"<w:outlineLvl w:val=\"" + std::to_wstring(outlineLvl) + L"\"/>");
}break;
default:
res = c_oSerConstants::ReadUnknown;
break;
@ -989,6 +1024,11 @@ public:
poTabItem->Val = m_oBufferedStream.GetUChar();
else if(c_oSerProp_pPrType::Tab_Item_Pos == type)
poTabItem->Pos = m_oBufferedStream.GetDouble();
else if(c_oSerProp_pPrType::Tab_Item_Leader == type)
{
poTabItem->bLeader = true;
poTabItem->Leader = m_oBufferedStream.GetUChar();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -2786,7 +2826,7 @@ public:
{
CWiterTblPr oWiterTblPr;
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
odocStyle->TablePr = oWiterTblPr.Write(true, false);
odocStyle->TablePr = oWiterTblPr.Write();
}
else if(c_oSer_sts::Style_RowPr == type)
{
@ -2882,7 +2922,7 @@ public:
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
if(false == oWiterTblPr.IsEmpty())
ptblStylePr->Writer.WriteString(oWiterTblPr.Write(false, false));
ptblStylePr->Writer.WriteString(oWiterTblPr.Write());
}
else if(c_oSerProp_tblStylePrType::TrPr == type)
{
@ -2917,7 +2957,8 @@ class Binary_OtherTableReader : public Binary_CommonReader<Binary_OtherTableRead
Writers::FileWriter& m_oFileWriter;
std::wstring m_sFileInDir;
public:
Binary_OtherTableReader(std::wstring sFileInDir, NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter):m_sFileInDir(sFileInDir),Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter)
Binary_OtherTableReader(std::wstring sFileInDir, NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter)
: m_sFileInDir(sFileInDir), Binary_CommonReader(poBufferedStream), m_oFileWriter(oFileWriter)
{
}
int Read()
@ -3039,6 +3080,11 @@ public:
std::wstring Date(m_oBufferedStream.GetString3(length));
pComment->Date = Date;
}
else if ( c_oSer_CommentsType::OOData == type )
{
std::wstring Data(m_oBufferedStream.GetString3(length));
pComment->OOData = Data;
}
else if ( c_oSer_CommentsType::Text == type )
{
std::wstring Text(m_oBufferedStream.GetString3(length));
@ -3688,6 +3734,18 @@ public:
res = Read2(length, &Binary_DocumentTableReader::Read_Background, this, &oBackground);
m_oDocumentWriter.m_oBackground.WriteString(oBackground.Write());
}
else if ( c_oSerParType::BookmarkStart == type )
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
}
else if ( c_oSerParType::BookmarkEnd == type )
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3826,6 +3884,18 @@ public:
SdtWraper oSdt(1);
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
}
else if ( c_oSerParType::BookmarkStart == type )
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
}
else if ( c_oSerParType::BookmarkEnd == type )
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3983,6 +4053,19 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFldChar(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFldChar* pFldChar = static_cast<OOX::Logic::CFldChar*>(poResult);
if ( c_oSer_FldSimpleType::CharType == type )
{
pFldChar->m_oFldCharType.Init();
pFldChar->m_oFldCharType->SetValue((SimpleTypes::EFldCharType)m_oBufferedStream.GetUChar());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFldSimple(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -4208,6 +4291,57 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadBookmarkStart(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(poResult);
if ( c_oSerBookmark::Id == type )
{
pBookmarkStart->m_oId.Init();
pBookmarkStart->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerBookmark::Name == type )
{
pBookmarkStart->m_sName.Init();
pBookmarkStart->m_sName->append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
{
pBookmarkStart->m_oDisplacedByCustomXml.Init();
pBookmarkStart->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else if ( c_oSerBookmark::ColFirst == type )
{
pBookmarkStart->m_oColFirst.Init();
pBookmarkStart->m_oColFirst->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerBookmark::ColLast == type )
{
pBookmarkStart->m_oColLast.Init();
pBookmarkStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadBookmarkEnd(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(poResult);
if ( c_oSerBookmark::Id == type )
{
pBookmarkEnd->m_oId.Init();
pBookmarkEnd->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
{
pBookmarkEnd->m_oDisplacedByCustomXml.Init();
pBookmarkEnd->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadHyperlink(BYTE type, long length, void* poResult)
{
@ -4401,6 +4535,18 @@ public:
res = Read1(length, &Binary_DocumentTableReader::ReadMathSSup, this, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:sSup>")));
}
else if ( c_oSer_OMathContentType::BookmarkStart == type )
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
GetRunStringWriter().WriteString(oBookmarkStart.toXML());
}
else if ( c_oSer_OMathContentType::BookmarkEnd == type )
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
GetRunStringWriter().WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -6609,7 +6755,7 @@ public:
//сбрасываем Shd
oBinary_tblPrReader.m_sCurTableShd.clear();
}
else if(c_oSerRunType::fldstart == type)
else if(c_oSerRunType::fldstart_deprecated == type)
{
std::wstring sField(m_oBufferedStream.GetString3(length));
sField = XmlUtils::EncodeXmlString(sField);
@ -6623,7 +6769,7 @@ public:
m_oCur_rPr.Write(&GetRunStringWriter());
GetRunStringWriter().WriteString(std::wstring(_T("<w:fldChar w:fldCharType=\"separate\"/>")));
}
else if(c_oSerRunType::fldend == type)
else if(c_oSerRunType::fldend_deprecated == type)
{
GetRunStringWriter().WriteString(std::wstring(_T("<w:fldChar w:fldCharType=\"end\"/>")));
}
@ -6672,6 +6818,28 @@ public:
res = Read1(length, &Binary_DocumentTableReader::ReadEndnoteRef, this, &oEndnoteRef);
GetRunStringWriter().WriteString(oEndnoteRef.toXML());
}
else if ( c_oSerRunType::fldChar == type)
{
OOX::Logic::CFldChar oFldChar;
res = Read1(length, &Binary_DocumentTableReader::ReadFldChar, this, &oFldChar);
GetRunStringWriter().WriteString(oFldChar.toXML());
}
else if ( c_oSerRunType::instrText == type)
{
GetRunStringWriter().WriteString(std::wstring(_T("<w:instrText xml:space=\"preserve\">")));
std::wstring sText(m_oBufferedStream.GetString3(length));
sText = XmlUtils::EncodeXmlString(sText);
GetRunStringWriter().WriteString(sText);
GetRunStringWriter().WriteString(std::wstring(_T("</w:instrText>")));
}
else if ( c_oSerRunType::delInstrText == type)
{
GetRunStringWriter().WriteString(std::wstring(_T("<w:delInstrText xml:space=\"preserve\">")));
std::wstring sText(m_oBufferedStream.GetString3(length));
sText = XmlUtils::EncodeXmlString(sText);
GetRunStringWriter().WriteString(sText);
GetRunStringWriter().WriteString(std::wstring(_T("</w:delInstrText>")));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -6770,7 +6938,7 @@ public:
{
CWiterTblPr oWiterTblPr;
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
pCStringWriter->WriteString(oWiterTblPr.Write(false, true));
pCStringWriter->WriteString(oWiterTblPr.Write());
}
else if( c_oSerDocTableType::tblGrid == type )
{
@ -6842,6 +7010,18 @@ public:
SdtWraper oSdt(2);
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
}
else if (c_oSerDocTableType::BookmarkStart == type)
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
pCStringWriter->WriteString(oBookmarkStart.toXML());
}
else if (c_oSerDocTableType::BookmarkEnd == type)
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
pCStringWriter->WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -6879,6 +7059,18 @@ public:
SdtWraper oSdt(3);
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
}
else if (c_oSerDocTableType::BookmarkStart == type)
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
pCStringWriter->WriteString(oBookmarkStart.toXML());
}
else if (c_oSerDocTableType::BookmarkEnd == type)
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
pCStringWriter->WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -7017,13 +7209,13 @@ public:
{
if(false == m_oFileWriter.m_bSaveChartAsImg)
{
OOX::CPath pathChartsDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR +_T("charts");
OOX::CPath pathChartsDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"charts";
OOX::CSystemUtility::CreateDirectories(pathChartsDir.GetPath());
OOX::CPath pathChartsRelsDir = pathChartsDir.GetPath() + FILE_SEPARATOR_STR + _T("_rels");
OOX::CPath pathChartsRelsDir = pathChartsDir.GetPath() + FILE_SEPARATOR_STR + L"_rels";
OOX::CSystemUtility::CreateDirectories(pathChartsRelsDir.GetPath());
OOX::CPath pathChartsWorksheetDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR +_T("embeddings");
OOX::CPath pathChartsWorksheetDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"embeddings";
OOX::CSystemUtility::CreateDirectories(pathChartsWorksheetDir.GetPath());
int nativeDocumentType = m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_nDocumentType;
@ -7044,21 +7236,22 @@ public:
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(nChartIndex) + L".xlsx";
std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename;
BinXlsxRW::CXlsxSerializer oXlsxSerializer;
oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace);
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
{
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
//save chart.xml
NSStringUtils::CStringBuilder sw;
@ -7917,9 +8110,9 @@ public:
int res = ReadTable(&Binary_NotesTableReader::ReadNotes, this, &oBinary_DocumentTableReader);
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") +
FILE_SEPARATOR_STR + _T("_rels")+
FILE_SEPARATOR_STR + sFilename + _T(".rels");
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word" +
FILE_SEPARATOR_STR + L"_rels"+
FILE_SEPARATOR_STR + sFilename + L".rels";
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(fileRelsPath.GetPath());
return res;
@ -7956,33 +8149,33 @@ public:
XmlUtils::CStringWriter& writer = pBinary_DocumentTableReader->m_oDocumentWriter.m_oContent;
if(m_bIsFootnote)
{
writer.WriteString(_T("<w:footnote"));
writer.WriteString(L"<w:footnote");
}
else
{
writer.WriteString(_T("<w:endnote"));
writer.WriteString(L"<w:endnote");
}
if(m_oType.IsInit())
{
writer.WriteString(_T(" w:type=\""));
writer.WriteString(L" w:type=\"");
writer.WriteString(m_oType->ToString());
writer.WriteString(_T("\""));
writer.WriteString(L"\"");
}
if(m_oId.IsInit())
{
writer.WriteString(_T(" w:id=\""));
writer.WriteString(L" w:id=\"");
writer.WriteString(m_oId->ToString());
writer.WriteString(_T("\""));
writer.WriteString(L"\"");
}
writer.WriteString(_T(">"));
writer.WriteString(L">");
res = Read1(length, &Binary_NotesTableReader::ReadNoteContent, this, poResult);
if(m_bIsFootnote)
{
writer.WriteString(_T("</w:footnote>"));
writer.WriteString(L"</w:footnote>");
}
else
{
writer.WriteString(_T("</w:endnote>"));
writer.WriteString(L"</w:endnote>");
}
}
else
@ -8082,8 +8275,8 @@ public:
}
else
{
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<w:defaultTabStop w:val=\"708\"/>"));
std::wstring sClrMap(_T("<w:clrSchemeMapping w:bg1=\"light1\" w:t1=\"dark1\" w:bg2=\"light2\" w:t2=\"dark2\" w:accent1=\"accent1\" w:accent2=\"accent2\" w:accent3=\"accent3\" w:accent4=\"accent4\" w:accent5=\"accent5\" w:accent6=\"accent6\" w:hyperlink=\"hyperlink\" w:followedHyperlink=\"followedHyperlink\"/>"));
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"708\"/>");
std::wstring sClrMap(L"<w:clrSchemeMapping w:bg1=\"light1\" w:t1=\"dark1\" w:bg2=\"light2\" w:t2=\"dark2\" w:accent1=\"accent1\" w:accent2=\"accent2\" w:accent3=\"accent3\" w:accent4=\"accent4\" w:accent5=\"accent5\" w:accent6=\"accent6\" w:hyperlink=\"hyperlink\" w:followedHyperlink=\"followedHyperlink\"/>");
m_oFileWriter.m_oSettingWriter.AddSetting(sClrMap);
m_oFileWriter.m_pDrawingConverter->LoadClrMap(sClrMap);
}
@ -8135,9 +8328,12 @@ public:
case c_oSerTableTypes::Endnotes:
res = Binary_NotesTableReader(m_oBufferedStream, m_oFileWriter, m_oFileWriter.m_pComments, false).Read();
break;
case c_oSerTableTypes::VbaProject:
res = Binary_VbaProjectTableReader(m_oBufferedStream, m_oFileWriter).Read();
break;
//Comments должны читаться раньше чем c_oSerTableTypes::Document
//case c_oSerTableTypes::Comments:
//case c_oSerTableTypes::Comments
// res = oBinary_CommentsTableReader.Read();
// break;
//case c_oSerTableTypes::Other:
@ -8160,7 +8356,18 @@ public:
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", L"fontTable.xml", L"", &stamdartRId);
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", L"theme/theme1.xml",L"", &stamdartRId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", L"/word", L"document.xml");
if (m_oFileWriter.m_pVbaProject.IsInit())
{
//m_oFileWriter.m_pVbaProject->write();
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2006/relationships/vbaProject", L"vbaProject.bin", L"", &stamdartRId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.ms-word.document.macroEnabled.main+xml", L"/word", L"document.xml");
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.ms-office.vbaProject", L"/word", L"vbaProject.bin");
}
else
{
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", L"/word", L"document.xml");
}
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", L"/word", L"styles.xml");
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", L"/word", L"settings.xml");
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml", L"/word", L"webSettings.xml");
@ -8170,19 +8377,19 @@ public:
if(false == m_oFileWriter.m_oNumberingWriter.IsEmpty())
{
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering")), std::wstring(_T("numbering.xml")), std::wstring(), &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;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes")), std::wstring(_T("footnotes.xml")), std::wstring(), &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;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes")), std::wstring(_T("endnotes.xml")), std::wstring(), &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");
}
for(size_t i = 0; i < m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders.size(); ++i)
@ -8191,7 +8398,7 @@ public:
if(false == pHeader->IsEmpty())
{
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header")), pHeader->m_sFilename, std::wstring(), &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 );
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", L"/word", pHeader->m_sFilename);
@ -8203,7 +8410,7 @@ public:
if(false == pFooter->IsEmpty())
{
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer")), pFooter->m_sFilename, std::wstring(), &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);
@ -8211,9 +8418,9 @@ public:
}
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 + _T("word")
+ FILE_SEPARATOR_STR + _T("_rels")
+ FILE_SEPARATOR_STR + _T("document.xml.rels");
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word"
+ FILE_SEPARATOR_STR + L"_rels"
+ FILE_SEPARATOR_STR + L"document.xml.rels";
CComments& oComments= oBinary_CommentsTableReader.m_oComments;
Writers::CommentsWriter& oCommentsWriter = m_oFileWriter.m_oCommentsWriter;
@ -8227,19 +8434,19 @@ public:
if(false == oCommentsWriter.m_sComment.empty())
{
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments")), std::wstring(_T("comments.xml")), std::wstring(), &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;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.microsoft.com/office/2011/relationships/commentsExtended")), std::wstring(_T("commentsExtended.xml")), std::wstring(), &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;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.microsoft.com/office/2011/relationships/people")), std::wstring(_T("people.xml")), std::wstring(), &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");
}

View File

@ -144,9 +144,13 @@ namespace MathEquation
void AddAccent (MEMBELTYPE eType)
{
LONG lPos = GetSize() - 1;
if (lPos < 0) return;
EquationRun oRun;
oRun = arrRun[lPos];
RemoveElem(lPos);
oRun.bAccent = true;
oRun.eType = eType;
Add(oRun);
@ -557,11 +561,11 @@ namespace MathEquation
BYTE horAlign;
switch(eHorAlign)
{
case matrixhoralignLeft: horAlign = SimpleTypes::xalignLeft;
case matrixhoralignCenter: horAlign = SimpleTypes::xalignCenter;
case matrixhoralignRight: horAlign = SimpleTypes::xalignRight;
case matrixhoralignEqualSign: horAlign = SimpleTypes::xalignCenter;
case matrixhoralignCommaSign: horAlign = SimpleTypes::xalignCenter;
case matrixhoralignLeft: horAlign = SimpleTypes::xalignLeft; break;
case matrixhoralignCenter: horAlign = SimpleTypes::xalignCenter; break;
case matrixhoralignRight: horAlign = SimpleTypes::xalignRight; break;
case matrixhoralignEqualSign: horAlign = SimpleTypes::xalignCenter; break;
case matrixhoralignCommaSign: horAlign = SimpleTypes::xalignCenter; break;
}
WriteItemVal(BinDocxRW::c_oSer_OMathBottomNodesType::McJc, horAlign);
@ -1675,7 +1679,7 @@ namespace MathEquation
void WriteEndNode(BinaryEquationWriter* pWriter)
{
int nCurPos;
int nCurPos = -1;
if (!m_aBaseStack.empty())
{
nCurPos = m_aBaseStack.top();
@ -1687,14 +1691,20 @@ namespace MathEquation
}
if (bPile && bEqArrayStart)
{
pWriter->WriteItemEnd(nCurPos);
}
else if (!bPile && !bEqArrayStart)
{
pWriter->WriteItemEnd(nCurPos);
}
else if (!bPile && bEqArrayStart)
{
pWriter->m_aRowsCounter.push(nRows);
bEqArrayStart = false;
pWriter->WriteItemEnd(nCurPos);//eqArr
if (nCurPos > 0)
pWriter->WriteItemEnd(nCurPos);//eqArr
if (!m_aBaseStack.empty())
{

View File

@ -125,6 +125,7 @@ const double g_dKoef_mm_to_hps = 2 * g_dKoef_mm_to_pt;
const static wchar_t* g_sFormatSignature = L"DOCY";
const int g_nFormatVersion = 5;
const int g_nFormatVersionNoBase64 = 10;
extern int g_nCurFormatVersion;
namespace c_oAscWrapStyle{enum c_oSerFormat
{
@ -141,19 +142,20 @@ extern int g_nCurFormatVersion;
};}
namespace c_oSerTableTypes{enum c_oSerTableTypes
{
Signature = 0,
Info = 1,
Media = 2,
Numbering = 3,
HdrFtr = 4,
Style = 5,
Document = 6,
Other = 7,
Comments = 8,
Settings = 9,
Footnotes = 10,
Endnotes = 11,
Background
Signature = 0,
Info = 1,
Media = 2,
Numbering = 3,
HdrFtr = 4,
Style = 5,
Document = 6,
Other = 7,
Comments = 8,
Settings = 9,
Footnotes = 10,
Endnotes = 11,
Background = 12,
VbaProject = 13
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
@ -202,10 +204,10 @@ extern int g_nCurFormatVersion;
};}
namespace c_oSerOtherTableTypes{enum c_oSerOtherTableTypes
{
ImageMap = 0,
ImageMap_Src = 1,
EmbeddedFonts = 2,
DocxTheme = 3
ImageMap = 0,
ImageMap_Src = 1,
EmbeddedFonts = 2,
DocxTheme = 3
};}
namespace c_oSerFontsTypes{enum c_oSerFontsTypes
{
@ -342,7 +344,9 @@ extern int g_nCurFormatVersion;
FramePr = 30,
SectPr = 31,
numPr_Ins = 32,
pPrChange = 33
pPrChange = 33,
outlineLvl = 34,
Tab_Item_Leader = 35
};}
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
{
@ -472,7 +476,9 @@ extern int g_nCurFormatVersion;
MoveFromRangeStart = 18,
MoveFromRangeEnd = 19,
MoveToRangeStart = 20,
MoveToRangeEnd = 21
MoveToRangeEnd = 21,
BookmarkStart = 22,
BookmarkEnd = 23
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -487,7 +493,9 @@ extern int g_nCurFormatVersion;
Cell_Pr = 7,
Cell_Content = 8,
tblGridChange = 9,
Sdt = 10
Sdt = 10,
BookmarkStart = 11,
BookmarkEnd = 12
};}
namespace c_oSerRunType{enum c_oSerRunType
{
@ -500,8 +508,8 @@ extern int g_nCurFormatVersion;
image = 6,
table = 7,
Content = 8,
fldstart = 9,
fldend = 10,
fldstart_deprecated = 9,
fldend_deprecated = 10,
CommentReference = 11,
pptxDrawing = 12,
object = 14,
@ -518,7 +526,14 @@ extern int g_nCurFormatVersion;
endnoteRef = 25,
footnoteReference = 26,
endnoteReference = 27,
arPr = 28
arPr = 28,
fldChar = 29,
instrText = 30,
delInstrText = 31
};}
namespace c_oSerVbaProjectTypes{enum c_oSerVbaProjectType
{
Name = 0
};}
namespace c_oSerBackgroundType{enum c_oSerBackgroundType
{
@ -715,7 +730,8 @@ extern int g_nCurFormatVersion;
Text = 6,
QuoteText = 7,
Solved = 8,
Replies = 9
Replies = 9,
OOData = 10
};}
namespace c_oSer_SettingsType{enum c_oSer_SettingsType
{
@ -888,7 +904,9 @@ extern int g_nCurFormatVersion;
Ins = 62,
Del = 63,
columnbreak = 64,
ARPr = 65
ARPr = 65,
BookmarkStart = 66,
BookmarkEnd = 67
};}
namespace c_oSer_FramePrType{ enum c_oSer_FramePrType
{
@ -921,7 +939,8 @@ extern int g_nCurFormatVersion;
{
Content = 0,
Instr = 1,
FFData = 2
FFData = 2,
CharType = 3
};}
namespace c_oSer_ColorThemeType{ enum c_oSer_ColorThemeType
{
@ -1092,6 +1111,14 @@ extern int g_nCurFormatVersion;
Name = 6,
UserId = 7
};}
namespace c_oSerBookmark{enum c_oSerBookmark
{
Id = 0,
Name = 1,
DisplacedByCustomXml = 2,
ColFirst = 3,
ColLast = 4
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

View File

@ -76,18 +76,6 @@ namespace BinDocxRW
{
}
};
class FldStruct
{
protected:
int m_nType;
public:
std::wstring m_sFld;
public: FldStruct(std::wstring sFld, int nType):m_sFld(sFld),m_nType(nType){}
public: int GetType()
{
return m_nType;
}
};
class BinaryCommonWriter
{
public:
@ -1024,6 +1012,12 @@ namespace BinDocxRW
WritePPrChange(pPr.m_oPPrChange.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(pPr.m_oOutlineLvl.IsInit() && pPr.m_oOutlineLvl->m_oVal.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::outlineLvl);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pPr.m_oOutlineLvl->m_oVal->GetValue());
}
//SectPr
if(NULL != m_oBinaryHeaderFooterTableWriter && pPr.m_oSectPr.IsInit())
{
@ -1185,6 +1179,12 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(TabItem.m_oPos.get().ToMm());
}
if(false != TabItem.m_oLeader.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Tab_Item_Leader);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE((BYTE)TabItem.m_oLeader->GetValue());
}
}
void WriteNumPr(const OOX::Logic::CNumPr& numPr, const OOX::Logic::CParagraphProperty& pPr)
{
@ -2986,11 +2986,6 @@ namespace BinDocxRW
std::wstring m_sCurParStyle;
OOX::CSettings* m_oSettings;
//для fldChar
//todo в документации описан случай если нет fldchartypeEnd, у нас работает не так.
std::vector<FldStruct*> m_aFldChars;
std::wstring m_sFldChar;
SimpleTypes::EFldCharType m_eFldState;
NSBinPptxRW::CDrawingConverter* m_pOfficeDrawingConverter;
std::map<int, bool>* m_mapIgnoreComments;
public:
@ -3006,14 +3001,6 @@ namespace BinDocxRW
pBackground = NULL;
pSectPr = NULL;
m_bWriteSectPr = false;
m_eFldState = SimpleTypes::fldchartypeEnd;
}
~BinaryDocumentTableWriter()
{
for(size_t i = 0, length = m_aFldChars.size(); i < length; ++i)
{
RELEASEOBJECT(m_aFldChars[i]);
}
}
void prepareOfficeDrawingConverter(NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, OOX::IFileContainer *rels, std::vector<std::wstring>& aShapeTypes)
{
@ -3025,7 +3012,14 @@ namespace BinDocxRW
std::wstring& sShapeType = aShapeTypes[i];
pOfficeDrawingConverter->AddShapeType(sShapeType);
}
pOfficeDrawingConverter->SetRels(oldRels);
pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteVbaProject(OOX::VbaProject& oVbaProject)
{
m_oBcw.m_oStream.StartRecord(0);
oVbaProject.toPPTY(&m_oBcw.m_oStream);
m_oBcw.m_oStream.EndRecord();
}
void Write(std::vector<OOX::WritingElement*>& aElems)
{
@ -3082,6 +3076,20 @@ namespace BinDocxRW
OOX::Logic::CBdo* pBdo = static_cast<OOX::Logic::CBdo*>(item);
WriteDocumentContent(pBdo->m_arrItems);
}break;
case OOX::et_w_bookmarkStart:
{
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkStart);
WriteBookmarkStart(*pBookmarkStart);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}break;
case OOX::et_w_bookmarkEnd:
{
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkEnd);
WriteBookmarkEnd(*pBookmarkEnd);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}break;
default:
break;
}
@ -3156,24 +3164,6 @@ namespace BinDocxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
FldStruct* ParseField(const std::wstring& sFld)
{
std::wstring sFldCopy = sFld;
boost::algorithm::trim (sFldCopy);
boost::algorithm::to_upper (sFldCopy);
FldStruct* pRes = NULL;
int nIndex = 0;
if(-1 != (nIndex = (int)sFldCopy.find(_T("TOC"))))
pRes = new FldStruct(sFldCopy, fieldstruct_toc);
else if(-1 != (nIndex = (int)sFldCopy.find(_T("HYPERLINK"))))
pRes = new FldStruct(sFldCopy, fieldstruct_hyperlink);
else
pRes = new FldStruct(sFldCopy, fieldstruct_none);
return pRes;
}
void WriteParagraphContent(const std::vector<OOX::WritingElement *>& Content, bool bHyperlink = false)
{
int nCurPos = 0;
@ -3273,6 +3263,22 @@ namespace BinDocxRW
WriteComment(OOX::et_w_commentRangeEnd, pCommentRangeEnd->m_oId);
break;
}
case OOX::et_w_bookmarkStart:
{
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkStart);
WriteBookmarkStart(*pBookmarkStart);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_bookmarkEnd:
{
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkEnd);
WriteBookmarkEnd(*pBookmarkEnd);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
//todo moveRange on all levels(body, p ...)
// case OOX::et_w_moveFromRangeStart:
// {
@ -3452,6 +3458,16 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
}
void WriteFldChar(OOX::Logic::CFldChar* pFldChar)
{
int nCurPos = 0;
if(pFldChar->m_oFldCharType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::CharType);
m_oBcw.m_oStream.WriteBYTE((BYTE)pFldChar->m_oFldCharType->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteFldSimple(OOX::Logic::CFldSimple* pFldSimple)
{
int nCurPos = 0;
@ -3603,7 +3619,7 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteLONG(oDDList.m_oResult->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
for(int i = 0 ; i < oDDList.m_arrListEntry.size(); ++i)
for(size_t i = 0 ; i < oDDList.m_arrListEntry.size(); ++i)
{
ComplexTypes::Word::String* pVal = oDDList.m_arrListEntry[i];
if(pVal->m_sVal.IsInit())
@ -3674,11 +3690,60 @@ namespace BinDocxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteBookmarkStart(const OOX::Logic::CBookmarkStart& oBookmarkStart)
{
int nCurPos = 0;
if (oBookmarkStart.m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::Id);
m_oBcw.m_oStream.WriteLONG(oBookmarkStart.m_oId->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oBookmarkStart.m_sName.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::Name);
m_oBcw.m_oStream.WriteStringW3(oBookmarkStart.m_sName.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oBookmarkStart.m_oDisplacedByCustomXml.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::DisplacedByCustomXml);
m_oBcw.m_oStream.WriteBYTE((BYTE)oBookmarkStart.m_oDisplacedByCustomXml->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oBookmarkStart.m_oColFirst.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::ColFirst);
m_oBcw.m_oStream.WriteLONG(oBookmarkStart.m_oColFirst->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oBookmarkStart.m_oColLast.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::ColLast);
m_oBcw.m_oStream.WriteLONG(oBookmarkStart.m_oColLast->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteBookmarkEnd(const OOX::Logic::CBookmarkEnd& oBookmarkEnd)
{
int nCurPos = 0;
if (oBookmarkEnd.m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::Id);
m_oBcw.m_oStream.WriteLONG(oBookmarkEnd.m_oId->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oBookmarkEnd.m_oDisplacedByCustomXml.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::DisplacedByCustomXml);
m_oBcw.m_oStream.WriteBYTE((BYTE)oBookmarkEnd.m_oDisplacedByCustomXml->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteHyperlink(OOX::Logic::CHyperlink* pHyperlink)
{
int nCurPos = 0;
std::wstring sField;
std::wstring sLink;
if(pHyperlink->m_oId.IsInit())
{
@ -3691,24 +3756,20 @@ namespace BinDocxRW
}
}
if(!sLink.empty())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Hyperlink);
WriteHyperlinkContent(sLink, pHyperlink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
else
{
WriteParagraphContent(pHyperlink->m_arrItems, true);
}
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Hyperlink);
WriteHyperlinkContent(sLink, pHyperlink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
void WriteHyperlinkContent(std::wstring& sLink, OOX::Logic::CHyperlink* pHyperlink)
{
int nCurPos = 0;
//Link
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Link);
m_oBcw.m_oStream.WriteStringW3(sLink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
if(!sLink.empty())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Link);
m_oBcw.m_oStream.WriteStringW3(sLink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//Anchor
if(pHyperlink->m_sAnchor.IsInit())
{
@ -4111,6 +4172,22 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_bookmarkStart:
{
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::BookmarkStart);
WriteBookmarkStart(*pBookmarkStart);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_bookmarkEnd:
{
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::BookmarkEnd);
WriteBookmarkEnd(*pBookmarkEnd);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
default:
break;
}
@ -5409,51 +5486,6 @@ namespace BinDocxRW
int nCurPos = 0;
OOX::Logic::CRunProperty* oCur_rPr = pRun->m_oRunProperty;
if(NULL != oCur_rPr)
{
//Заглушка для содержания
if(false == bHyperlink)
{
//Случай если Hyperlink задан как field
for(size_t i = 0, length = m_aFldChars.size(); i < length; ++i)
{
if(fieldstruct_hyperlink == m_aFldChars[i]->GetType())
{
bHyperlink = true;
break;
}
}
}
if(bHyperlink)
{
bool bInTOC = false;
for(size_t i = 0, length = m_aFldChars.size(); i < length; ++i)
{
if(fieldstruct_toc == m_aFldChars[i]->GetType())
{
bInTOC = true;
break;
}
}
if(bInTOC)
{
//убираем Runstyle
if(oCur_rPr->m_oRStyle.IsInit())
oCur_rPr->m_oRStyle.reset();
//Если настройки выставлены явно, то убираем их
if(oCur_rPr->m_oColor.IsInit() && oCur_rPr->m_oColor->m_oVal.IsInit() && SimpleTypes::hexcolorRGB == oCur_rPr->m_oColor->m_oVal->GetValue())
{
unsigned char bR = oCur_rPr->m_oColor->m_oVal->Get_R();
unsigned char bG = oCur_rPr->m_oColor->m_oVal->Get_G();
unsigned char bB = oCur_rPr->m_oColor->m_oVal->Get_B();
if(0x00 == bR && 0x00 == bG && 0xFF == bB)
oCur_rPr->m_oColor->m_oVal->Set_B(0x00);
}
if(oCur_rPr->m_oU.IsInit() && oCur_rPr->m_oU->m_oVal.IsInit() && SimpleTypes::underlineSingle == oCur_rPr->m_oU->m_oVal->GetValue())
oCur_rPr->m_oU->m_oVal->SetValue(SimpleTypes::underlineNone);
}
}
}
//Если первый элемент символ надо выставить в его настройки шрифт
if(nIndexStart < (int)pRun->m_arrItems.size() && OOX::et_w_sym == pRun->m_arrItems[nIndexStart]->getType())
{
@ -5530,51 +5562,21 @@ namespace BinDocxRW
case OOX::et_w_fldChar:
{
OOX::Logic::CFldChar* pFldChar = static_cast<OOX::Logic::CFldChar*>(item);
if(pFldChar->m_oFldCharType.IsInit())
{
if(SimpleTypes::fldchartypeBegin == pFldChar->m_oFldCharType.get().GetValue())
{
m_eFldState = SimpleTypes::fldchartypeBegin;
m_sFldChar.clear();
}
else if(SimpleTypes::fldchartypeEnd == pFldChar->m_oFldCharType.get().GetValue())
{
m_eFldState = SimpleTypes::fldchartypeEnd;
if(m_aFldChars.size() > 0)
{
int nIndex = (int)m_aFldChars.size() - 1;
FldStruct* pFldStruct = m_aFldChars[nIndex];
RELEASEOBJECT(pFldStruct);
m_aFldChars.erase(m_aFldChars.begin() + nIndex);
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::fldend);
m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null);
}
}
else if(SimpleTypes::fldchartypeSeparate == pFldChar->m_oFldCharType.get().GetValue())
{
m_eFldState = SimpleTypes::fldchartypeSeparate;
FldStruct* pFldStruct = ParseField(m_sFldChar);
m_aFldChars.push_back(pFldStruct);
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::fldstart);
m_oBcw.m_oStream.WriteStringW(m_sFldChar);
}
}
int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::fldChar);
WriteFldChar(pFldChar);
m_oBcw.WriteItemEnd(nCurPos);
}
break;
case OOX::et_w_delInstrText:
{
OOX::Logic::CDelInstrText* pInstrText = static_cast<OOX::Logic::CDelInstrText*>(item);
WriteText(pInstrText->m_sText, c_oSerRunType::delInstrText);
}
break;
case OOX::et_w_instrText:
{
OOX::Logic::CInstrText* pInstrText = static_cast<OOX::Logic::CInstrText*>(item);
if(SimpleTypes::fldchartypeBegin == m_eFldState)
m_sFldChar += pInstrText->m_sText;
else
{
if(!pInstrText->m_sText.empty())
{
WriteText(pInstrText->m_sText);
}
}
WriteText(pInstrText->m_sText, c_oSerRunType::instrText);
}
break;
case OOX::et_w_nonBreakHyphen:
@ -5606,25 +5608,19 @@ namespace BinDocxRW
OOX::Logic::CSym* oSym = static_cast<OOX::Logic::CSym*>(item);
wchar_t ch = 0x0FFF & oSym->m_oChar->GetValue();
std::wstring sText(&ch, 1);
WriteText(sText);
WriteText(sText, c_oSerRunType::run);
break;
}
case OOX::et_w_delText:
{
std::wstring& sText = static_cast<OOX::Logic::CDelText*>(item)->m_sText;
if(!sText.empty())
{
WriteDelText(sText);
}
WriteText(sText, c_oSerRunType::delText);
}
break;
case OOX::et_w_t:
{
std::wstring& sText = static_cast<OOX::Logic::CText*>(item)->m_sText;
if(!sText.empty())
{
WriteText(sText);
}
WriteText(sText, c_oSerRunType::run);
}
break;
case OOX::et_w_tab:
@ -5714,19 +5710,15 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
}
void WriteDelText(const std::wstring& text)
void WriteText(const std::wstring& text, BYTE type)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::delText);
m_oBcw.m_oStream.WriteStringW(text.c_str());
if(NULL != m_oBcw.m_pEmbeddedFontsManager)
m_oBcw.m_pEmbeddedFontsManager->CheckString(text);
}
void WriteText(const std::wstring& text)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::run);
m_oBcw.m_oStream.WriteStringW(text);
if(NULL != m_oBcw.m_pEmbeddedFontsManager)
m_oBcw.m_pEmbeddedFontsManager->CheckString(text);
if(!text.empty())
{
m_oBcw.m_oStream.WriteBYTE(type);
m_oBcw.m_oStream.WriteStringW(text);
if(NULL != m_oBcw.m_pEmbeddedFontsManager)
m_oBcw.m_pEmbeddedFontsManager->CheckString(text);
}
}
void WriteDrawingPptx(OOX::WritingElement* item)
{
@ -6737,6 +6729,20 @@ namespace BinDocxRW
OOX::Logic::CBdo* pBdo = static_cast<OOX::Logic::CBdo*>(item);
WriteTableContent(pBdo->m_arrItems, pTblPr, nRows, nCols);
}
else if(OOX::et_w_bookmarkStart == item->getType())
{
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkStart);
WriteBookmarkStart(*pBookmarkStart);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
else if(OOX::et_w_bookmarkEnd == item->getType())
{
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkEnd);
WriteBookmarkEnd(*pBookmarkEnd);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
void WriteRow(const OOX::Logic::CTr& Row, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nRows, int nCols)
@ -6797,6 +6803,20 @@ namespace BinDocxRW
OOX::Logic::CBdo* pBdo = static_cast<OOX::Logic::CBdo*>(item);
WriteRowContent(pBdo->m_arrItems, pTblPr, nCurRowIndex, nRows, nCols);
}
else if(OOX::et_w_bookmarkStart == item->getType())
{
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkStart);
WriteBookmarkStart(*pBookmarkStart);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
else if(OOX::et_w_bookmarkEnd == item->getType())
{
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkEnd);
WriteBookmarkEnd(*pBookmarkEnd);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
void WriteCell(OOX::Logic::CTc& tc, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nCurColIndex, int nRows, int nCols)
@ -7222,6 +7242,11 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentsType::Date);
m_oBcw.m_oStream.WriteStringW(pComment->m_oDate->ToString());
}
if(pComment->m_oOOData.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_CommentsType::OOData);
m_oBcw.m_oStream.WriteStringW(pComment->m_oOOData.get2());
}
if(pComment->m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_CommentsType::Id);
@ -7714,9 +7739,9 @@ namespace BinDocxRW
m_nLastFilePos = 0;
m_nRealTableCount = 0;
}
static std::wstring WriteFileHeader(long nDataSize)
static std::wstring WriteFileHeader(long nDataSize, int version)
{
std::wstring sHeader = std::wstring(g_sFormatSignature) + L";v" + std::to_wstring(g_nFormatVersion) + L";" + std::to_wstring(nDataSize) + L";";
std::wstring sHeader = std::wstring(g_sFormatSignature) + L";v" + std::to_wstring(version) + L";" + std::to_wstring(nDataSize) + L";";
return sHeader;
}
void WriteMainTableStart()
@ -7861,9 +7886,8 @@ namespace BinDocxRW
//Write DocumentTable
ParamsDocumentWriter oParamsDocumentWriter(poDocument);
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
//DocumentTable всегда пишем последней, чтобы сначала заполнить все вспомогательные структуры, а при заполении документа, вызывать методы типа Style_Add...
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Document);
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, &oBinaryHeaderFooterTableWriter);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_oParamsWriter.m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, poDocument->m_arrShapeTypes);
@ -7871,7 +7895,15 @@ namespace BinDocxRW
oBinaryDocumentTableWriter.pBackground = poDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.m_bWriteSectPr = true;
//Write Vba
if(NULL != oDocx.m_pVbaProject)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::VbaProject);
oBinaryDocumentTableWriter.WriteVbaProject(*oDocx.m_pVbaProject);
this->WriteTableEnd(nCurPos);
}
// Write content
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Document);
oBinaryDocumentTableWriter.Write(poDocument->m_arrItems);
this->WriteTableEnd(nCurPos);

View File

@ -658,8 +658,7 @@ namespace BinXlsxRW{
std::wstring wb, sheetFrom, sheetTo;
int nRow1, nCol1, nRow2, nCol2;
if(OOX::Spreadsheet::CCell::parse3DRef(*pStrRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() &&
NULL != pStrRef->m_strCache)
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pStrRef->m_strCache)
{
bool bRow = nRow1 == nRow2;
if(bUpdateRange)
@ -727,7 +726,7 @@ namespace BinXlsxRW{
std::wstring wb, sheetFrom, sheetTo;
int nRow1, nCol1, nRow2, nCol2;
if(OOX::Spreadsheet::CCell::parse3DRef(*pNumRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
{
bool bRow = nRow1 == nRow2;
if(bUpdateRange)

View File

@ -47,6 +47,7 @@ BinDocxRW::CDocxSerializer::CDocxSerializer()
m_pCurFileWriter = NULL;
m_bIsNoBase64Save = false;
m_bIsNoBase64 = false;
m_bSaveChartAsImg = false;
}
BinDocxRW::CDocxSerializer::~CDocxSerializer()
@ -54,52 +55,6 @@ BinDocxRW::CDocxSerializer::~CDocxSerializer()
RELEASEOBJECT(m_pParamsWriter);
RELEASEOBJECT(m_pCurFileWriter);
}
bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, L"Editor.bin");
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
if(saveToFile(strEditorBin, strDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName))
return true;
return false;
}
bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, L"Editor.bin");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
std::wstring sEditorBin = strEditorBin;
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
{
std::wstring sMediaPath;
std::wstring sThemePath;
std::wstring sEmbedPath;
CreateDocxFolders(strDirDst, sThemePath, sMediaPath, sEmbedPath);
if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
{
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, true))
return true;
}
}
return false;
}
bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions)
{
OOX::CPath pathMain(sSrcFileName);
@ -138,19 +93,25 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
oDrawingConverter.SetFontDir(m_sFontDir);
oDrawingConverter.SetFontPicker(pFontPicker);
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetDstPath(pathMain.GetDirectory() + FILE_SEPARATOR_STR + L"word");
oDrawingConverter.SetMediaDstPath(pathMedia.GetPath());
m_pParamsWriter = new ParamsWriter(&oBufferedStream, &fp, &oDrawingConverter, pEmbeddedFontsManager);
BinaryFileWriter oBinaryFileWriter(*m_pParamsWriter);
if (m_bIsNoBase64)
{
oBufferedStream.WriteStringUtf8(oBinaryFileWriter.WriteFileHeader(0, g_nFormatVersionNoBase64));
}
oBinaryFileWriter.intoBindoc(sDstPath);
BYTE* pbBinBuffer = oBufferedStream.GetBuffer();
int nBinBufferLen = oBufferedStream.GetPosition();
if (m_bIsNoBase64Save)
if (m_bIsNoBase64 || m_bIsNoBase64Save)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSrcFileName);
@ -166,7 +127,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSrcFileName);
oFile.WriteStringUTF8(oBinaryFileWriter.WriteFileHeader(nBinBufferLen));
oFile.WriteStringUTF8(oBinaryFileWriter.WriteFileHeader(nBinBufferLen, g_nFormatVersion));
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
@ -268,28 +229,45 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
else
dst_len += _c;
}
int nDataSize = atoi(dst_len.c_str());
BYTE* pData = new BYTE[nDataSize];
if(false != Base64::Base64Decode((const char*)(pBase64Data + nIndex), nBase64DataSize - nIndex, pData, &nDataSize))
int nVersion = g_nFormatVersion;
if(!version.empty())
{
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pReader;
oBufferedStream.Init(pData, 0, nDataSize);
version = version.substr(1);
g_nCurFormatVersion = nVersion = std::stoi(version.c_str());
}
bool bIsNoBase64 = nVersion == g_nFormatVersionNoBase64;
int nVersion = g_nFormatVersion;
if(!version.empty())
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pReader;
int nDataSize = 0;
BYTE* pData = NULL;
if (!bIsNoBase64)
{
nDataSize = atoi(dst_len.c_str());
pData = new BYTE[nDataSize];
if(Base64::Base64Decode((const char*)(pBase64Data + nIndex), nBase64DataSize - nIndex, pData, &nDataSize))
{
version = version.substr(1);
int nTempVersion = atoi(version.c_str());
if(0 != nTempVersion)
{
g_nCurFormatVersion = nVersion = nTempVersion;
}
}
oBufferedStream.Init(pData, 0, nDataSize);
}
else
{
RELEASEARRAYOBJECTS(pData);
}
}
else
{
nDataSize = nBase64DataSize;
pData = pBase64Data;
oBufferedStream.Init(pData, 0, nDataSize);
oBufferedStream.Seek(nIndex);
}
if (NULL != pData)
{
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetDstPath(sDstPath + FILE_SEPARATOR_STR + L"word");
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
@ -299,7 +277,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
std::wstring sFileInDir = strFileInDir.c_str();
oDrawingConverter.SetSourceFileDir(sFileInDir);
oDrawingConverter.SetSrcPath(sFileInDir);
BinaryFileReader oBinaryFileReader(sFileInDir, oBufferedStream, *m_pCurFileWriter);
oBinaryFileReader.ReadFile();
@ -318,7 +296,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
if (pApp)
{
pApp->SetApplication(_T("OnlyOffice"));
pApp->SetAppVersion(_T("4.3000"));
pApp->SetAppVersion(_T("5.0"));
pApp->SetDocSecurity(0);
pApp->SetScaleCrop(false);
pApp->SetLinksUpToDate(false);
@ -343,6 +321,11 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
bResultOk = true;
}
if (!bIsNoBase64)
{
RELEASEARRAYOBJECTS(pData);
}
}
RELEASEARRAYOBJECTS(pBase64Data);
}
@ -472,6 +455,10 @@ void BinDocxRW::CDocxSerializer::setIsNoBase64Save(bool bIsNoBase64Save)
{
m_bIsNoBase64Save = bIsNoBase64Save;
}
void BinDocxRW::CDocxSerializer::setIsNoBase64(bool bIsNoBase64)
{
m_bIsNoBase64 = bIsNoBase64;
}
void BinDocxRW::CDocxSerializer::setSaveChartAsImg(bool bSaveChartAsImg)
{
m_bSaveChartAsImg = bSaveChartAsImg;

View File

@ -54,6 +54,7 @@ namespace BinDocxRW
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
bool m_bIsNoBase64Save;
bool m_bIsNoBase64;
bool m_bSaveChartAsImg;
ParamsWriter* m_pParamsWriter;
Writers::FileWriter* m_pCurFileWriter;
@ -61,9 +62,6 @@ namespace BinDocxRW
CDocxSerializer();
virtual ~CDocxSerializer();
bool ConvertDocxToDoct(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions);
bool ConvertDoctToDocx(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions);
bool loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sThemePath, const std::wstring& sMediaPath, const std::wstring& sEmbedPath);
bool saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
@ -78,6 +76,7 @@ namespace BinDocxRW
void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);
void setIsNoBase64Save (bool bIsNoBase64Save);
void setIsNoBase64 (bool bIsNoBase64);
void setSaveChartAsImg (bool bSaveChartAsImg);
};
}

View File

@ -49,6 +49,7 @@ namespace BinXlsxRW{
CXlsxSerializer::CXlsxSerializer()
{
m_pExternalDrawingConverter = NULL;
m_bIsNoBase64 = false;
}
CXlsxSerializer::~CXlsxSerializer()
{
@ -85,15 +86,16 @@ namespace BinXlsxRW{
}
bool 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);
NSBinPptxRW::CDrawingConverter oDrawingConverter;
oDrawingConverter.SetDstPath(sDstPath + FILE_SEPARATOR_STR + L"xl");
oDrawingConverter.SetSrcPath(strFileInDir, 2);
oDrawingConverter.SetMediaDstPath(sMediaDir);
oDrawingConverter.SetEmbedDstPath(sEmbedDir);
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
oDrawingConverter.SetSourceFileDir(strFileInDir, 2);
BinXlsxRW::BinaryFileReader oBinaryFileReader;
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
return true;
@ -134,7 +136,7 @@ namespace BinXlsxRW{
oOfficeDrawingConverter.SetFontPicker(pFontPicker);
BinXlsxRW::BinaryFileWriter oBinaryFileWriter(fp);
oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions);
oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
RELEASEOBJECT(pFontPicker);
return true;
@ -179,20 +181,22 @@ namespace BinXlsxRW{
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
writeChartXlsx(sXlsxPath, oChartSpace);
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
if (writeChartXlsx(sXlsxPath, oChartSpace))
{
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
}
std::wstring strFilepath = sFilepath;
@ -226,7 +230,12 @@ namespace BinXlsxRW{
{
m_pExternalDrawingConverter = pDrawingConverter;
}
void CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
void CXlsxSerializer::setIsNoBase64(bool bIsNoBase64)
{
m_bIsNoBase64 = bIsNoBase64;
}
bool CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
{
//анализируем chart
BinXlsxRW::ChartWriter helper;
@ -245,11 +254,15 @@ namespace BinXlsxRW{
helper.toXlsx(oXlsx);
//write
OOX::CContentTypes oContentTypes;
oXlsx.Write(oPath, oContentTypes);
//zip
COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
bool res = oXlsx.Write(oPath, oContentTypes);
if (res)
{
//zip
COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
}
//clean
NSDirectory::DeleteDirectory(sTempDir);
return res;
}
};

View File

@ -55,6 +55,7 @@ namespace BinXlsxRW {
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
NSBinPptxRW::CDrawingConverter* m_pExternalDrawingConverter;
bool m_bIsNoBase64;
public:
CXlsxSerializer();
~CXlsxSerializer();
@ -69,8 +70,9 @@ namespace BinXlsxRW {
void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
void setIsNoBase64 (bool bIsNoBase64);
void writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
bool writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
};
}
#endif // #ifndef XLSX_SERIALIZER

View File

@ -314,7 +314,7 @@
17E17ED41AC453F800BEA2EA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0710;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Ascensio System SIA";
};
buildConfigurationList = 17E17ED71AC453F800BEA2EA /* Build configuration list for PBXProject "ASCOfficeDocxFile2Lib" */;
@ -402,6 +402,7 @@
EXECUTABLE_PREFIX = lib;
GCC_ENABLE_CPP_EXCEPTIONS = YES;
GCC_ENABLE_CPP_RTTI = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
@ -441,13 +442,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
@ -455,6 +464,7 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
@ -467,7 +477,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
@ -483,13 +493,21 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
@ -497,13 +515,14 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;

View File

@ -34,9 +34,11 @@
#include <stdio.h>
#include <tchar.h>
#include "../../Common/OfficeFileFormatChecker.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../src/ConvertOO2OOX.h"
#include "../include/logging.h"
#if defined(_WIN64)
@ -45,30 +47,55 @@
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
int _tmain(int argc, _TCHAR* argv[])
HRESULT convert_single(std::wstring srcFileName)
{
if (argc < 2) return 1;
HRESULT hr = S_OK;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx docx
COfficeFileFormatChecker fileChecker(srcFileName);
std::wstring dstPath = srcFileName;// + ; //xlsx pptx docx
switch(fileChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT: dstPath += L"-my.docx"; break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT: dstPath += L"-my.xlsx"; break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT: dstPath += L"-my.pptx"; break;
default:
return S_FALSE;
}
//---------------------------------------------------------------------------------------------------
COfficeUtils oCOfficeUtils(NULL);
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
std::wstring srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
std::wstring srcTempPath;
// распаковываем исходник во временную директорию
COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
return S_FALSE;
if (fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT ||
fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS ||
fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP)
{
srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
return S_FALSE;
}
else // flat
{
srcTempPath = srcFileName;
}
_CP_LOG << L"[info] " << srcFileName << std::endl;
hr = ConvertOO2OOX(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", false, NULL);
NSDirectory::DeleteDirectory(srcTempPath);
if (srcTempPath != srcFileName)
{
NSDirectory::DeleteDirectory(srcTempPath);
}
if (hr != S_OK) return hr;
@ -77,6 +104,35 @@ int _tmain(int argc, _TCHAR* argv[])
NSDirectory::DeleteDirectory(dstTempPath);
////////////////////////////////////////////////////////////////////////
return 0;
return hr;
}
HRESULT convert_directory(std::wstring pathName)
{
HRESULT hr = S_OK;
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
for (size_t i = 0; i < arFiles.size(); i++)
{
convert_single(arFiles[i]);
}
return S_OK;
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
HRESULT hr = -1;
if (NSFile::CFileBinary::Exists(argv[1]))
{
hr = convert_single(argv[1]);
}
else if (NSDirectory::Exists(argv[1]))
{
hr = convert_directory(argv[1]);
}
return hr;
}

View File

@ -43,6 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE;UNICODE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -335,6 +336,14 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\Common\OfficeFileFormatChecker.h"
>
</File>
<File
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
@ -347,6 +356,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>

View File

@ -32,6 +32,7 @@
#pragma once
#include <string>
#include <vector>
#include "../include/cpdoccore/CPScopedPtr.h"
namespace cpdoccore {
@ -51,12 +52,15 @@ public:
// $Лист1.$A$1 -> Лист1!$A$1
std::wstring convert_named_ref(std::wstring const & expr, bool withTableName = true, std::wstring separator = L" ");
std::wstring get_table_name();
//a-la convert without check formula
std::wstring convert_named_expr(std::wstring const & expr, bool withTableName = true);
//Sheet2.C3:Sheet2.C19 -> Sheet2!C3:C19
std::wstring convert_chart_distance(std::wstring const & expr);
void split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out);
std::wstring convert_ref(std::wstring const & expr);
@ -87,9 +91,10 @@ public:
std::wstring convert_conditional_formula(std::wstring const & expr);
// Лист1!$A$1 -> $Лист1.$A$1
std::wstring convert_named_ref(std::wstring const & expr);
std::wstring convert_named_ref (std::wstring const & expr);
std::wstring convert_named_formula(std::wstring const & expr);
std::wstring find_base_cell(std::wstring const & expr);
std::wstring get_table_name();
//Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19
std::wstring convert_chart_distance(std::wstring const & expr);

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"
@ -43,10 +42,12 @@ namespace formulasconvert {
class odf2oox_converter::Impl
{
public:
static bool convert_with_TableName;
std::wstring convert(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr);
void split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out);
void replace_cells_range(std::wstring& expr, bool withTableName);
bool check_formula(std::wstring& expr);
void replace_semicolons(std::wstring& expr);
@ -57,11 +58,16 @@ namespace formulasconvert {
static std::wstring replace_named_ref_formater1(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_;
};
bool odf2oox_converter::Impl::convert_with_TableName = true;
bool odf2oox_converter::Impl::convert_with_TableName = true;
std::wstring odf2oox_converter::Impl::table_name_ = L"";
bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last)
{
@ -151,11 +157,20 @@ namespace formulasconvert {
std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L"");
table_name_ = sheet1;
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str();
if (convert_with_TableName)
{
if (std::wstring::npos != sheet1.find(L" "))
{
if (sheet1[0] != L'\'')
{
sheet1 = L"'" + sheet1 + L"'";
}
}
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c2) );
}
else
@ -172,15 +187,25 @@ namespace formulasconvert {
const std::wstring c2 = what[3].str(); //sheet name 2
const std::wstring c3 = what[4].str();
table_name_ = sheet1;
if (convert_with_TableName)
{
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c3) );
return (sheet1 + L"!") + c1 + (c3.empty() ? L"" : (L":" + c3) );
}
else
{
return c1 + (c3.empty() ? L"" : (L":" + c3) );
}
}
else if (sz == 5 && !what[1].matched)
{
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) );
}
return L"";
}
std::wstring odf2oox_converter::Impl::replace_named_ref_formater1(boost::wsmatch const & what)
@ -208,10 +233,10 @@ namespace formulasconvert {
void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr, bool withTableName)
{
convert_with_TableName = withTableName;
//boost::wregex simpleRef(L"\\[\\.([a-zA-Z]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
boost::wregex complexRef(L"\\[(?:\\$)?([^\\.]+?){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}[a-zA-Z]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}\\]");
/*
[ $ Sheet2 . A1 : . B5 ]
[ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
*/
const std::wstring res = boost::regex_replace(
@ -226,8 +251,8 @@ namespace formulasconvert {
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}([^\\.\\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}");
const std::wstring res = boost::regex_replace(
expr,
complexRef,
@ -263,15 +288,12 @@ namespace formulasconvert {
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
// заменить точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
// TODO: проверить как сохраняются кавычки в строке
void odf2oox_converter::Impl::replace_semicolons(std::wstring& expr)
{
const std::wstring res = boost::regex_replace(
@ -367,30 +389,37 @@ namespace formulasconvert {
}
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 forbidden_formulas[] =
//{
// L"NULLFORMULA"
// //L"BETADIST",
// //L"CEILING",
// //L"FLOOR",
// //L"RANK",
// //L"ROUND",
// //L"ROUNDDOWN",
// //L"ROUNDUP",
// //L"SUBTOTAL",
// //L"FORMULA",
// //L"ISREF"
//};
bool is_forbidden(const std::wstring & formula)
std::wstring is_forbidden(const std::wstring & formula)
{
BOOST_FOREACH(const std::wstring & s, forbidden_formulas)
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, s))
return true;
if (boost::algorithm::contains(formula, it->first))
{
XmlUtils::replace_all(result, it->first, it->second);
}
}
return false;
return result;
}
// заменить вертикальную черту во всех вхождениях в фигурных скобках, но не внутри строк
@ -416,10 +445,7 @@ namespace formulasconvert {
std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
{
if (is_forbidden(expr))
return L"NULLFORMULA()";
std::wstring workstr = 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,
@ -428,7 +454,7 @@ namespace formulasconvert {
// boost::match_default | boost::format_all);
bool isFormula = check_formula(workstr);
boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
@ -451,6 +477,12 @@ namespace formulasconvert {
}
//todooo INDEX((A1:C6~A8:C11),2,2,2) - ???? - INDEX_emb.ods
}
else
{
size_t sz_workstr = workstr.length();
if (workstr.substr(0, (std::min)((size_t)3, sz_workstr)) == L"of:")//sample_02neu_crashes.ods
workstr = workstr.substr(3);
}
//-----------------------------------------------------------
@ -470,16 +502,34 @@ namespace formulasconvert {
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(
expr,
complexRef,
&replace_point_space,
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".");
}
}
//Sheet2.C3:Sheet2.C19 Sheet2.L29:Sheet2.L36
//в
//Sheet2!C3:C19,Sheet2!L27:L34
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
{
if (is_forbidden(expr))
return L"NULLFORMULA()";
std::wstring workstr = is_forbidden(expr);
std::wstring workstr = expr;
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
@ -495,25 +545,27 @@ namespace formulasconvert {
boost::algorithm::split(distance_inp, workstr, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
BOOST_FOREACH(std::wstring &d,distance_inp)
for (size_t i = 0; i < distance_inp.size(); i++)
{
std::wstring sheet;
std::vector<std::wstring> range;
std::vector<std::wstring> cells;
boost::algorithm::split(range,d, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
boost::algorithm::split(range, distance_inp[i], boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
BOOST_FOREACH(std::wstring &c,range)
for (size_t j = 0; j < range.size(); j++)
{
const std::string::size_type colon = c.find('.');
cells.push_back(c.substr(colon+1));
if (sheet.size()<1)
sheet=c.substr(0, colon);
const std::string::size_type colon = range[j].find('.');
cells.push_back(range[j].substr(colon + 1));
if (sheet.size() < 1)
{
sheet = range[j].substr(0, colon);
}
}
std::wstring cells_out;
BOOST_FOREACH(std::wstring &c,cells)
for (size_t j = 0; j < cells.size(); j++)
{
cells_out.append(c);
cells_out.append(cells[j]);
cells_out.append(L":");
}
int res1 = sheet.find(L"-");
@ -524,19 +576,19 @@ namespace formulasconvert {
sheet = L"'" + sheet + L"'";
}
distance_out.push_back(sheet+L"!" + cells_out.substr(0, cells_out.size()-1));
distance_out.push_back(sheet + L"!" + cells_out.substr(0, cells_out.size()-1));
}
std::wstring result;
BOOST_FOREACH(std::wstring &d, distance_out)
for (size_t i = 0; i < distance_out.size(); i++)
{
result.append(d);
result.append(distance_out[i]);
result.append(L",");
}
XmlUtils::replace_all( result, L"PROBEL" , L" ");
XmlUtils::replace_all( result, L"TOCHKA" , L".");
XmlUtils::replace_all( result, L"TOCHKA", L".");
return result.substr(0, result.size()-1);// минус последняя лишняя запятая
return result.substr(0, result.size() - 1);// минус последняя лишняя запятая
}
odf2oox_converter::odf2oox_converter(): impl_(new odf2oox_converter::Impl)
{
@ -546,6 +598,11 @@ namespace formulasconvert {
{
}
std::wstring odf2oox_converter::get_table_name()
{
return impl_->table_name_;
}
std::wstring odf2oox_converter::convert(const std::wstring& expr)
{
return impl_->convert(expr);
@ -554,6 +611,10 @@ namespace formulasconvert {
{
return impl_->convert_chart_distance(expr);
}
void odf2oox_converter::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
{
return impl_->split_distance_by(expr, by, out);
}
std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
{
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
@ -577,34 +638,60 @@ namespace formulasconvert {
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;
}
std::wstring odf2oox_converter::convert_named_expr(const std::wstring& expr, bool withTableName)
{
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
std::wstring workstr = expr;
std::wstring workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
bool isFormula = impl_->check_formula(workstr);
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)
if (isFormula)
{
//могут быть частично заданы диапазоны
//todooo
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".");
}
}
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
return workstr;
}

View File

@ -43,6 +43,7 @@ namespace formulasconvert {
class oox2odf_converter::Impl
{
public:
std::wstring convert(const std::wstring& expr);
std::wstring convert_formula(const std::wstring& expr);
std::wstring convert_conditional_formula(const std::wstring& expr);
@ -59,93 +60,17 @@ public:
static std::wstring replace_arguments(boost::wsmatch const & what);
static std::wstring convert_scobci(boost::wsmatch const & what);
std::wstring replace_arguments1(std::wstring & workstr);
void replace_named_ref(std::wstring & expr);
void replace_named_formula(std::wstring & expr);
std::wstring find_base_cell(const std::wstring & expr);
static bool isFindBaseCell_;
// 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 std::wstring table_name_;
};
////Table!.$A$1:$A2 -> ref $A$1 -> ref $A$2
//bool oox2odf_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last)
//{
// std::vector< std::wstring > splitted;
//
// boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L".:"), boost::algorithm::token_compress_on);
//
// if (splitted.size()>2)
// {
// table = splitted[0];
// ref_first = splitted[1];
// ref_last = splitted[2];
// return true;
// }
// return false;
//}
// // =[.A1]+[.B1] -> table = ""; ref = "A1"
// // of:=['Sheet2 A'.B2] -> table= "Sheet2 A"; ref = "B2"
//
//bool oox2odf_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::wsmatch result;
// bool b = boost::regex_search(expr, result, re);
//
// size_t sz = result.size();
// if (sz == 4 && !result[1].matched)
// {
// table = L"";
// ref = result[2].str();
// return true;
// }
// else if (sz == 4 && result[1].matched)
// {
// table = result[1].str();
// XmlUtils::replace_all( table, L"$", L"");
// XmlUtils::replace_all( table, L"'", L"");
// ref = result[2].str();
// return true;
// }
// return false;
//}
//
//namespace
//{
//
//std::wstring 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();
// const std::wstring c2 = what[3].str();
// const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
// return s;
// }
// return L"";
//}
//
//}
//
// заменяем формат адресации ячеек НАОБОРОТ
// [.A1] -> A1
// [.A1:.B5] -> A1:B5
// [Sheet2.A1:B5] -> Sheet2!A1:B5
// [Sheet2.A1] -> Sheet2!A1
// [$'Sheet2 A'.$B2] -> 'Sheet2 A'!$B2
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
std::wstring oox2odf_converter::Impl::table_name_ = L"";
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
{
boost::wregex re(L"([:$!])+");
@ -155,8 +80,10 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
if (b)
{
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?");
// $ Sheet2 ! $ A1 : $ B5
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]*\\d*)\\:?([a-zA-Z$]*\\d*)?");
// $ Sheet2 ! $ A1 : $ B5
// $ Sheet2 ! $ A : $ A
// $ Sheet2 ! $ 1 : $ 1
std::wstring workstr = expr;
std::wstring res = boost::regex_replace(
@ -178,19 +105,28 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
{
const size_t sz = what.size();
if (sz>3)
if (sz > 3)
{
std::wstring sheet1 = what[1].matched ? what[1].str() : L"";
XmlUtils::replace_all( sheet1, L"!", L"");
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();
int res=0;
if (sheet1.length() > 0 && (res = c1.find(L"$")) >=0) sheet1 = L"$" + sheet1;
if (!c1.empty() || !c2.empty() || !sheet.empty())
{
XmlUtils::replace_all( sheet, L"!", L"");
const std::wstring s = std::wstring(L"[") + sheet1 + L"." +
c1 +
(c2.empty() ? L"" : (L":" + sheet1 + L"." + c2) ) + std::wstring(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 = std::wstring(L"[") + sheet + L"." +
c1 +
(c2.empty() ? L"" : (L":" + sheet + L"." + c2) ) + std::wstring(L"]");
}
return s;
}
else
@ -209,7 +145,7 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
{
const size_t sz = what.size();
if (sz>2)
if (sz > 2)
{
const std::wstring c1 = what[1].str();
const std::wstring c2 = what[2].str();
@ -222,39 +158,22 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
return L"";
}
//namespace {
//
//std::wstring replace_named_ref_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();
// const std::wstring c2 = what[3].str();
// const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
// return s;
// }
// return L"";
//}
//
//}
void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
{
table_name_.clear();
isFindBaseCell_ = true;
expr = convert_formula(expr);
isFindBaseCell_ = false;
}
// Лист1!$A$1 -> $Лист1.$A$1
void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
{
table_name_.clear();
isFindBaseCell_ = true;
std::wstring workstr = expr, out;
replace_vertical(workstr);
@ -264,8 +183,10 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
boost::algorithm::split(distance,workstr, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
BOOST_FOREACH(std::wstring &d, distance)
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");
@ -283,21 +204,18 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
out = out + d + std::wstring(L";");
}
if (out.length()>0) expr = out.substr(0,out.length()-1);
if (!out.empty()) expr = out.substr(0, out.length() - 1);
}
isFindBaseCell_ = false;
std::wstring oox2odf_converter::Impl::find_base_cell(const std::wstring & expr)
{
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L"!"), boost::algorithm::token_compress_on);
if (splitted.size()>1)
if (table_name_.empty() == false)
{
return splitted[0] + L".$A$1";
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"\"");
}
else return L"";
}
@ -440,32 +358,6 @@ std::wstring replace_(boost::wsmatch const & what)
return L"";
}
std::wstring oox2odf_converter::Impl::replace_arguments1(std::wstring & workstr1)
{
std::wstring out;
std::wstring workstr = workstr1;
replace_vertical(workstr);
replace_semicolons(workstr);
std::vector<std::wstring> distance;
boost::algorithm::split(distance,workstr, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
BOOST_FOREACH(std::wstring &d, distance)
{
replace_cells_range(d);
out = out + d + std::wstring(L";");
}
if (out.length()>0) out = out.substr(0,out.length()-1);
return out ;
}
std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
@ -506,33 +398,31 @@ std::wstring oox2odf_converter::Impl::replace_arguments(boost::wsmatch const &
int sz = what.size();
std::wstring c1= what[1].str();
std::wstring c2= what[2].str();
std::wstring c3= what[3].str();
if (what[1].matched)
{
std::wstring workstr = what[1].str();
replace_vertical(workstr);
replace_semicolons(workstr);
out = what[1].str();
}
else if (what[2].matched)
{
out = what[2].str();
}
if (!out.empty())
{
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, out, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
BOOST_FOREACH(std::wstring &d, distance)
{
replace_cells_range(d);
out = L"";
for (size_t i = 0; i < distance.size(); i++)
{
replace_cells_range(distance[i]);
out = out + d + std::wstring(L";");
out = out + distance[i] + std::wstring(L";");
}
if (out.length()>0) out = out.substr(0,out.length()-1);
if (!out.empty()) out = out.substr(0, out.length() - 1);
}
else if (what[2].matched)
out = what[2].str();
else if (what[3].matched)
out = what[3].str();
return out ;
@ -560,7 +450,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
std::wstring res = boost::regex_replace(
res1,
boost::wregex(L"(?:(?=[()])(.*?)(?=[)]))"),
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
if (res1 == res)
@ -572,10 +462,6 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::wregex(L"(\\$?\\w+\\!)?([a-zA-Z$]+\\d{1,})\\:?([a-zA-Z$]+\\d{1,})?"),
&replace_cells_range_formater1,
boost::match_default | boost::format_all);
replace_vertical(res);
replace_semicolons(res);
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
@ -584,12 +470,31 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
XmlUtils::replace_all( res, L"KVADRATIN", L"[");
XmlUtils::replace_all( res, L"KVADRATOUT", L"]");
XmlUtils::replace_all( res, L"PROBEL", L" ");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
replace_vertical(res);
replace_semicolons(res);
XmlUtils::replace_all( res, L"PROBEL", L" ");
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" ");
}
return std::wstring(L"of:=") + res;
}
@ -600,12 +505,12 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
std::wstring res1 = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&oox2odf_converter::Impl::convert_scobci,boost::match_default | boost::format_all);
&oox2odf_converter::Impl::convert_scobci, boost::match_default | boost::format_all);
std::wstring res = boost::regex_replace(
res1,
boost::wregex(L"(?:(?=[()])(.*?)(?=[)]))"),
&oox2odf_converter::Impl::replace_arguments,boost::match_default | boost::format_all);
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
if (res1 == res)
{
@ -614,20 +519,21 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
&replace_cells_range_formater1,
boost::match_default | boost::format_all);
replace_vertical(res);
replace_semicolons(res);
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
XmlUtils::replace_all( res, L"PROBEL", L" ");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
return res;
replace_vertical(res);
replace_semicolons(res);
XmlUtils::replace_all( res, L"PROBEL", L" ");
return res;
}
//Sheet2!C3:C19,Sheet2!L27:L34
@ -726,9 +632,15 @@ std::wstring oox2odf_converter::convert_named_ref(const std::wstring& expr)
impl_->replace_named_ref(workstr);
return workstr;
}
std::wstring oox2odf_converter::find_base_cell(const std::wstring& expr)
std::wstring oox2odf_converter::convert_named_formula(const std::wstring& expr)
{
return impl_->find_base_cell(expr);
std::wstring workstr = expr;
impl_->replace_named_formula(workstr);
return workstr;
}
std::wstring oox2odf_converter::get_table_name()
{
return impl_->table_name_;
}
@ -840,14 +752,6 @@ int oox2odf_converter::get_count_value_points(std::wstring expr)
return count;
}
//bool oox2odf_converter::find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref)
//{
// return impl_->find_first_ref(expr, table, ref);
//}
//bool oox2odf_converter::find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last)
//{
// return impl_->find_first_last_ref(expr, table, ref_first,ref_last);
//}
}
}

View File

@ -35,11 +35,15 @@
#include "../CPSharedPtr.h"
#include "../CPScopedPtr.h"
struct ProgressCallback;
namespace cpdoccore {
namespace xml
{
class sax;
}
namespace oox {
class docx_conversion_context;
class xlsx_conversion_context;
@ -54,9 +58,10 @@ class odf_document
{
public:
odf_document(const std::wstring & Folder, const ProgressCallback* CallBack);
~odf_document();
odf_document(xml::sax * Reader);
~odf_document();
public:
odf_read_context & odf_context();
bool docx_convert(oox::docx_conversion_context & Context);
@ -77,6 +82,7 @@ private:
_CP_SCOPED_PTR(Impl) impl_;
};
typedef shared_ptr<odf_document>::Type odf_document_ptr;
}
}

View File

@ -154,7 +154,7 @@ namespace cpdoccore
if (val)
{
std::wstring tmp = *val;
XmlUtils::GetLower(tmp);
tmp = XmlUtils::GetLower(tmp);
return optional<bool>::Type((tmp == xml_char_value_type::trueVal));
}
else

View File

@ -105,6 +105,7 @@ SOURCES += \
../src/odf/table_calculation_settings.cpp \
../src/odf/table_docx.cpp \
../src/odf/table_named_expressions.cpp \
../src/odf/table_data_pilot_tables.cpp \
../src/odf/table_pptx.cpp \
../src/odf/table_xlsx.cpp \
../src/odf/templates.cpp \
@ -209,6 +210,14 @@ SOURCES += \
../src/odf/datatypes/wrapoption.cpp \
../src/odf/datatypes/writingmode.cpp \
../src/odf/datatypes/xlink.cpp \
../src/odf/datatypes/chartlabelposition.cpp \
../src/odf/datatypes/grandtotal.cpp \
../src/odf/datatypes/membertype.cpp \
../src/odf/datatypes/tabletype.cpp \
../src/odf/datatypes/tableorientation.cpp \
../src/odf/datatypes/tablefunction.cpp \
../src/odf/datatypes/tableorder.cpp \
../src/odf/datatypes/dategroup.cpp \
../src/docx/xlsx_conditionalFormatting.cpp \
../src/docx/xlsx_dxfs.cpp \
../src/docx/docx_content_type.cpp \
@ -278,6 +287,7 @@ SOURCES += \
../src/docx/xlsx_table_metrics.cpp \
../src/docx/xlsx_table_state.cpp \
../src/docx/xlsx_textcontext.cpp \
../src/docx/xlsx_pivots_context.cpp \
../src/docx/xlsx_utils.cpp \
../src/docx/xlsx_xf.cpp
}
@ -462,6 +472,8 @@ HEADERS += \
../src/odf/datatypes/wrapoption.h \
../src/odf/datatypes/writingmode.h \
../src/odf/datatypes/xlink.h \
../src/odf/datatypes/chartlabelposition.h \
../src/odf/datatypes/grandtotal.h \
../src/docx/docx_content_type.h \
../src/docx/docx_conversion_context.h \
../src/docx/docx_conversion_state.h \
@ -543,7 +555,6 @@ HEADERS += \
../src/docx/xlsx_xf.h \
../include/logging.h \
../include/cpdoccore/CPColorUtils.h \
../include/cpdoccore/CPHash.h \
../include/cpdoccore/CPNoncopyable.h \
../include/cpdoccore/CPOptional.h \
../include/cpdoccore/CPScopedPtr.h \

View File

@ -88,6 +88,7 @@
#include "../src/odf/table_calculation_settings.cpp"
#include "../src/odf/table_docx.cpp"
#include "../src/odf/table_named_expressions.cpp"
#include "../src/odf/table_data_pilot_tables.cpp"
#include "../src/odf/table_pptx.cpp"
#include "../src/odf/table_xlsx.cpp"
#include "../src/odf/templates.cpp"

View File

@ -119,3 +119,11 @@
#include "../src/odf/datatypes/wrapoption.cpp"
#include "../src/odf/datatypes/writingmode.cpp"
#include "../src/odf/datatypes/xlink.cpp"
#include "../src/odf/datatypes/chartlabelposition.cpp"
#include "../src/odf/datatypes/grandtotal.cpp"
#include "../src/odf/datatypes/membertype.cpp"
#include "../src/odf/datatypes/tabletype.cpp"
#include "../src/odf/datatypes/tableorientation.cpp"
#include "../src/odf/datatypes/tablefunction.cpp"
#include "../src/odf/datatypes/tableorder.cpp"
#include "../src/odf/datatypes/dategroup.cpp"

View File

@ -100,3 +100,4 @@
#include "../src/docx/xlsx_textcontext.cpp"
#include "../src/docx/xlsx_utils.cpp"
#include "../src/docx/xlsx_xf.cpp"
#include "../src/docx/xlsx_pivots_context.cpp"

View File

@ -97,14 +97,6 @@ HRESULT ConvertOO2OOX(const std::wstring & srcPath, const std::wstring & dstPath
if (encrypted) return AVS_ERROR_DRM;
//if (type<1)
//{
// if (ext == L".odt")type = 1;
// if (ext == L".ods")type = 2;
// if (ext == L".odp")type = 3;
//}
if (bOnlyPresentation && type != 3)return AVS_ERROR_UNEXPECTED;
switch (type)

View File

@ -34,8 +34,6 @@
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include "docx_content_type.h"
#include "namespaces.h"
@ -86,14 +84,14 @@ std::wostream & content_type_content::xml_to_stream(std::wostream & _Wostream) c
CP_XML_ATTR(L"xmlns", xmlns::types.value);
BOOST_FOREACH(const xml::element_wc & elm, default_)
for (size_t i = 0; i < default_.size(); i++)
{
elm.xml_to_stream(CP_XML_STREAM());
default_[i].xml_to_stream(CP_XML_STREAM());
}
BOOST_FOREACH(const xml::element_wc & elm, override_)
for (size_t i = 0; i < override_.size(); i++)
{
elm.xml_to_stream(CP_XML_STREAM());
override_[i].xml_to_stream(CP_XML_STREAM());
}
}
}

View File

@ -96,7 +96,7 @@ void text_tracked_context::start_change (std::wstring id)
{
current_state_.clear();
current_state_.id = id;
current_state_.id = id;
}
void text_tracked_context::end_change ()
{
@ -378,7 +378,8 @@ void docx_conversion_context::start_document()
output_stream() << L"xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ";
output_stream() << L"xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ";
output_stream() << L"xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ";
output_stream() << L"xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ";
output_stream() << L"xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ";
output_stream() << L"xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ";
output_stream() << L"mc:Ignorable=\"w14 wp14\">";
@ -406,14 +407,12 @@ void docx_conversion_context::end_document()
output_document_->get_word_files().set_notes(notes_context_);
////////////////////////
int count = 0;
BOOST_FOREACH(const oox_chart_context_ptr& chart, charts_)
for (size_t i = 0; i < charts_.size(); i++)
{
count++;
package::chart_content_ptr content = package::chart_content::create();
chart->serialize(content->content());
chart->dump_rels(content->get_rel_file()->get_rels());
charts_[i]->serialize(content->content());
charts_[i]->dump_rels(content->get_rel_file()->get_rels());
output_document_->get_word_files().add_charts(content);
@ -580,10 +579,10 @@ mc:Ignorable=\"w14 wp14\">";
strm << L"</w:abstractNum>";
}
BOOST_FOREACH(int numId, numIds)
for (size_t i = 0; i < numIds.size(); i++)
{
strm << L"<w:num w:numId=\"" << numId << L"\" >";
strm << L"<w:abstractNumId w:val=\"" << numId << "\" />";
strm << L"<w:num w:numId=\"" << numIds[i] << L"\" >";
strm << L"<w:abstractNumId w:val=\"" << numIds[i] << "\" />";
strm << L"</w:num>";
}
@ -801,7 +800,7 @@ bool docx_conversion_context::process_page_properties(std::wostream & strm)
if (page_layout_instance_)
{
page_layout_instance_->docx_convert_serialize(strm, *this);
page_layout_instance_->docx_serialize(strm, *this);
}
else
{
@ -1286,7 +1285,8 @@ void docx_conversion_context::start_text_changes (std::wstring id)
L" w:author=\"" + state.author + L"\"" ;
finish_run();
state.active = true;
state.active = true;
state.in_drawing = get_drawing_state_content();
if (state.type == 1)
{
@ -1420,6 +1420,9 @@ void docx_conversion_context::end_changes()
if (state.type == 0) continue; //unknown change ... libra format change skip
if (state.type == 3) continue;
if (!state.active) continue;
if (state.in_drawing != get_drawing_state_content())
continue;
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";

View File

@ -224,8 +224,9 @@ public:
bool & get_use_image_replace()
{
bool res = false;
if (frames_.size()>0) return frames_.back().use_image_replace;
else return res;
if (!frames_.empty()) return frames_.back().use_image_replace;
else
throw;
}
std::wstring & get_text_stream_shape()
@ -492,10 +493,11 @@ public:
std::wstring id;
std::wstring author;
std::wstring date;
int type;
int type = 0;
std::wstring style_name;
std::vector<std::wstring> content; //delete elements
bool active;
bool active = false;
bool in_drawing = false;
void clear()
{
@ -505,6 +507,7 @@ public:
date.clear();
content.clear();
active = false;
in_drawing = false;
}
};
std::wstring dumpPPr_;

View File

@ -392,8 +392,11 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
{
CP_XML_NODE(L"wp:extent")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
if (val.cx > 0 || val.cy > 0)
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
serialize_null_extent(CP_XML_STREAM());
}
@ -463,10 +466,13 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
}
}
}
CP_XML_NODE(L"wp:extent")
if (val.cx > 0 || val.cy > 0)
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
CP_XML_NODE(L"wp:extent")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
}
serialize_wrap(CP_XML_STREAM(), val);

View File

@ -30,6 +30,7 @@
*
*/
#include <boost/foreach.hpp>
#include "docx_package.h"
#include "docx_conversion_context.h"
@ -218,26 +219,25 @@ void docx_charts_files::write(const std::wstring & RootPath)
size_t count = 0;
BOOST_FOREACH(const chart_content_ptr & item, charts_)
for (int i = 0 ; i < charts_.size(); i++)
{
if (item)
{
count++;
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();
contentTypes->add_override(std::wstring(L"/word/charts/") + fileName, kWSConType);
if (!charts_[i]) continue;
count++;
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();
contentTypes->add_override(std::wstring(L"/word/charts/") + fileName, kWSConType);
package::simple_element(fileName, item->str()).write(path);
rels_files relFiles;
package::simple_element(fileName, charts_[i]->str()).write(path);
rels_files relFiles;
item->get_rel_file()->set_file_name(fileName + L".rels");
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
}
charts_[i]->get_rel_file()->set_file_name(fileName + L".rels");
relFiles.add_rel_file(charts_[i]->get_rel_file());
relFiles.write(path);
}
}
///////////////////////////
@ -319,6 +319,7 @@ namespace
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" >";
//mc:Ignorable=\"w14 wp14\"

View File

@ -33,7 +33,6 @@
#include <string>
#include <vector>
#include <boost/foreach.hpp>
#include <cpdoccore/CPSharedPtr.h>

View File

@ -32,7 +32,6 @@
#include "docx_conversion_context.h"
#include "logging.h"
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/odf/odf_document.h>
#include "../odf/odfcontext.h"

View File

@ -33,9 +33,6 @@
#include "hyperlinks.h"
#include "oox_rels.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/xml/utils.h>
namespace cpdoccore {

View File

@ -181,7 +181,11 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
sub_path = L"embeddings/";
}
else
{
isMediaInternal = is_internal(href, odf_packet_);
if (href.empty() && type == typeImage)
return L"";
}
int number=0;
@ -205,9 +209,9 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
if ( type == typeChart) outputPath = outputPath + L".xml";
std::wstring id;
for (int i = 0 ; i < items_.size(); i++)
for (size_t i = 0 ; i < items_.size(); i++)
{
if (items_[i].href == inputPath)
if ((items_[i].href == inputPath && !inputPath.empty()) || (items_[i].type == type && inputPath.empty()))
{
id = items_[i].Id;
outputPath = items_[i].outputName;
@ -235,7 +239,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
outputPath = outputPath.substr(0, n_svm) + L".png";
}
//------------------------------------------------
if (inputFileName.empty()) return L"";
//if (inputFileName.empty()) return L""; - Book 27.ods - пустые линки на картинки
id = std::wstring(L"picId") + std::to_wstring(count_image + 1);
count_image++;

View File

@ -127,6 +127,7 @@ public:
if (sExt == L"m4v") return typeVideo;
if (sExt == L"mp4") return typeVideo;
if (sExt == L"mov") return typeVideo;
if (sExt == L"mkv") return typeVideo;
return typeMedia;
}

View File

@ -31,10 +31,8 @@
*/
#include "oox_chart_axis.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include "oox_title.h"
#include "oox_chart_shape.h"
@ -181,18 +179,18 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
}
}
BOOST_FOREACH(odf_reader::chart::axis::grid & g, content_.grids_)
for (size_t i = 0; i < content_.grids_.size(); i++)
{
_oox_fill fill_null;
shape.set(g.graphic_properties_, fill_null);
shape.set(content_.grids_[i].graphic_properties_, fill_null);
if (g.type_ == odf_reader::chart::axis::grid::major)
if (content_.grids_[i].type_ == odf_reader::chart::axis::grid::major)
{
CP_XML_NODE(L"c:majorGridlines")
{
shape.oox_serialize(CP_XML_STREAM());
}
odf_reader::GetProperty(content_.properties_,L"display_label",boolVal);
odf_reader::GetProperty(content_.properties_, L"display_label", boolVal);
if ((boolVal == true) && (boolVal.get()==true))
{
CP_XML_NODE(L"c:majorTickMark")
@ -201,7 +199,7 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
}
}
}
if (g.type_ == odf_reader::chart::axis::grid::minor)
if (content_.grids_[i].type_ == odf_reader::chart::axis::grid::minor)
{
CP_XML_NODE(L"c:minorGridlines")
{
@ -234,11 +232,11 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
oox_serialize_default_text(_Wostream, content_.text_properties_);
BOOST_FOREACH(int const & ii, cross_id_)
for (size_t i = 0; i < cross_id_.size(); i++)
{
CP_XML_NODE(L"c:crossAx")
{
CP_XML_ATTR(L"val", ii);
CP_XML_ATTR(L"val", cross_id_[i]);
}
}

View File

@ -118,6 +118,23 @@ void oox_chart_context::serialize(std::wostream & strm)
{
CP_XML_ATTR(L"val",L"en-US");
}
if (pivot_source_.empty() == false)
{
set_cache_only(true);
CP_XML_NODE(L"c:pivotSource")
{
CP_XML_NODE(L"c:name")
{
CP_XML_STREAM() << pivot_source_;
}
CP_XML_NODE(L"c:fmtId")
{
CP_XML_ATTR(L"val", 0);
}
}
}
CP_XML_NODE(L"c:chart")
{
if (plot_area_.current_chart_->is3D_)
@ -148,10 +165,42 @@ void oox_chart_context::serialize(std::wostream & strm)
shape.set(graphic_properties_, fill_);
shape.oox_serialize(CP_XML_STREAM());
if (pivot_source_.empty() == false)
{
CP_XML_NODE(L"c:extLst")
{
CP_XML_NODE(L"c:ext")
{
CP_XML_ATTR(L"uri", L"{781A3756-C4B2-4CAC-9D66-4F8BD8637D16}");
CP_XML_ATTR(L"xmlns:c14", L"http://schemas.microsoft.com/office/drawing/2007/8/2/chart");
CP_XML_NODE(L"c14:pivotOptions")
{
CP_XML_NODE(L"c14:dropZoneFilter")
{
CP_XML_ATTR(L"val", 1);
}
CP_XML_NODE(L"c14:dropZoneCategories")
{
CP_XML_ATTR(L"val", 1);
}
CP_XML_NODE(L"c14:dropZoneData")
{
CP_XML_ATTR(L"val", 1);
}
CP_XML_NODE(L"c14:dropZoneSeries")
{
CP_XML_ATTR(L"val", 1);
}
CP_XML_NODE(L"c14:dropZonesVisible")
{
CP_XML_ATTR(L"val", 1);
}
}
}
}
}
}
}
}
oox_chart_context::~oox_chart_context()
@ -160,7 +209,7 @@ oox_chart_context::~oox_chart_context()
void oox_chart_context::set_cache_only (bool val)
{
for (int i = 0 ; i < plot_area_.charts_.size(); i++)
for (size_t i = 0 ; i < plot_area_.charts_.size(); i++)
{
plot_area_.charts_[i]->set_cache_only(val);
}

View File

@ -63,6 +63,10 @@ public:
void serialize(std::wostream & strm);
void dump_rels(rels & Rels);
void set_pivot_chart(const std::wstring &source)
{
pivot_source_ = source;
}
void set_title(odf_reader::chart::title & t)
{
title_.set_content(t);
@ -130,6 +134,8 @@ private:
cpdoccore::oox::oox_plot_area plot_area_;
cpdoccore::oox::oox_chart_legend legend_;
std::wstring pivot_source_;
std::vector<odf_reader::_property> graphic_properties_;
_oox_fill fill_;
};

View File

@ -31,9 +31,8 @@
*/
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "oox_chart_legend.h"

View File

@ -37,6 +37,8 @@
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/style_text_properties.h"
#include "xlsx_utils.h"
#include "oox_chart_series.h"
#include "../formulasconvert/formulasconvert.h"
@ -55,6 +57,7 @@ oox_chart_series::oox_chart_series()
iSymbolMarkerType_ = 0;
bLocalTable_ = false;
labelPosEnabled_ = true;
}
void oox_chart_series::setName(std::wstring &value)
{
@ -67,8 +70,7 @@ void oox_chart_series::setFormula(int ind, std::wstring &value, std::wstring & f
if (ind == 0)
{
long res = value.find(L"local-table");
if (res >=0) return;
if (std::wstring::npos != value.find(L"local-table")) return;
values_[ind].strRef_.formula = converter.convert_chart_distance(value);
values_[ind].strRef_.present = true;
@ -76,8 +78,8 @@ void oox_chart_series::setFormula(int ind, std::wstring &value, std::wstring & f
}
else
{
long res = value.find(L"local-table");
if (res >=0 && !bLocalTable_ ) return; //в xlsx низя .... нужно сделать тогда отдельную table.xml
if (std::wstring::npos != value.find(L"local-table") && !bLocalTable_ ) return;
//в xlsx низя .... нужно сделать тогда отдельную table.xml
values_[ind].numRef_.formula = converter.convert_chart_distance(value);
values_[ind].numRef_.present = true;
@ -124,6 +126,7 @@ void oox_chart_series::parse_properties()
data_labels_->set_showCatName(*boolVal);
}
odf_reader::GetProperty(content_.properties_, L"data-label-number", intVal);
if (intVal)
{
if (!data_labels_) data_labels_ = oox_data_labels();
@ -131,6 +134,13 @@ void oox_chart_series::parse_properties()
if (*intVal == 1) data_labels_->set_showVal(true);
if (*intVal == 2) data_labels_->set_showPercent(true);
}
odf_reader::GetProperty(content_.properties_, L"label-position", intVal);
if (intVal && labelPosEnabled_)
{
if (!data_labels_) data_labels_ = oox_data_labels();
data_labels_->set_position(*intVal);
}
}
void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values)
{
@ -210,12 +220,24 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
shape.set(content_.graphic_properties_, content_.fill_);
shape.oox_serialize(_Wostream);
for (int i=0; i < 5; i++)
for (int i = 0; i < 5; i++)
{
if (values_[i].present)
{
if (bLocalTable_)
{
if (values_[i].numRef_.present && values_[i].numRef_.num_cache_count == 0)
{
continue;
}
if (values_[i].strRef_.present && values_[i].strRef_.str_cache_count == 0 )
{
continue;
}
}
CP_XML_NODE(values_[i].type)
{
if (values_[i].numRef_.present && !bLocalTable_)
{
CP_XML_NODE(L"c:numRef")
@ -250,8 +272,11 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
CP_XML_ATTR(L"idx", j);
double val = 0;
try { val = boost::lexical_cast<double>(v);}
catch(...){}
if (oox::IsNumber(v))
{
try { val = boost::lexical_cast<double>(v);}
catch(...){}
}
CP_XML_NODE(L"c:v")
{
CP_XML_CONTENT(val);
@ -285,8 +310,11 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
CP_XML_ATTR(L"idx", j);
double val = 0;
try { val = boost::lexical_cast<double>(v);}
catch(...){}
if (oox::IsNumber(v))
{
try { val = boost::lexical_cast<double>(v);}
catch(...){}
}
CP_XML_NODE(L"c:v")
{
CP_XML_CONTENT(val);

View File

@ -55,6 +55,7 @@ public:
virtual void oox_serialize(std::wostream & _Wostream) = 0;
bool labelPosEnabled_;
_oox_chart_values values_[5]; //cat(labels), common, x, y, bubble,
int id_;
std::wstring name_; //tx (Series Text) §21.2.2.215

View File

@ -29,9 +29,8 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "oox_chart_shape.h"

View File

@ -32,7 +32,6 @@
#include "oox_conversion_context.h"
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/odf/odf_document.h>
@ -145,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
namespace oox
{
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :
base_font_size_(12), fonts_container_(fonts)
base_font_size_(12), fonts_container_(fonts), is_need_e_(false)
{
graphRPR_ = graphic;

View File

@ -106,6 +106,8 @@ namespace oox {
std::wstring nsRPr_;
bool graphRPR_;
bool is_need_e_;
private:
std::wstringstream math_stream_;
std::wstringstream math_style_stream_;

View File

@ -31,14 +31,12 @@
*/
#include <cpdoccore/CPHash.h>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "oox_data_labels.h"
#include "oox_chart_shape.h"
#include <boost/foreach.hpp>
namespace cpdoccore {
namespace oox {
@ -51,6 +49,8 @@ oox_data_labels::oox_data_labels()//подписи на значениях
showPercent_ = false;
showSerName_ = false;
showVal_ = false;
position_ = -1; //not set
}
void oox_data_labels::set_common_dLbl ( std::vector<odf_reader::_property> & text_properties)
@ -107,6 +107,29 @@ void oox_data_labels::oox_serialize(std::wostream & _Wostream)
}
}
}
if (position_ >= 0 && position_ < 13)
{
CP_XML_NODE(L"c:dLblPos")
{
switch (position_)
{
case 0: CP_XML_ATTR(L"val", L"bestFit");break;
case 1: CP_XML_ATTR(L"val", L"b"); break;
case 2: CP_XML_ATTR(L"val", L"b"); break;
case 3: CP_XML_ATTR(L"val", L"b"); break;
case 6: CP_XML_ATTR(L"val", L"l"); break;
case 7: CP_XML_ATTR(L"val", L"inBase"); break;
case 9: CP_XML_ATTR(L"val", L"r"); break;
case 10: CP_XML_ATTR(L"val", L"t"); break;
case 11: CP_XML_ATTR(L"val", L"t"); break;
case 12: CP_XML_ATTR(L"val", L"t"); break;
case 5: //CP_XML_ATTR(L"val", L"inEnd"); break;
case 8: //CP_XML_ATTR(L"val", L"outEnd"); break;
case 4: CP_XML_ATTR(L"val", L"ctr"); break;
}
}
}
CP_XML_NODE(L"c:showLegendKey")
{

View File

@ -59,8 +59,10 @@ public:
void set_showSerName (bool Val){showSerName_ = Val;}
void set_showVal (bool Val){showVal_ = Val;}
void add_dLbl(int ind, std::vector<odf_reader::_property> & text_properties);
void set_common_dLbl ( std::vector<odf_reader::_property> & text_properties);
void set_position (int Val){position_ = Val;}
void add_dLbl (int ind, std::vector<odf_reader::_property> & text_properties);
void set_common_dLbl ( std::vector<odf_reader::_property> & text_properties);
private:
@ -72,6 +74,8 @@ private:
bool showSerName_; // (Show Series Name) §21.2.2.188
bool showVal_; // (Show Value) §21.2.2.189
int position_;
std::vector<odf_reader::_property> textPr_;
std::map<int, std::vector<odf_reader::_property>> dLbls_;

View File

@ -171,7 +171,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
if ( color.empty() )
{
if (always_draw) color = L"000000";
else color = L"ffffff";
else color = L"FFFFFF";
}
CP_XML_NODE(L"a:srgbClr")
@ -210,16 +210,15 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
}
}
}
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:avLst")
{
_CP_OPT(bool) bModifiers;
_CP_OPT(std::wstring) strModifiers;
odf_reader::GetProperty(prop, L"bModifiers", bModifiers);
odf_reader::GetProperty(prop, L"oox-draw-modifiers", strModifiers);
if (strModifiers)
{
std::vector< std::wstring > values;
@ -227,17 +226,61 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
if (!values.empty() && values.back().empty()) values.pop_back();
std::vector<std::wstring> names;
if (std::wstring::npos != shapeGeomPreset.find(L"math") ||
std::wstring::npos != shapeGeomPreset.find(L"bentConnector") ||
std::wstring::npos != shapeGeomPreset.find(L"curvedConnector")||
std::wstring::npos != shapeGeomPreset.find(L"frame"))
{
names.push_back(L"adj1");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
{
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
{
names.push_back(L"hf");
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"hexagon"))
{
names.push_back(L"adj");
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"star5")||
std::wstring::npos != shapeGeomPreset.find(L"star7"))
{
names.push_back(L"adj");
names.push_back(L"hf");
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"star6") ||
std::wstring::npos != shapeGeomPreset.find(L"star10"))
{
names.push_back(L"adj");
names.push_back(L"hf");
}
for (size_t i = 0; i < values.size(); i++)
{
if (values[i].empty()) continue;
CP_XML_NODE(L"a:gd")
{
if (values.size() > 1 || bModifiers)
//весьма странное .. для некоторых модификаторов (напр math...) нужно указывать множественность их
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i+1));
if (names.size() > i)
{
CP_XML_ATTR(L"name", names[i]);
}
else
CP_XML_ATTR(L"name", L"adj");
{
if (values.size() > 1)
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i + 1));
else
CP_XML_ATTR(L"name", L"adj");
}
CP_XML_ATTR(L"fmla", L"val " + values[i]);
}
}
@ -263,8 +306,8 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
odf_reader::GetProperty(prop,L"text-padding-bottom" , dPaddingBottom);
if (dPaddingLeft) CP_XML_ATTR(L"lIns", (int)(*dPaddingLeft));
if (dPaddingRight) CP_XML_ATTR(L"rIns", (int)(*dPaddingRight));
if (dPaddingTop) CP_XML_ATTR(L"tIns", (int)(*dPaddingTop));
if (dPaddingRight) CP_XML_ATTR(L"rIns", (int)(*dPaddingRight));
if (dPaddingBottom) CP_XML_ATTR(L"bIns", (int)(*dPaddingBottom));
if (inGroup == false)
@ -321,7 +364,8 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
CP_XML_NODE(L"a:prstTxWarp")
{
CP_XML_ATTR(L"prst", shapeType);
oox_serialize_aLst(CP_XML_STREAM(), prop);
oox_serialize_aLst(CP_XML_STREAM(), prop, shapeType);
}
}
}
@ -370,7 +414,8 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
{
CP_XML_NODE(L"a:custGeom")
{
oox_serialize_aLst(CP_XML_STREAM(), additional);
std::vector<std::wstring> names;
oox_serialize_aLst(CP_XML_STREAM(), additional, L"");
CP_XML_NODE(L"a:ahLst");
CP_XML_NODE(L"a:gdLst");
@ -391,8 +436,14 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : cy);
int path_w = w ? *w : cx;
int path_h = h ? *h : cy;
if (path_w < 1) path_w = 1024;
if (path_h < 1) path_h = 1024;
CP_XML_ATTR(L"w", path_w);
CP_XML_ATTR(L"h", path_h);
if (sCustomPath)
{
@ -414,11 +465,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
CP_XML_ATTR(L"prst", shapeGeomPreset);
if (!bWordArt)
{
if (std::wstring::npos != shapeGeomPreset.find(L"mathPlus"))
{
additional.push_back(odf_reader::_property(L"bModifiers", true));
}
oox_serialize_aLst(CP_XML_STREAM(), additional);
oox_serialize_aLst(CP_XML_STREAM(), additional, shapeGeomPreset);
}
}
}
@ -508,10 +555,13 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
CP_XML_ATTR(L"x", 0);
CP_XML_ATTR(L"y", 0);
}
CP_XML_NODE(L"a:chExt")
if (cx > 0 || cy > 0)
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
CP_XML_NODE(L"a:chExt")
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
}
}
}
}
@ -525,9 +575,6 @@ void oox_serialize_action(std::wostream & strm, _action_desc const & val)
{
CP_XML_NODE(L"a:hlinkClick")
{
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
if (!val.action.empty())
CP_XML_ATTR(L"action", val.action);
@ -544,6 +591,8 @@ void oox_serialize_action(std::wostream & strm, _action_desc const & val)
CP_XML_ATTR(L"name", L"sound");
}
}
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
}
}
}

View File

@ -83,7 +83,7 @@ namespace oox {
class _oox_drawing
{
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object")
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object"), extExternal(false)
{
}
RelsType type;
@ -103,6 +103,7 @@ namespace oox {
std::wstring objectProgId;
std::wstring extId;
bool extExternal;
_action_desc action;
std::vector<_hlink_desc> hlinks;
@ -118,7 +119,7 @@ namespace oox {
typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset);
void oox_serialize_action (std::wostream & strm, const _action_desc & val);
}

View File

@ -37,7 +37,7 @@
namespace cpdoccore {
namespace oox {
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false),bTile(false),isInternal(true)
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
{
memset(cropRect,0,sizeof(double)*4);
}
@ -186,10 +186,10 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
CP_XML_NODE(L"a:srcRect")
{
CP_XML_ATTR(L"l", static_cast<size_t>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<size_t>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<size_t>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<size_t>(val.bitmap->cropRect[3]*1000));
CP_XML_ATTR(L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
}
}
if (val.bitmap->bTile)

View File

@ -147,6 +147,6 @@ namespace oox {
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity);
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val);
}
}

View File

@ -31,9 +31,8 @@
*/
#include "oox_layout.h"
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/style_text_properties.h"

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