Compare commits

...

222 Commits

Author SHA1 Message Date
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
ccc4d751d0 Merge remote-tracking branch 'origin/hotfix/v4.4.2' into develop 2017-07-06 15:40:57 +03:00
a020d3dbf9 PptxFormat - fix audio wav files, fix old standart ole
XlsFormat - fix custom shape with connectors
2017-07-06 15:40:10 +03:00
7852b7fbe8 . 2017-07-06 15:35:14 +03:00
a64fd8792d Fixed build error 2017-07-06 12:19:50 +03:00
32448298a3 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  OdfFormatReader - fix spreadsheets margins PptFormatReader - fix previous users picture, fix read picture stream version up
  XlsFormat - convert pivot tables
  debug
  .
  .
2017-07-05 15:35:54 +03:00
b3384f1466 chart-settings seralize 2017-07-05 15:35:46 +03:00
93274395a9 . 2017-07-05 13:55:37 +03:00
2726e14445 Merge remote-tracking branch 'origin/hotfix/v4.4.2' into develop 2017-07-05 13:46:05 +03:00
75e32a1562 OdfFormatReader - fix spreadsheets margins
PptFormatReader - fix previous users picture, fix read picture stream
version up
2017-07-05 13:44:50 +03:00
8c2637b89c Merge tag 'v4.4.1' into develop
v4.4.1
2017-07-05 11:48:04 +03:00
ef389872df Merge branch 'release/v4.4.1' 2017-07-05 11:47:48 +03:00
6fc611fdfc XlsFormat - convert pivot tables 2017-07-04 18:50:39 +03:00
0cabb63336 debug 2017-07-04 13:54:52 +03:00
f501bf7930 remove curl for ios 2017-07-04 11:52:23 +03:00
7b617dc9e9 fix curl path 2017-07-04 10:40:26 +03:00
245f989ae3 XlsFormat... 2017-07-03 19:27:46 +03:00
429729b979 remade build.bat 2017-07-03 18:17:49 +03:00
d709652992 debug 2017-07-03 17:01:02 +03:00
776d799fd2 Debug 2017-07-03 16:50:49 +03:00
a975cb8261 Merge pull request #32 from ONLYOFFICE/feature/lenas-fixes
Feature/lenas fixies
2017-07-03 16:36:04 +03:00
c932b5af26 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  XlsFormat - convert pivot tables view
  Added scripts for fetching and building curl
  Removed curl sources
  refactoring
  refactoring
  XlsFormat ...
  XlsFormat ...
  .
  .
  .
  .
  min command length
  XlsFormat - convert piot cache
  x2t - return error code by PptConvert
  memset before readlink.
2017-07-03 16:06:14 +03:00
423e8dda86 chart-settings seralize 2017-07-03 16:06:02 +03:00
afcf6b079e . 2017-07-03 15:56:21 +03:00
3ed2224f93 . 2017-07-03 15:56:08 +03:00
5307855120 XlsFormat - convert pivot tables view 2017-07-03 15:10:00 +03:00
3c9a91af45 Added scripts for fetching and building curl 2017-07-03 14:46:56 +03:00
9f06f94c93 Removed curl sources 2017-07-03 12:45:30 +03:00
4954ef2934 refactoring 2017-07-03 10:27:49 +03:00
721e8800f1 refactoring 2017-07-03 10:27:23 +03:00
ef8e5cab6d XlsFormat ... 2017-07-02 17:49:41 +03:00
028e58ad51 XlsFormat ... 2017-07-02 13:18:56 +03:00
424e0e34cc . 2017-07-01 17:56:12 +03:00
d8988cd101 . 2017-07-01 16:33:36 +03:00
440a884c0a . 2017-07-01 14:38:46 +03:00
449bab1a70 . 2017-06-30 19:42:25 +03:00
c1e5e33691 min command length 2017-06-30 17:30:03 +03:00
8c7515443a Merge remote-tracking branch 'origin/release/v4.4.1' into develop 2017-06-30 16:56:51 +03:00
1d16f4ab8f XlsFormat - convert piot cache 2017-06-30 16:55:37 +03:00
122a5cd056 x2t - return error code by PptConvert 2017-06-30 16:21:07 +03:00
b0994759e7 memset before readlink. 2017-06-30 15:02:21 +03:00
118f1c5736 . 2017-06-30 12:51:08 +03:00
b65703ceb1 . 2017-06-30 12:22:45 +03:00
c08c960c96 . 2017-06-30 12:22:37 +03:00
02ece25af8 . 2017-06-30 10:15:08 +03:00
435a27f6d9 Merge remote-tracking branch 'origin/release/v4.4.1' into develop 2017-06-29 19:26:31 +03:00
85ea22048a fix bug #35120 2017-06-29 19:25:23 +03:00
87ae0b38fa XlsFormat - read pivot cache stream 2017-06-29 19:05:45 +03:00
b93d463469 OdfFormat - fix roundRect 2017-06-29 12:43:05 +03:00
0aa59b0d92 debug build 2017-06-28 19:05:05 +03:00
3dbcce8c36 . 2017-06-28 18:39:37 +03:00
cc9459359f Merge remote-tracking branch 'origin/release/v4.4.1' into develop 2017-06-28 18:38:01 +03:00
465e70759b fix connectors in spreadsheets 2017-06-28 18:36:04 +03:00
9f6c833af5 Update Readme.md
ru -> en
2017-06-28 17:18:38 +03:00
f4d16b0d61 Merge remote-tracking branch 'origin/release/v4.4.1' into develop 2017-06-28 16:02:58 +03:00
398dc42bb2 . 2017-06-28 16:01:58 +03:00
69b4a09475 builder bugs 2017-06-28 14:23:32 +03:00
ab360be66a Merge commit 'bab6e40c2b2267c9cec4c167c93361b2fafe7e8d' into develop 2017-06-28 13:18:36 +03:00
98285c225d Merge branch 'release/v4.4.1' of https://github.com/ONLYOFFICE/core into release/v4.4.1 2017-06-28 13:16:56 +03:00
bab6e40c2b fix bug #34984 2017-06-28 13:14:19 +03:00
539cb2f355 Merge remote-tracking branch 'origin/release/v4.4.1' into develop 2017-06-28 12:25:53 +03:00
64d6c3c872 . 2017-06-28 12:22:01 +03:00
7c9be7e2eb XlsFormat ... 2017-06-27 18:53:40 +03:00
bad2992903 . 2017-06-27 16:41:22 +03:00
d405cd4e83 XlsFormat ... 2017-06-27 16:33:25 +03:00
f632855006 . 2017-06-27 15:30:38 +03:00
48641d5bde XlsFormat - .. 2017-06-27 14:56:22 +03:00
d88ae6d3f4 . 2017-06-27 14:48:17 +03:00
e9ad1202ff Merge remote-tracking branch 'origin/release/v4.4.1' into develop 2017-06-27 13:29:59 +03:00
1fc9280ab3 . 2017-06-27 13:26:52 +03:00
9e639ec68f fix convert meta image to raster 2017-06-27 13:01:18 +03:00
28ebf5aaa6 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  XlsFormat - connections records
  "60% - Accent1 2" -> "60% - Accent1"
  .
  x2t version up 2.4.466
  XlsFormat - external data records
  Decryptors ... small refactoring
  moveRange
  moveFrom/moveTo open/save
  .
  PptFormatReader - decrypt ppt images
  .
  PprFormatReader - read encrypted files
  x14:conditionalFormatting DxfId starts from 0
2017-06-26 19:19:13 +03:00
8f5967356d up 2017-06-26 19:17:29 +03:00
bc7d73667d XlsFormat - connections records 2017-06-26 17:52:14 +03:00
a434ae2cc4 "60% - Accent1 2" -> "60% - Accent1" 2017-06-26 17:11:36 +03:00
7e52ebca48 . 2017-06-26 11:39:52 +03:00
4925b47002 x2t version up 2.4.466 2017-06-26 10:50:00 +03:00
afdaacb226 XlsFormat - external data records 2017-06-25 15:56:46 +03:00
9f98f07f23 Decryptors ... small refactoring 2017-06-25 14:20:14 +03:00
9e1a0e365f moveRange 2017-06-24 16:36:18 +03:00
39e2b69b8e moveFrom/moveTo open/save 2017-06-24 16:17:44 +03:00
58c00745a7 . 2017-06-24 16:02:47 +03:00
4015e8ba4d PptFormatReader - decrypt ppt images 2017-06-24 15:46:38 +03:00
276af55699 . 2017-06-24 13:02:46 +03:00
ebdfcbd7ee PprFormatReader - read encrypted files 2017-06-23 19:50:43 +03:00
867c09c85d x14:conditionalFormatting DxfId starts from 0 2017-06-23 19:26:03 +03:00
cd12777c68 up 2017-06-22 18:27:00 +03:00
0708c1f45a . 2017-06-22 12:32:00 +03:00
ee577e629a DocFormat - fix user file 2017-06-21 19:50:02 +03:00
f230dc2555 add binary test (file as resource) 2017-06-21 18:36:06 +03:00
11c9d74e68 fix bug #35161 2017-06-21 17:16:00 +03:00
d61a955c38 . 2017-06-20 19:04:55 +03:00
acfb96e3c3 . 2017-06-20 17:53:11 +03:00
d2e3cc47f2 . 2017-06-20 17:16:27 +03:00
4f2f164af9 XlsFormat - pivot tables records 2017-06-20 14:09:53 +03:00
8addd6cb04 XlsFormat - pivot table records 2017-06-20 12:50:57 +03:00
92cda5bc80 fix bug #35146 2017-06-20 12:48:48 +03:00
1a377d8738 . 2017-06-20 10:53:21 +03:00
ed3e107db5 XlsFormatReader - pivot tables records 2017-06-19 19:31:46 +03:00
64d8c659bc . 2017-06-19 13:20:19 +03:00
3debba45b8 . 2017-06-19 12:05:14 +03:00
b8ad1797f0 PpfFormat - read crypted files
RC4 CryptoAPI encrypting
2017-06-16 16:33:09 +03:00
48587f55b3 . 2017-06-16 15:17:31 +03:00
a505ae391d verify cert (openssl only) 2017-06-16 15:07:35 +03:00
c389801937 . 2017-06-15 14:26:43 +03:00
24214cb561 . 2017-06-15 12:58:07 +03:00
b19191b286 openssl signing bugs 2017-06-15 11:13:18 +03:00
77f8ab6875 . 2017-06-14 19:04:46 +03:00
6fc6f9ead3 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-06-14 18:50:53 +03:00
270c1fa2ac . 2017-06-14 18:39:13 +03:00
f76a03fab8 openssl signing bugs 2017-06-14 18:09:28 +03:00
09e6d3f760 XlsFormat - read pivot table records 2017-06-14 17:31:57 +03:00
3607 changed files with 24374 additions and 537129 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

@ -58,7 +58,7 @@
#include <boost/format.hpp>
namespace DocFormatUtils
namespace DocFileFormat
{
typedef unsigned char Bool8;
typedef unsigned short Bool16;
@ -963,4 +963,3 @@ namespace DocFormatUtils
};
}
using namespace DocFormatUtils;

View File

@ -76,4 +76,4 @@ namespace DocFileFormat
return static_cast<ByteStructure*>(newObject);
}
}
}

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

@ -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);
@ -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)
{
@ -1540,7 +1583,6 @@ namespace DocFileFormat
return cpCellEnd;
}
//
bool DocumentMapping::writeBookmarks(int cp)
{
bool result = true;
@ -1561,7 +1603,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 +1647,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 +1662,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,8 +99,9 @@ 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 );
@ -121,6 +122,10 @@ namespace DocFileFormat
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

@ -33,7 +33,6 @@
#include "DrawingPrimitives.h"
#include "VirtualStreamReader.h"
namespace DocFileFormat
{
DrawingPrimitive * DrawingPrimitive::Create(VirtualStreamReader* reader, int length, short dpk)

View File

@ -133,14 +133,25 @@ namespace DocFileFormat
pos = tStream.GetPosition();
//------------------------------------------------------------------------------------------
crypt_data_aes.hashAlgorithm = CRYPT_METHOD::SHA1; //by AlgIDHash -> 0x0000 || 0x8004
crypt_data_aes.spinCount = 50000;
switch(AlgIDHash)
{
case 0x8003: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::MD5; break;
case 0x0000:
case 0x8004: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::SHA1; break;
}
crypt_data_aes.spinCount = 0;
switch(AlgID)
{
case 0x0000:
if (fAES) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
if (fCryptoAPI) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
case 0x6801:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
if (crypt_data_aes.keySize == 0) crypt_data_aes.keySize = 5; // 40 bit
break;
case 0x660E:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
@ -156,16 +167,11 @@ namespace DocFileFormat
break;
}
switch(ProviderType)
{
case 0x0001: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4; break;
case 0x0018: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB; break;
}
//switch(ProviderType)
//{
// case 0x0001: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4; break;
// case 0x0018: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB; break;
//}
}
//RELEASEARRAYOBJECTS( bytes );
}
}

View File

@ -507,9 +507,9 @@ namespace DocFileFormat
class FileInformationBlock
{
public:
bool m_bOlderVersion;
int m_CodePage;
FibBase m_FibBase;
bool m_bOlderVersion;
int m_CodePage;
FibBase m_FibBase;
RgW97 m_RgW97;
RgLw97 m_RgLw97;
@ -1189,9 +1189,9 @@ namespace DocFileFormat
m_FibBase.fDot = FormatUtils::BitmaskToBool((int)flag16, 0x0001);
m_FibBase.fGlsy = FormatUtils::BitmaskToBool((int)flag16, 0x0002);
m_FibBase.fComplex = FormatUtils::BitmaskToBool((int)flag16, 0x0002);
m_FibBase.fHasPic = FormatUtils::BitmaskToBool((int)flag16, 0x0008);
m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4);
m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100);
m_FibBase.fHasPic = FormatUtils::BitmaskToBool((int)flag16, 0x0008);
m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4);
m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100);
m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200);
m_FibBase.fReadOnlyRecommended = FormatUtils::BitmaskToBool((int)flag16, 0x0400);
m_FibBase.fWriteReservation = FormatUtils::BitmaskToBool((int)flag16, 0x0800);

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

@ -124,11 +124,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

@ -72,7 +72,7 @@ public:
if (m_Data)
{
rdUShort = FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size);
rdUShort = DocFileFormat::FormatUtils::BytesToUInt16 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdUShort);
}
@ -85,7 +85,7 @@ public:
if (m_Data)
{
rdShort = FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size);
rdShort = DocFileFormat::FormatUtils::BytesToInt16 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdShort);
}
@ -98,7 +98,7 @@ public:
if (m_Data)
{
rdInt = FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size);
rdInt = DocFileFormat::FormatUtils::BytesToInt32 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdInt);
}
@ -111,7 +111,7 @@ public:
if (m_Data )
{
rdUInt = FormatUtils::BytesToUInt32 (m_Data, m_Position, m_Size);
rdUInt = DocFileFormat::FormatUtils::BytesToUInt32 (m_Data, m_Position, m_Size);
m_Position += sizeof(rdUInt);
}

View File

@ -60,7 +60,7 @@ namespace DocFileFormat
_size.cx = Right - Left;
_size.cy = Bottom - Top;
rcgBounds = DocFormatUtils::Rectangle (_point, _size);
rcgBounds = DocFileFormat::Rectangle (_point, _size);
}
virtual ~ChildAnchor()
@ -75,7 +75,7 @@ namespace DocFileFormat
public:
/// Rectangle that describes the bounds of the anchor
DocFormatUtils::Rectangle rcgBounds;
DocFileFormat::Rectangle rcgBounds;
int Left;
int Top;
int Right;

View File

@ -64,7 +64,7 @@ namespace DocFileFormat
oSize.cx = ( right - left );
oSize.cy = ( bottom - top );
rcgBounds = DocFormatUtils::Rectangle(oPoint,oSize);
rcgBounds = DocFileFormat::Rectangle(oPoint,oSize);
}
virtual ~GroupShapeRecord()
@ -77,6 +77,6 @@ namespace DocFileFormat
return new GroupShapeRecord( _reader, bodySize, typeCode, version, instance );
}
DocFormatUtils::Rectangle rcgBounds;
DocFileFormat::Rectangle rcgBounds;
};
}

View File

@ -0,0 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "RegularContainer.h"
namespace DocFileFormat
{
class OfficeArtFRITContainer: public RegularContainer
{
public:
static const unsigned short TYPE_CODE_0xF118 = 0xF118;
OfficeArtFRITContainer () : RegularContainer()
{
}
OfficeArtFRITContainer (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : RegularContainer (_reader, size, typeCode, version, instance)
{
}
virtual ~OfficeArtFRITContainer()
{
}
virtual Record* NewObject (IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance)
{
return new OfficeArtFRITContainer( _reader, bodySize, typeCode, version, instance );
}
};
}

View File

@ -50,6 +50,7 @@
#include "GroupShapeRecord.h"
#include "OfficeArtClientTextbox.h"
#include "UnknownRecord.h"
#include "OfficeArtFRITContainer.h"
namespace DocFileFormat
{
@ -135,6 +136,7 @@ namespace DocFileFormat
case GroupContainer::TYPE_CODE_0xF003 : return new GroupContainer();
case GroupShapeRecord::TYPE_CODE_0xF009 : return new GroupShapeRecord ();
case OfficeArtClientTextbox::TYPE_CODE_0xF00D : return new OfficeArtClientTextbox ();
case OfficeArtFRITContainer::TYPE_CODE_0xF118 : return new OfficeArtFRITContainer ();
default:
return new UnknownRecord();

View File

@ -488,7 +488,7 @@ namespace DocFileFormat
{
for ( unsigned int i = 0, nSize = _grid->size(); i < nSize; i++ )
{
if(_grid->at(i) % DocFormatUtils::gc_nZeroWidth != 0)
if(_grid->at(i) % DocFileFormat::gc_nZeroWidth != 0)
{
bWriteGridCol = true;
break;

View File

@ -44,6 +44,8 @@
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/raster/BgraFrame.h"
using namespace DocFileFormat;
typedef struct
{
DWORD iType; // Record type EMR_HEADER

View File

@ -247,9 +247,8 @@ namespace DocFileFormat
{
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())));
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)));
}
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)));
if (pShape->is<LineType>())
{
@ -446,7 +445,7 @@ namespace DocFileFormat
{
yCoord = iter->op;
}break;
// OUTLINE
// LINE
case lineColor:
{
RGBColor lineColor((int)iter->op, RedFirst);
@ -493,6 +492,21 @@ namespace DocFileFormat
{
appendValueAttribute(&m_stroke, L"startarrowwidth", getArrowWidth( iter->op ));
}break;
case cxstyle:
{
if (pShape->GetShapeType() == NULL)
{
freeform = false;
m_pXmlWriter->WriteAttribute(L"type", L"#_x0000_t32");
}
switch(iter->op)
{
case 0: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"straight"); break;
case 1: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"elbow"); break;
case 2: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"curved"); break;
case 3: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"none"); break;
}
}break;
// FILL
case fillColor:
{
@ -544,6 +558,14 @@ namespace DocFileFormat
appendValueAttribute(&m_fill, L"r:id", std::wstring(( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) ));
}
}break;
case fillBlipName:
{
std::wstring name;
FormatUtils::GetSTLCollectionFromBytes<std::wstring>(&name, iter->opComplex.get(), iter->op, ENCODING_UTF16);
if (!name.empty())
appendValueAttribute(&m_fill, L"o:title", FormatUtils::XmlEncode(name));
}break;
case fillOpacity:
{
appendValueAttribute(&m_fill, L"opacity", ( FormatUtils::IntToWideString( iter->op ) + L"f" ));
@ -1419,7 +1441,7 @@ namespace DocFileFormat
{
if ((style != NULL) && (anchor != NULL))
{
DocFormatUtils::Rectangle bounds = anchor->rcgBounds;
DocFileFormat::Rectangle bounds = anchor->rcgBounds;
if (twistDimensions)
{
@ -2065,6 +2087,7 @@ namespace DocFileFormat
nElemSize = 4;
bTruncated = true;
}
else nElemSize = 2;
long dwSize = nElems * nElemSize;

View File

@ -197,20 +197,20 @@ public:
int cchSize = 1;
cch = ReadBytes( cchSize, true );
int xstzSize = FormatUtils::BytesToUChar( cch, 0, cchSize ) * 1;
int xstzSize = DocFileFormat::FormatUtils::BytesToUChar( cch, 0, cchSize ) * 1;
xstz = ReadBytes(xstzSize, true);
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 );
DocFileFormat::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_WINDOWS_1250 );
}
else
{
int cchSize = 2;
cch = ReadBytes( cchSize, true );
int xstzSize = FormatUtils::BytesToInt16( cch, 0, cchSize ) * 2;
int xstzSize = DocFileFormat::FormatUtils::BytesToInt16( cch, 0, cchSize ) * 2;
xstz = ReadBytes(xstzSize, true);
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_UTF16 );
DocFileFormat::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &wstrResult, xstz, xstzSize, ENCODING_UTF16 );
}
RELEASEARRAYOBJECTS(xstz);
@ -234,7 +234,7 @@ public:
//dont read the terminating zero
unsigned char* stringBytes = ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UTF16 );
DocFileFormat::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( ( cch * 2 ) - 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( stringBytes );
}
@ -278,7 +278,7 @@ public:
//dont read the terminating zero
stringBytes = ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250);
DocFileFormat::FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &result, stringBytes, ( cch - 1 ), ENCODING_WINDOWS_1250);
}
RELEASEARRAYOBJECTS( stringBytes );

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;
@ -139,7 +140,7 @@ namespace DocFileFormat
if (encryptionHeader->bStandard)
{
CRYPT::RC4Decryptor Decryptor(encryptionHeader->crypt_data_rc4, m_sPassword, 1);
CRYPT::RC4Decryptor Decryptor(encryptionHeader->crypt_data_rc4, m_sPassword);
if (Decryptor.IsVerify() == false)
{
@ -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,6 +483,7 @@ namespace DocFileFormat
delete storageOut;
return false;
}
std::list<std::string> listStream = storageIn->entries();
for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
@ -484,9 +498,12 @@ namespace DocFileFormat
}
}
else
{
DecryptStream(Decryptor, *it, storageIn, storageOut);
}
}
storageOut->close();
delete storageOut;
@ -508,9 +525,7 @@ namespace DocFileFormat
}
return true;
}
bool WordDocument::DecryptStream(CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
bool WordDocument::CopyStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
{
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
if (!stream) return false;
@ -524,24 +539,59 @@ namespace DocFileFormat
unsigned char* data_stream = new unsigned char[sz_stream];
stream->read(data_stream, sz_stream);
streamNew->write(data_stream, sz_stream);
RELEASEARRAYOBJECTS(data_stream);
streamNew->flush();
delete streamNew;
delete stream;
return true;
}
bool WordDocument::DecryptStream(CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
{
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
if (!stream) return false;
stream->seek(0);
int size_stream = stream->size();
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
if (!streamNew) return false;
unsigned char* data_stream = new unsigned char[size_stream];
stream->read(data_stream, size_stream);
unsigned char* data_store = NULL;
int sz_data_store = 0;
int size_data_store = 0;
if ("WordDocument" == streamName)
{
sz_data_store = 68;
data_store = new unsigned char[sz_data_store];
size_data_store = 68;
data_store = new unsigned char[size_data_store];
}
if (data_store)
memcpy(data_store, data_stream, sz_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++)
{
if (pos + size_block > size_stream)
size_block = size_stream - pos;
Decryptor->Decrypt((char*)data_stream + pos, size_block, block);
}
Decryptor->Decrypt((char*)data_stream, sz_stream, 0);
if (data_store)
memcpy(data_stream, data_store, sz_data_store);
memcpy(data_stream, data_store, size_data_store);
streamNew->write(data_stream, sz_stream);
streamNew->write(data_stream, size_stream);
RELEASEARRAYOBJECTS(data_store);
RELEASEARRAYOBJECTS(data_stream);
@ -622,6 +672,8 @@ namespace DocFileFormat
RELEASEOBJECT(SectionPlex);
RELEASEOBJECT(BookmarkStartPlex);
RELEASEOBJECT(BookmarkEndPlex);
RELEASEOBJECT(AnnotStartPlex);
RELEASEOBJECT(AnnotEndPlex);
RELEASEOBJECT(AutoTextPlex);
RELEASEOBJECT(ListPlex);
RELEASEOBJECT(Styles);

View File

@ -103,6 +103,7 @@ namespace DocFileFormat
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
{
@ -161,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
@ -203,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

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

@ -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()

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

@ -405,6 +405,8 @@ public:
std::wstring Fill;
std::wstring Del;
std::wstring Ins;
std::wstring MoveFrom;
std::wstring MoveTo;
std::wstring rPrChange;
bool bBold;
@ -492,13 +494,15 @@ public:
Fill.clear();
Del.clear();
Ins.clear();
MoveFrom.clear();
MoveTo.clear();
rPrChange.clear();
}
bool IsNoEmpty()
{
return bBold || bItalic || bUnderline || bStrikeout || bFontAscii || bFontHAnsi || bFontAE || bFontCS || bFontSize || bColor || bVertAlign || bHighLight || bShd ||
bRStyle || bSpacing || bDStrikeout || bCaps || bSmallCaps || bPosition || bFontHint || bBoldCs || bItalicCs || bFontSizeCs || bCs || bRtl || bLang || bLangBidi || bLangEA || bThemeColor || bVanish ||
!Outline.empty() || !Fill.empty() || !Del.empty() || !Ins.empty() || !rPrChange.empty();
!Outline.empty() || !Fill.empty() || !Del.empty() || !Ins.empty() || !MoveFrom.empty() || !MoveTo.empty() || !rPrChange.empty();
}
void Write(XmlUtils::CStringWriter* pCStringWriter)
{
@ -749,6 +753,10 @@ public:
pCStringWriter->WriteString(Del);
if (!Ins.empty())
pCStringWriter->WriteString(Ins);
if (!MoveFrom.empty())
pCStringWriter->WriteString(MoveFrom);
if (!MoveTo.empty())
pCStringWriter->WriteString(MoveTo);
if (!rPrChange.empty())
pCStringWriter->WriteString(rPrChange);
pCStringWriter->WriteString(L"</w:rPr>");
@ -1575,6 +1583,7 @@ public:
std::wstring UserName;
std::wstring UserId;
std::wstring Date;
std::wstring OOData;
bool Solved;
std::wstring Text;
std::wstring m_sParaId;
@ -1698,9 +1707,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);

View File

@ -34,6 +34,30 @@
namespace BinDocxRW {
int Binary_VbaProjectTableReader::Read()
{
return ReadTable(&Binary_VbaProjectTableReader::ReadContent, this);
}
int Binary_VbaProjectTableReader::ReadContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerVbaProjectTypes::Name == type )
{
std::wstring file_name = m_oBufferedStream.GetString4(length);
OOX::CPath inputPath = m_oBufferedStream.m_strFolder + FILE_SEPARATOR_STR + L"media" + FILE_SEPARATOR_STR + file_name;
OOX::CPath outputPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"vbaProject.bin";
NSFile::CFileBinary::Copy(inputPath.GetPath(), outputPath.GetPath());
m_oFileWriter.m_pVbaProject = new OOX::VbaProject();
m_oFileWriter.m_pVbaProject->set_filename(outputPath.GetPath());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
//-------------------------------------------------------------------------------------
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 +117,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,21 @@ 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 ();
int ReadContent (BYTE type, long length, void* poResult);
};
class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableReader>
{
Writers::FileWriter& m_oFileWriter;
@ -282,12 +297,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 +566,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,21 +575,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(L"w:moveFrom");
}
break;
case c_oSerProp_rPrType::MoveTo:
{
TrackRevision oMoveTo;
oBinary_CommonReader2.ReadTrackRevision(length, &oMoveTo);
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:
@ -633,9 +662,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:
{
@ -643,9 +672,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;
}
@ -654,35 +683,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:
@ -691,7 +720,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)
@ -731,9 +760,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)
{
@ -744,11 +773,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;
}
@ -762,7 +791,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;
@ -773,10 +802,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:
@ -786,7 +815,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];
@ -794,14 +823,14 @@ 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(std::wstring(_T("</w:tabs>")));
pCStringWriter->WriteString(std::wstring(L"</w:tabs>"));
}
}break;
case c_oSerProp_pPrType::ParaStyle:
@ -812,9 +841,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:
{
@ -2903,7 +2932,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()
@ -3025,6 +3055,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));
@ -3771,6 +3806,42 @@ public:
res = Read1(length, &Binary_DocumentTableReader::ReadDelIns, this, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:del"));
}
else if ( c_oSerParType::MoveFrom == type )
{
TrackRevision oTrackRevision;
res = Read1(length, &Binary_DocumentTableReader::ReadDelIns, this, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:moveFrom"));
}
else if ( c_oSerParType::MoveTo == type )
{
TrackRevision oTrackRevision;
res = Read1(length, &Binary_DocumentTableReader::ReadDelIns, this, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:moveTo"));
}
else if ( c_oSerParType::MoveFromRangeStart == type )
{
OOX::Logic::CMoveFromRangeStart oMoveFromRangeStart;
res = Read1(length, &Binary_DocumentTableReader::ReadMoveFromRangeStart, this, &oMoveFromRangeStart);
GetRunStringWriter().WriteString(oMoveFromRangeStart.toXML());
}
else if ( c_oSerParType::MoveFromRangeEnd == type )
{
OOX::Logic::CMoveFromRangeEnd oMoveToRangeEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadMoveFromRangeEnd, this, &oMoveToRangeEnd);
GetRunStringWriter().WriteString(oMoveToRangeEnd.toXML());
}
else if ( c_oSerParType::MoveToRangeStart == type )
{
OOX::Logic::CMoveToRangeStart oMoveToRangeStart;
res = Read1(length, &Binary_DocumentTableReader::ReadMoveToRangeStart, this, &oMoveToRangeStart);
GetRunStringWriter().WriteString(oMoveToRangeStart.toXML());
}
else if ( c_oSerParType::MoveToRangeEnd == type )
{
OOX::Logic::CMoveToRangeEnd oMoveToRangeEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadMoveToRangeEnd, this, &oMoveToRangeEnd);
GetRunStringWriter().WriteString(oMoveToRangeEnd.toXML());
}
else if(c_oSerParType::Sdt == type)
{
SdtWraper oSdt(1);
@ -3797,6 +3868,142 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadMoveFromRangeStart(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(poResult);
if (c_oSerMoveRange::Author == type)
{
pMoveFromRangeStart->m_sAuthor.Init();
pMoveFromRangeStart->m_sAuthor->append(m_oBufferedStream.GetString3(length));
}
else if (c_oSerMoveRange::ColFirst == type)
{
pMoveFromRangeStart->m_oColFirst.Init();
pMoveFromRangeStart->m_oColFirst->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::ColLast == type)
{
pMoveFromRangeStart->m_oColLast.Init();
pMoveFromRangeStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::Date == type)
{
std::wstring strValue = m_oBufferedStream.GetString3(length);
pMoveFromRangeStart->m_oDate.Init();
pMoveFromRangeStart->m_oDate->SetValue(strValue);
}
else if (c_oSerMoveRange::DisplacedByCustomXml == type)
{
pMoveFromRangeStart->m_oDisplacedByCustomXml.Init();
pMoveFromRangeStart->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else if (c_oSerMoveRange::Id == type)
{
pMoveFromRangeStart->m_oId.Init();
pMoveFromRangeStart->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::Name == type)
{
pMoveFromRangeStart->m_sName.Init();
pMoveFromRangeStart->m_sName->append(m_oBufferedStream.GetString3(length));
}
else if (c_oSerMoveRange::UserId == type)
{
pMoveFromRangeStart->m_sUserId.Init();
pMoveFromRangeStart->m_sUserId->append(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadMoveToRangeStart(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(poResult);
if (c_oSerMoveRange::Author == type)
{
pMoveToRangeStart->m_sAuthor.Init();
pMoveToRangeStart->m_sAuthor->append(m_oBufferedStream.GetString3(length));
}
else if (c_oSerMoveRange::ColFirst == type)
{
pMoveToRangeStart->m_oColFirst.Init();
pMoveToRangeStart->m_oColFirst->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::ColLast == type)
{
pMoveToRangeStart->m_oColLast.Init();
pMoveToRangeStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::Date == type)
{
std::wstring strValue = m_oBufferedStream.GetString3(length);
pMoveToRangeStart->m_oDate.Init();
pMoveToRangeStart->m_oDate->SetValue(strValue);
}
else if (c_oSerMoveRange::DisplacedByCustomXml == type)
{
pMoveToRangeStart->m_oDisplacedByCustomXml.Init();
pMoveToRangeStart->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else if (c_oSerMoveRange::Id == type)
{
pMoveToRangeStart->m_oId.Init();
pMoveToRangeStart->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerMoveRange::Name == type)
{
pMoveToRangeStart->m_sName.Init();
pMoveToRangeStart->m_sName->append(m_oBufferedStream.GetString3(length));
}
else if (c_oSerMoveRange::UserId == type)
{
pMoveToRangeStart->m_sUserId.Init();
pMoveToRangeStart->m_sUserId->append(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadMoveFromRangeEnd(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(poResult);
if (c_oSerMoveRange::DisplacedByCustomXml == type)
{
pMoveFromRangeEnd->m_oDisplacedByCustomXml.Init();
pMoveFromRangeEnd->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else if (c_oSerMoveRange::Id == type)
{
pMoveFromRangeEnd->m_oId.Init();
pMoveFromRangeEnd->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadMoveToRangeEnd(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(poResult);
if (c_oSerMoveRange::DisplacedByCustomXml == type)
{
pMoveToRangeEnd->m_oDisplacedByCustomXml.Init();
pMoveToRangeEnd->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else if (c_oSerMoveRange::Id == type)
{
pMoveToRangeEnd->m_oId.Init();
pMoveToRangeEnd->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFldSimple(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -6831,13 +7038,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;
@ -7731,9 +7938,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;
@ -7770,33 +7977,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
@ -7896,8 +8103,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);
}
@ -7949,9 +8156,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:
@ -7974,7 +8184,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");
@ -7984,19 +8205,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)
@ -8005,7 +8226,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);
@ -8017,7 +8238,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);
@ -8025,9 +8246,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;
@ -8041,19 +8262,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

@ -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
{
@ -381,7 +383,9 @@ extern int g_nCurFormatVersion;
TextFill = 32,
Del = 33,
Ins = 34,
rPrChange = 35
rPrChange = 35,
MoveFrom = 36,
MoveTo = 37
};}
namespace c_oSerProp_rowPrType{enum c_oSerProp_rowPrType
{
@ -464,7 +468,13 @@ extern int g_nCurFormatVersion;
Del = 12,
Ins = 13,
Background = 14,
Sdt = 15
Sdt = 15,
MoveFrom = 16,
MoveTo = 17,
MoveFromRangeStart = 18,
MoveFromRangeEnd = 19,
MoveToRangeStart = 20,
MoveToRangeEnd = 21
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -512,6 +522,10 @@ extern int g_nCurFormatVersion;
endnoteReference = 27,
arPr = 28
};}
namespace c_oSerVbaProjectTypes{enum c_oSerVbaProjectType
{
Name = 0
};}
namespace c_oSerBackgroundType{enum c_oSerBackgroundType
{
Color = 0,
@ -707,7 +721,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
{
@ -1073,6 +1088,17 @@ extern int g_nCurFormatVersion;
TIMaxLength = 23,
TIType = 24,
};}
namespace c_oSerMoveRange{enum c_oSerMoveRange
{
Author = 0,
ColFirst = 1,
ColLast = 2,
Date = 3,
DisplacedByCustomXml = 4,
Id = 5,
Name = 6,
UserId = 7
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

View File

@ -82,11 +82,11 @@ namespace BinDocxRW
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;
}
FldStruct(std::wstring sFld, int nType):m_sFld(sFld),m_nType(nType){}
int GetType()
{
return m_nType;
}
};
class BinaryCommonWriter
{
@ -831,6 +831,22 @@ namespace BinDocxRW
Write_rPrChange(rPr.m_oRPrChange.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(rPr.m_oMoveFrom.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::MoveFrom);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
m_oBcw.WriteTrackRevision(rPr.m_oMoveFrom.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(rPr.m_oMoveTo.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::MoveTo);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
m_oBcw.WriteTrackRevision(rPr.m_oMoveTo.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void Write_rPrChange(const OOX::Logic::CRPrChange& rPrChange)
{
@ -3009,7 +3025,27 @@ namespace BinDocxRW
std::wstring& sShapeType = aShapeTypes[i];
pOfficeDrawingConverter->AddShapeType(sShapeType);
}
pOfficeDrawingConverter->SetRels(oldRels);
pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteVbaProjectContent(OOX::VbaProject& oVbaProject)
{
std::wstring file_name = oVbaProject.filename().GetFilename();
m_oBcw.m_oStream.WriteBYTE(c_oSerVbaProjectTypes::Name);
m_oBcw.m_oStream.WriteStringW(file_name);
//... todooo write parsing vba project
//write vbaData.... todooo
//copy file bin
oVbaProject.copy_to(m_oBcw.m_oStream.m_pCommon->m_pImageManager->m_strDstMedia);
}
void WriteVbaProject(OOX::VbaProject& oVbaProject)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteVbaProjectContent(oVbaProject);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void Write(std::vector<OOX::WritingElement*>& aElems)
{
@ -3229,6 +3265,22 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_moveFrom:
{
OOX::Logic::CMoveFrom* pMoveFrom = static_cast<OOX::Logic::CMoveFrom*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFrom);
WriteMoveFrom(*pMoveFrom);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_moveTo:
{
OOX::Logic::CMoveTo* pMoveTo = static_cast<OOX::Logic::CMoveTo*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveTo);
WriteMoveTo(*pMoveTo);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_commentRangeStart:
{
OOX::Logic::CCommentRangeStart* pCommentRangeStart = static_cast<OOX::Logic::CCommentRangeStart*>(item);
@ -3241,6 +3293,39 @@ namespace BinDocxRW
WriteComment(OOX::et_w_commentRangeEnd, pCommentRangeEnd->m_oId);
break;
}
//todo moveRange on all levels(body, p ...)
// case OOX::et_w_moveFromRangeStart:
// {
// OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(item);
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeStart);
// WriteMoveRangeStart(*pMoveFromRangeStart);
// m_oBcw.WriteItemEnd(nCurPos);
// break;
// }
// case OOX::et_w_moveFromRangeEnd:
// {
// OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(item);
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeEnd);
// WriteMoveRangeEnd(*pMoveFromRangeEnd);
// m_oBcw.WriteItemEnd(nCurPos);
// break;
// }
// case OOX::et_w_moveToRangeStart:
// {
// OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(item);
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeStart);
// WriteMoveRangeStart(*pMoveToRangeStart);
// m_oBcw.WriteItemEnd(nCurPos);
// break;
// }
// case OOX::et_w_moveToRangeEnd:
// {
// OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(item);
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeEnd);
// WriteMoveRangeEnd(*pMoveToRangeEnd);
// m_oBcw.WriteItemEnd(nCurPos);
// break;
// }
case OOX::et_m_oMathPara:
{
OOX::Logic::COMathPara* pOMathPara = static_cast<OOX::Logic::COMathPara*>(item);
@ -3280,6 +3365,92 @@ namespace BinDocxRW
WriteParagraphContent(oIns.m_arrItems);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
void WriteMoveFrom(const OOX::Logic::CMoveFrom& oMoveFrom)
{
int nCurPos = 0;
m_oBcw.WriteTrackRevision(oMoveFrom);
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_RevisionType::Content);
WriteParagraphContent(oMoveFrom.m_arrItems);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
void WriteMoveTo(const OOX::Logic::CMoveTo& oMoveTo)
{
int nCurPos = 0;
m_oBcw.WriteTrackRevision(oMoveTo);
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_RevisionType::Content);
WriteParagraphContent(oMoveTo.m_arrItems);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
template<typename T> void WriteMoveRangeStart(const T& elem)
{
int nCurPos = 0;
if (elem.m_sAuthor.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::Author);
m_oBcw.m_oStream.WriteStringW3(elem.m_sAuthor.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_oColFirst.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::ColFirst);
m_oBcw.m_oStream.WriteLONG(elem.m_oColFirst->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_oColLast.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::ColLast);
m_oBcw.m_oStream.WriteLONG(elem.m_oColLast->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_oDate.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::Date);
m_oBcw.m_oStream.WriteStringW3(elem.m_oDate->ToString());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_oDisplacedByCustomXml.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::DisplacedByCustomXml);
m_oBcw.m_oStream.WriteBYTE(elem.m_oDisplacedByCustomXml->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::Id);
m_oBcw.m_oStream.WriteLONG(elem.m_oId->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_sName.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::Name);
m_oBcw.m_oStream.WriteStringW3(elem.m_sName.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_sUserId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::UserId);
m_oBcw.m_oStream.WriteStringW3(elem.m_sUserId.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
template<typename T> void WriteMoveRangeEnd(const T& elem)
{
int nCurPos = 0;
if (elem.m_oDisplacedByCustomXml.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::DisplacedByCustomXml);
m_oBcw.m_oStream.WriteBYTE(elem.m_oDisplacedByCustomXml->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (elem.m_oId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerMoveRange::Id);
m_oBcw.m_oStream.WriteLONG(elem.m_oId->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteComment(OOX::EElementType eType, nullable<SimpleTypes::CDecimalNumber<>>& oId)
{
int nCurPos = 0;
@ -5587,6 +5758,8 @@ namespace BinDocxRW
OOX::Logic::CDrawing* pGraphicDrawing = NULL;
PPTX::Logic::GraphicFrame* pGraphic = NULL;
m_oBcw.m_oStream.ClearCurShapePositionAndSizes();
if(OOX::et_mc_alternateContent == pElementType)
{
OOX::WritingElement* we = NULL;
@ -7069,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);
@ -7561,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()
@ -7708,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);
@ -7718,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

@ -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);
@ -144,13 +99,17 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
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 +125,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,27 +227,42 @@ 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.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
@ -318,7 +292,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 +317,11 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
bResultOk = true;
}
if (!bIsNoBase64)
{
RELEASEARRAYOBJECTS(pData);
}
}
RELEASEARRAYOBJECTS(pBase64Data);
}
@ -472,6 +451,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()
{
@ -134,7 +135,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;
@ -226,6 +227,11 @@ namespace BinXlsxRW{
{
m_pExternalDrawingConverter = pDrawingConverter;
}
void CXlsxSerializer::setIsNoBase64(bool bIsNoBase64)
{
m_bIsNoBase64 = bIsNoBase64;
}
void CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
{
//анализируем chart

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,6 +70,7 @@ 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);
};

View File

@ -49,8 +49,8 @@
6967917D1D9E8AEE002CA4BA /* BinReaderWriterDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 696791791D9E8AEE002CA4BA /* BinReaderWriterDefines.h */; };
6967917E1D9E8AEE002CA4BA /* BinWriters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6967917A1D9E8AEE002CA4BA /* BinWriters.cpp */; };
6967917F1D9E8AEE002CA4BA /* BinWriters.h in Headers */ = {isa = PBXBuildFile; fileRef = 6967917B1D9E8AEE002CA4BA /* BinWriters.h */; };
69BBDF251F0B8AAC00EB1BF7 /* FileDownloader_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 69BBDF241F0B8AAC00EB1BF7 /* FileDownloader_mac.mm */; };
69F181AF1C77274E00B2952B /* FileDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F181AD1C77274E00B2952B /* FileDownloader.h */; };
69F181B51C77276D00B2952B /* FileDownloader_curl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69F181B31C77276D00B2952B /* FileDownloader_curl.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -97,8 +97,8 @@
696791791D9E8AEE002CA4BA /* BinReaderWriterDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BinReaderWriterDefines.h; path = ../../BinWriter/BinReaderWriterDefines.h; sourceTree = "<group>"; };
6967917A1D9E8AEE002CA4BA /* BinWriters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BinWriters.cpp; path = ../../BinWriter/BinWriters.cpp; sourceTree = "<group>"; };
6967917B1D9E8AEE002CA4BA /* BinWriters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BinWriters.h; path = ../../BinWriter/BinWriters.h; sourceTree = "<group>"; };
69BBDF241F0B8AAC00EB1BF7 /* FileDownloader_mac.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp.preprocessed; fileEncoding = 4; name = FileDownloader_mac.mm; path = ../../../Common/FileDownloader/FileDownloader_mac.mm; sourceTree = "<group>"; };
69F181AD1C77274E00B2952B /* FileDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader.h; path = ../../../Common/FileDownloader/FileDownloader.h; sourceTree = "<group>"; };
69F181B31C77276D00B2952B /* FileDownloader_curl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileDownloader_curl.cpp; path = ../../../Common/FileDownloader/FileDownloader_curl.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -230,7 +230,7 @@
isa = PBXGroup;
children = (
69F181AD1C77274E00B2952B /* FileDownloader.h */,
69F181B31C77276D00B2952B /* FileDownloader_curl.cpp */,
69BBDF241F0B8AAC00EB1BF7 /* FileDownloader_mac.mm */,
);
name = Common;
sourceTree = "<group>";
@ -339,7 +339,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
69F181B51C77276D00B2952B /* FileDownloader_curl.cpp in Sources */,
17C1FE961ACC42C4006B99B3 /* Common.cpp in Sources */,
17C1FE971ACC42C4006B99B3 /* ChartFromToBinary.cpp in Sources */,
17C1FE981ACC42C4006B99B3 /* CSVReader.cpp in Sources */,
@ -348,6 +347,7 @@
17C1FE9B1ACC42C4006B99B3 /* CSVWriter.cpp in Sources */,
69414A301CB51666003E771B /* ChartWriter.cpp in Sources */,
6967917E1D9E8AEE002CA4BA /* BinWriters.cpp in Sources */,
69BBDF251F0B8AAC00EB1BF7 /* FileDownloader_mac.mm in Sources */,
17C1FE9C1ACC42C4006B99B3 /* XlsxSerializer.cpp in Sources */,
690FE0851E9BBD68004B26D0 /* Readers.cpp in Sources */,
17C1FE9D1ACC42C4006B99B3 /* FontProcessor.cpp in Sources */,
@ -379,6 +379,7 @@
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (
@ -416,6 +417,7 @@
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (

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"

View File

@ -51,6 +51,7 @@ 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);
@ -87,9 +88,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

@ -43,7 +43,6 @@ 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);
@ -57,11 +56,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 +155,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,6 +185,8 @@ 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) );
@ -181,6 +196,14 @@ namespace formulasconvert {
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 +231,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 +249,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 +286,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(
@ -546,6 +566,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);
@ -577,34 +602,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

@ -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,13 @@ 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/docx/xlsx_conditionalFormatting.cpp \
../src/docx/xlsx_dxfs.cpp \
../src/docx/docx_content_type.cpp \
@ -278,6 +286,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 +471,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 \

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,10 @@
#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"

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

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

@ -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);
}
}
///////////////////////////

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

@ -235,7 +235,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

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

@ -31,7 +31,6 @@
*/
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -124,6 +124,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 +132,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)
{
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)
{

View File

@ -29,7 +29,6 @@
* 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/xml/simple_xml_writer.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>

View File

@ -37,8 +37,6 @@
#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 4: CP_XML_ATTR(L"val", L"ctr"); break;
case 5: CP_XML_ATTR(L"val", L"inEnd"); break;
case 6: CP_XML_ATTR(L"val", L"l"); break;
case 7: CP_XML_ATTR(L"val", L"inBase"); break;
case 8: CP_XML_ATTR(L"val", L"outEnd"); 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;
}
}
}
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

@ -107,6 +107,7 @@ static const std::wstring _ooxShapeType[]=
L"path",
L"custGeom",//uses sub-sub type,
L"polygon",
L"roundRect",
};
@ -355,7 +356,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
shapeGeomPreset = L"rect";
}
}
else if (sub_type < 9 && sub_type >= 0)
else if (sub_type < 10 && sub_type >= 0)
{
shapeGeomPreset = _ooxShapeType[sub_type]; //odf -> oox
}

View File

@ -31,7 +31,6 @@
*/
#include "oox_layout.h"
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -32,7 +32,6 @@
#include "oox_package.h"
#include <boost/foreach.hpp>
#include <boost/ref.hpp>
#include <cpdoccore/utf8cpp/utf8.h>

View File

@ -32,7 +32,6 @@
#include "oox_rels.h"
#include <cpdoccore/xml/attributes.h>
#include <boost/foreach.hpp>
#include "namespaces.h"
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -31,7 +31,6 @@
*/
#include "oox_title.h"
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -30,12 +30,8 @@
*
*/
#include "oox_types_chart.h"
#include <boost/foreach.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "oox_types_chart.h"
#include "oox_chart_shape.h"
namespace cpdoccore {
@ -104,15 +100,15 @@ void oox_chart::oox_serialize_common(std::wostream & _Wostream)
CP_XML_ATTR(L"val", grouping_);
}
}
BOOST_FOREACH(oox_series_ptr const & s, series_)
for (size_t i = 0; i < series_.size(); i++)
{
s->oox_serialize(_Wostream);
series_[i]->oox_serialize(_Wostream);
}
BOOST_FOREACH(int const & i, axisId_)
for (size_t i = 0; i < axisId_.size(); i++)
{
CP_XML_NODE(L"c:axId")
{
CP_XML_ATTR(L"val", i);
CP_XML_ATTR(L"val", axisId_[i]);
}
}
data_labels_.oox_serialize(_Wostream);

View File

@ -31,7 +31,6 @@
*/
#include "pptx_comments.h"
#include <boost/foreach.hpp>
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "oox_rels.h"
@ -53,23 +52,23 @@ public:
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
BOOST_FOREACH(_pptx_comment const & c, pptx_comment_)
for (size_t i = 0; i < pptx_comment_.size(); i++)
{
CP_XML_NODE(L"p:cm")
{
CP_XML_ATTR(L"idx",c.idx_);
CP_XML_ATTR(L"idx", pptx_comment_[i].idx_);
CP_XML_ATTR(L"authorId", c.author_id_);
CP_XML_ATTR(L"dt", c.date_);
CP_XML_ATTR(L"authorId", pptx_comment_[i].author_id_);
CP_XML_ATTR(L"dt", pptx_comment_[i].date_);
CP_XML_NODE(L"p:pos")
{
CP_XML_ATTR(L"x", c.x_);
CP_XML_ATTR(L"y", c.y_);
CP_XML_ATTR(L"x", pptx_comment_[i].x_);
CP_XML_ATTR(L"y", pptx_comment_[i].y_);
}
CP_XML_NODE(L"p:text")
{
CP_XML_STREAM() << c.content_;
CP_XML_STREAM() << pptx_comment_[i].content_;
}
}
}

View File

@ -31,7 +31,6 @@
*/
#include "pptx_comments_context.h"
#include <boost/foreach.hpp>
#include <iostream>
#include "../odf/datatypes/length.h"
#include "xlsx_utils.h"

View File

@ -30,7 +30,6 @@
*
*/
#include <boost/foreach.hpp>
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -30,7 +30,6 @@
*
*/
#include <boost/make_shared.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -30,7 +30,6 @@
*
*/
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <cpdoccore/xml/utils.h>

View File

@ -30,7 +30,6 @@
*
*/
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -36,7 +36,6 @@
#include <iostream>
#include <list>
#include <boost/foreach.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <cpdoccore/odf/odf_document.h>

View File

@ -31,7 +31,6 @@
*/
#include "xlsx_border.h"
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPHash.h>
#include <cpdoccore/xml/simple_xml_writer.h>

View File

@ -32,8 +32,6 @@
#include "xlsx_cell_format.h"
#include <boost/foreach.hpp>
namespace cpdoccore {
namespace oox {

View File

@ -31,8 +31,6 @@
*/
#include <vector>
#include <boost/foreach.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "xlsx_cell_styles.h"
@ -69,9 +67,9 @@ void xlsx_cell_styles::serialize(std::wostream & _Wostream) const
{
CP_XML_ATTR(L"count", impl_->cell_styles_.size());
BOOST_FOREACH(const xlsx_cell_style & s, impl_->cell_styles_)
{
oox::xlsx_serialize(CP_XML_STREAM(), s);
for (size_t i = 0; i < impl_->cell_styles_.size(); i++)
{
oox::xlsx_serialize(CP_XML_STREAM(), impl_->cell_styles_[i]);
}
}
}

View File

@ -32,7 +32,6 @@
#include <sstream>
#include <boost/foreach.hpp>
#include <boost/functional/hash/hash.hpp>
#include "xlsx_font.h"

View File

@ -32,7 +32,6 @@
#include "xlsx_comments_context.h"
#include "xlsx_table_metrics.h"
#include <boost/foreach.hpp>
#include <iostream>
#include "../odf/datatypes/length.h"
#include "xlsx_utils.h"

View File

@ -29,7 +29,6 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
@ -515,7 +514,7 @@ void xlsx_drawing_context::process_position_properties(drawing_object_descriptio
}
void xlsx_drawing_context::process_image(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
if (!drawing.fill.bitmap)
{

View File

@ -175,13 +175,6 @@ void xlsx_fills::serialize(std::wostream & _Wostream) const
}
}
}
//_Wostream << L"<fills count=\"" << inst_array.size() << L"\" >";
//BOOST_FOREACH(const xlsx_fill & f, inst_array)
//{
// ::cpdoccore::oox::xlsx_serialize(_Wostream, f);
//}
//_Wostream << L"</fills>";
}
}

View File

@ -30,9 +30,6 @@
*
*/
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "xlsx_hyperlinks.h"
@ -60,11 +57,12 @@ public:
void dump_rels(rels & Rels) const
{
BOOST_FOREACH(const record & rec, records_)
for (size_t i = 0; i < records_.size(); i++)
{
if (rec.type == L"External")
if (records_[i].type == L"External")
{
Rels.add( relationship(rec.id, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", rec.location, rec.type) );
Rels.add( relationship(records_[i].id, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
records_[i].location, records_[i].type) );
}
}
}
@ -109,23 +107,23 @@ public:
void xlsx_serialize(std::wostream & _Wostream) const
{
BOOST_FOREACH(record const & r, records_)
for (size_t i = 0; i < records_.size(); i++)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"hyperlink")
{
CP_XML_ATTR(L"ref", r.ref);
CP_XML_ATTR(L"display", r.display);
CP_XML_ATTR(L"ref", records_[i].ref);
CP_XML_ATTR(L"display", records_[i].display);
if (!r.location.empty() && r.type == L"Internal")
if (!records_[i].location.empty() && records_[i].type == L"Internal")
{
CP_XML_ATTR(L"location", r.location);
CP_XML_ATTR(L"location", records_[i].location);
}
if (!r.id.empty() && r.type == L"External")
if (!records_[i].id.empty() && records_[i].type == L"External")
{
CP_XML_ATTR(L"r:id", r.id);
CP_XML_ATTR(L"r:id", records_[i].id);
}
}
}

View File

@ -57,8 +57,7 @@ public:
std::wstringstream ole_objects_;
std::wstringstream page_props_;
rels hyperlinks_rels_;
rels ole_objects_rels_;
rels sheet_rels_;
std::wstring drawingName_;
std::wstring drawingId_;
@ -141,14 +140,11 @@ std::wostream & xlsx_xml_worksheet::page_properties()
}
//---------------------------------------------------------------------------------------
rels & xlsx_xml_worksheet::hyperlinks_rels()
rels & xlsx_xml_worksheet::sheet_rels()
{
return impl_->hyperlinks_rels_;
}
rels & xlsx_xml_worksheet::ole_objects_rels()
{
return impl_->ole_objects_rels_;
return impl_->sheet_rels_;
}
void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
@ -189,14 +185,14 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->hyperlinks_.str();
}
}
CP_XML_STREAM() << impl_->drawing_.str();
if (!impl_->page_props_.str().empty())
{
CP_XML_STREAM() << impl_->page_props_.str();
}//props выше legacyDrawing !!
CP_XML_STREAM() << impl_->drawing_.str();
if (impl_->commentsId_.length()>0)
{
CP_XML_NODE(L"legacyDrawing")

View File

@ -49,8 +49,8 @@ class xlsx_xml_worksheet: noncopyable
public:
xlsx_xml_worksheet(std::wstring const & name);
~xlsx_xml_worksheet();
public:
std::wstring name() const;
std::wstring name() const;
std::wostream & cols();
std::wostream & sheetFormat();
@ -65,9 +65,8 @@ public:
std::wostream & ole_objects();
std::wostream & page_properties();
rels & hyperlinks_rels();
rels & ole_objects_rels();
rels & sheet_rels(); //hyperlink, background image, external, media ...
void write_to(std::wostream & strm);
void set_drawing_link (std::wstring const & fileName, std::wstring const & id);

View File

@ -32,8 +32,6 @@
#include "xlsx_package.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/ref.hpp>
#include <cpdoccore/utf8cpp/utf8.h>
@ -76,14 +74,33 @@ xlsx_document::xlsx_document()
void xlsx_document::write(const std::wstring & RootPath)
{
_CP_LOG << L"[info][xlsx] process writing" << std::endl;
xl_files_.write (RootPath);
docProps_files_.write (RootPath);
rels_files_.write (RootPath);
content_type_file_.write(RootPath);
}
////////////////////////////////////////////
//--------------------------------------------------------------------------------------------
pivot_cache_content::pivot_cache_content() : definitions_rels_file_(rels_file::create(L""))
{
}
_CP_PTR(pivot_cache_content) pivot_cache_content::create()
{
return boost::make_shared<pivot_cache_content>();
}
//--------------------------------------------------------------------------------------------
pivot_table_content::pivot_table_content() : rels_file_(rels_file::create(L""))
{
}
_CP_PTR(pivot_table_content) pivot_table_content::create()
{
return boost::make_shared<pivot_table_content>();
}
//--------------------------------------------------------------------------------------------
sheet_content::sheet_content() : rels_(rels_file::create(L""))
{
@ -101,13 +118,13 @@ void sheet_content::add_rel(relationship const & r)
void sheet_content::add_rels(rels & r)
{
BOOST_FOREACH(relationship & item, r.relationships())
std::vector<relationship> & items = r.relationships();
for (size_t i = 0; i < items.size(); i++)
{
rels_->get_rels().add(item);
rels_->get_rels().add(items[i]);
}
}
////////////
//--------------------------------------------------------------------------------------------
sheets_files::sheets_files()
{}
@ -121,41 +138,36 @@ void sheets_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"worksheets";
NSDirectory::CreateDirectory(path.c_str());
size_t count = 0;
BOOST_FOREACH(const sheet_content_ptr & item, sheets_)
for (size_t i = 0; i < sheets_.size(); i++)
{
if (item)
sheet_content_ptr & item = sheets_[i];
if (!item) continue;
const std::wstring fileName = std::wstring(L"sheet") + std::to_wstring(i + 1) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/xl/worksheets/") + fileName, kWSConType);
if (rels_)
{
count++;
const std::wstring fileName = std::wstring(L"sheet") + std::to_wstring(count) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/xl/worksheets/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"sId") + std::to_wstring(count);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
const std::wstring fileRef = std::wstring(L"worksheets/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
item->get_rel_file()->set_file_name(fileName + L".rels");
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
//item->get_rel_file()->write(path.string<std::wstring>());
package::simple_element(fileName, item->str()).write(path);
const std::wstring id = std::wstring(L"sId") + std::to_wstring(i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
const std::wstring fileRef = std::wstring(L"worksheets/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
item->get_rel_file()->set_file_name(fileName + L".rels");
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
//item->get_rel_file()->write(path.string<std::wstring>());
package::simple_element(fileName, item->str()).write(path);
}
}
////////////////////////////////////////////
//--------------------------------------------------------------------------------------------
xl_files::xl_files()
{
rels_files_.add_rel_file(rels_file::create(L"workbook.xml.rels"));
@ -166,10 +178,20 @@ void xl_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"xl";
NSDirectory::CreateDirectory(path.c_str());
sheets_files_.set_rels(&rels_files_);
sheets_files_.set_main_document( this->get_main_document() );
sheets_files_.write(path);
{
pivot_cache_files_.set_rels(&rels_files_);
pivot_cache_files_.set_main_document(get_main_document());
pivot_cache_files_.write(path);
}
{
pivot_table_files_.set_main_document(get_main_document());
pivot_table_files_.write(path);
}
{
sheets_files_.set_rels(&rels_files_);
sheets_files_.set_main_document( this->get_main_document() );
sheets_files_.write(path);
}
int index = 1;
if (true)
{
@ -181,7 +203,16 @@ void xl_files::write(const std::wstring & RootPath)
sharedStrings_->write(path);
rels_files_.add( relationship( L"shId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings", L"sharedStrings.xml" ) );
}
if (styles_)
if (connections_)
{
connections_->write(path);
rels_files_.add( relationship( L"cnId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections", L"connections.xml" ) );
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
contentTypes->add_override(L"/xl/connections.xml", L"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml");
}
if (styles_)
{
styles_->write(path);
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
@ -235,7 +266,10 @@ void xl_files::set_sharedStrings(element_ptr Element)
{
sharedStrings_ = Element;
}
void xl_files::set_connections(element_ptr Element)
{
connections_ = Element;
}
void xl_files::add_sheet(sheet_content_ptr sheet)
{
sheets_files_.add_sheet(sheet);
@ -269,7 +303,102 @@ void xl_files::add_charts(chart_content_ptr chart)
{
charts_files_.add_chart(chart);
}
////////////////////////////
void xl_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
{
pivot_cache_files_.add_pivot_cache(pivot_cache);
}
void xl_files::add_pivot_table(pivot_table_content_ptr pivot_table)
{
pivot_table_files_.add_pivot_table(pivot_table);
}
//----------------------------------------------------------------------------------------
void xl_pivot_cache_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
{
pivot_caches_.push_back(pivot_cache);
}
void xl_pivot_cache_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"pivotCache";
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConTypeD = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
static const std::wstring kWSConTypeR = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml";
for (size_t i = 0; i < pivot_caches_.size(); i++)
{
if (pivot_caches_[i])
{
const std::wstring fileNameD = std::wstring(L"pivotCacheDefinition") + std::to_wstring(i + 1) + L".xml";
contentTypes->add_override(std::wstring(L"/xl/pivotCache/") + fileNameD, kWSConTypeD);
package::simple_element(fileNameD, pivot_caches_[i]->str_d()).write(path);
if (pivot_caches_[i]->get_rels().empty() == false)
{
rels_files relFiles;
pivot_caches_[i]->definitions_rels_file_->set_file_name(fileNameD + L".rels");
relFiles.add_rel_file(pivot_caches_[i]->definitions_rels_file_);
relFiles.write(path);
}
if (rels_) //for workbook
{
const std::wstring id = std::wstring(L"pcId") + std::to_wstring(i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition";
const std::wstring fileRef = std::wstring(L"pivotCache/") + fileNameD;
rels_->add(id, kWSRel, fileRef);
}
std::wstring content_records = pivot_caches_[i]->str_r();
if (!content_records.empty())
{
const std::wstring fileNameR = std::wstring(L"pivotCacheRecords") + std::to_wstring(i + 1) + L".xml";
contentTypes->add_override(std::wstring(L"/xl/pivotCache/") + fileNameR, kWSConTypeR);
package::simple_element(fileNameR, content_records).write(path);
}
}
}
}
//----------------------------------------------------------------------------------------
void xl_pivot_table_files::add_pivot_table(pivot_table_content_ptr pivot_table)
{
pivot_tables_.push_back(pivot_table);
}
void xl_pivot_table_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"pivotTables";
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
for (size_t i = 0; i < pivot_tables_.size(); i++)
{
if (pivot_tables_[i])
{
const std::wstring fileName = std::wstring(L"pivotTable") + std::to_wstring(i + 1) + L".xml";
contentTypes->add_override(std::wstring(L"/xl/pivotTables/") + fileName, kWSConType);
package::simple_element(fileName, pivot_tables_[i]->str()).write(path);
if (pivot_tables_[i]->get_rels().empty() == false)
{
rels_files relFiles;
pivot_tables_[i]->rels_file_->set_file_name(fileName + L".rels");
relFiles.add_rel_file(pivot_tables_[i]->rels_file_);
relFiles.write(path);
}
}
}
}
//------------------------------------------------------------------------------------------------------
void xl_charts_files::add_chart(chart_content_ptr chart)
{
charts_.push_back(chart);
@ -281,29 +410,26 @@ void xl_charts_files::write(const std::wstring & RootPath)
size_t count = 0;
BOOST_FOREACH(const chart_content_ptr & item, charts_)
for (size_t i = 0; i < charts_.size(); i++)
{
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(count) + L".xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/xl/charts/") + fileName, kWSConType);
count++;
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(i + 1) + L".xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/xl/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);
}
}
//////////////////////////
//------------------------------------------------------------------------------------------------------
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms)
{
return boost::make_shared<xl_drawings>(boost::ref(elms));
@ -314,14 +440,14 @@ void xl_drawings::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"drawings";
NSDirectory::CreateDirectory(path.c_str());
BOOST_FOREACH(drawing_elm const & e, drawings_)
for (size_t i = 0; i < drawings_.size(); i++)
{
package::simple_element(e.filename, e.content).write(path);
package::simple_element(drawings_[i].filename, drawings_[i].content).write(path);
rels_files relFiles;
rels_file_ptr r = rels_file::create(e.filename + L".rels");
rels_file_ptr r = rels_file::create(drawings_[i].filename + L".rels");
e.drawings->dump_rels_drawing(r->get_rels());
drawings_[i].drawings->dump_rels_drawing(r->get_rels());
relFiles.add_rel_file(r);
relFiles.write(path);
@ -329,7 +455,7 @@ void xl_drawings::write(const std::wstring & RootPath)
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
const std::wstring kDrawingCT = L"application/vnd.openxmlformats-officedocument.drawing+xml";
contentTypes->add_override(L"/xl/drawings/" + e.filename, kDrawingCT);
contentTypes->add_override(L"/xl/drawings/" + drawings_[i].filename, kDrawingCT);
}
}
@ -344,15 +470,15 @@ void xl_comments::write(const std::wstring & RootPath)
std::wstring vml_path = RootPath + FILE_SEPARATOR_STR + L"drawings";
NSDirectory::CreateDirectory(vml_path.c_str());
BOOST_FOREACH(comment_elm const & e, comments_)
for (size_t i = 0; i < comments_.size(); i++)
{
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
contentTypes->add_override(std::wstring(L"/xl/") + e.filename, kWSConType);
contentTypes->add_override(std::wstring(L"/xl/") + comments_[i].filename, kWSConType);
package::simple_element(e.filename, e.content).write(RootPath);
package::simple_element(e.vml_filename, e.vml_content).write(vml_path);
package::simple_element(comments_[i].filename, comments_[i].content).write(RootPath);
package::simple_element(comments_[i].vml_filename, comments_[i].vml_content).write(vml_path);
}
}

View File

@ -50,9 +50,6 @@ public:
xlsx_content_types_file();
};
class sheet_content;
typedef _CP_PTR(sheet_content) sheet_content_ptr;
class sheet_content : noncopyable
{
public:
@ -68,8 +65,49 @@ private:
std::wstringstream content_;
rels_file_ptr rels_;
};
typedef _CP_PTR(sheet_content) sheet_content_ptr;
//------------------------------------------------------------------------
class pivot_cache_content;
typedef _CP_PTR(pivot_cache_content) pivot_cache_content_ptr;
class pivot_cache_content : boost::noncopyable
{
public:
pivot_cache_content();
static _CP_PTR(pivot_cache_content) create();
// sheets_files
std::wostream & definitions() { return definitions_; }
std::wostream & records() { return records_; }
rels & get_rels() { return definitions_rels_file_->get_rels(); }
std::wstring str_d() { return definitions_.str(); }
std::wstring str_r() { return records_.str(); }
friend class xl_pivot_cache_files;
private:
std::wstringstream records_;
std::wstringstream definitions_;
rels_file_ptr definitions_rels_file_;
};
//------------------------------------------------------------------------
class pivot_table_content;
typedef _CP_PTR(pivot_table_content) pivot_table_content_ptr;
class pivot_table_content : boost::noncopyable
{
public:
pivot_table_content();
static _CP_PTR(pivot_table_content) create();
std::wostream & content() { return content_; }
rels & get_rels() { return rels_file_->get_rels(); }
std::wstring str() { return content_.str(); }
friend class xl_pivot_table_files;
private:
std::wstringstream content_;
rels_file_ptr rels_file_;
};
//------------------------------------------------------------------------
class sheets_files : public element
{
public:
@ -90,7 +128,7 @@ public:
};
// xl_charts_files
class xl_charts_files : public element
{
public:
@ -102,12 +140,37 @@ public:
std::vector<chart_content_ptr> charts_;
};
///////////////////////////////////////////////////////////
class xl_pivot_table_files : public element
{
public:
xl_pivot_table_files(){}
void add_pivot_table(pivot_table_content_ptr pivot_table);
virtual void write(const std::wstring & RootPath);
std::vector<pivot_table_content_ptr> pivot_tables_;
};
class xl_pivot_cache_files : public element
{
public:
xl_pivot_cache_files(){}
void set_rels(rels_files * rels)
{
rels_ = rels;
}
void add_pivot_cache(pivot_cache_content_ptr pivot_cache);
virtual void write(const std::wstring & RootPath);
std::vector<pivot_cache_content_ptr> pivot_caches_;
rels_files * rels_;
};
//-------------------------------------------------------------------------------------------------------------
class xl_comments;
typedef _CP_PTR(xl_comments) xl_comments_ptr;
// xl_comments
class xl_comments: public element
{
public:
@ -121,13 +184,10 @@ public:
private:
const std::vector<comment_elm> & comments_;
};
//-----------------------------------------------------------------------------------------------------
class xl_drawings;
typedef _CP_PTR(xl_drawings) xl_drawings_ptr;
// xl_drawings
class xl_drawings: public element
{
public:
@ -146,10 +206,9 @@ public:
private:
const std::vector<drawing_elm> & drawings_;
rels_files * rels_;
};
//----------------------------------------------------------------------------------------------------------
// xl_files
class xl_files : public element
{
public:
@ -158,20 +217,25 @@ public:
public:
virtual void write(const std::wstring & RootPath);
void set_workbook(element_ptr Element);
void set_styles(element_ptr Element);
void set_sharedStrings(element_ptr Element);
void add_sheet(sheet_content_ptr sheet);
void set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts);
void set_drawings(element_ptr Element);
void set_vml_drawings(element_ptr Element);
void set_comments(element_ptr Element);
void add_charts(chart_content_ptr chart);
void set_workbook (element_ptr Element);
void set_styles (element_ptr Element);
void set_sharedStrings (element_ptr Element);
void set_connections (element_ptr Element);
void add_sheet (sheet_content_ptr sheet);
void set_media (mediaitems & _Mediaitems, CApplicationFonts *pAppFonts);
void set_drawings (element_ptr Element);
void set_vml_drawings (element_ptr Element);
void set_comments (element_ptr Element);
void add_charts (chart_content_ptr chart);
void add_pivot_cache (pivot_cache_content_ptr cache);
void add_pivot_table (pivot_table_content_ptr table);
private:
rels_files rels_files_;
sheets_files sheets_files_;
xl_charts_files charts_files_;
rels_files rels_files_;
sheets_files sheets_files_;
xl_charts_files charts_files_;
xl_pivot_cache_files pivot_cache_files_;
xl_pivot_table_files pivot_table_files_;
element_ptr theme_;
element_ptr workbook_;
@ -183,10 +247,9 @@ private:
element_ptr drawings_;
element_ptr vml_drawings_;
element_ptr comments_;
element_ptr connections_;
};
// xlsx_document
class xlsx_document : public document
{
public:

View File

@ -0,0 +1,455 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "xlsx_pivots_context.h"
#include <boost/make_shared.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace oox {
class xlsx_pivots_context::Impl
{
public:
struct _pivot_xml
{
std::wstring definitionsData_; //cacheData
std::wstring recordsData_; //cacheRecorda
std::wstring viewData_; //tableView
};
Impl() {}
std::vector<_pivot_xml> pivot_xmls_;
std::wstring connections_;
struct _field
{
std::wstring name;
int type = -1;
int function = -1;
std::wstring user_function;
std::vector<int> subtotals;
std::vector<std::wstring> caches;
};
struct _desc
{
void clear()
{
name.clear();
location_ref.clear();
source_ref.clear();
fields.clear();
row_fields.clear();
page_fields.clear();
col_fields.clear();
data_fields.clear();
}
std::wstring name;
std::wstring location_ref;
std::wstring source_ref;
std::wstring source_table_name;
std::vector<_field> fields;
std::vector<int> row_fields;
std::vector<int> page_fields;
std::vector<int> col_fields;
std::vector<int> data_fields;
}current_;
void serialize_view(std::wostream & strm);
void serialize_cache(std::wostream & strm);
};
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
{
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotTableDefinition")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"name", current_.name);
CP_XML_ATTR(L"cacheId", pivot_xmls_.size());
//CP_XML_ATTR(L"dataOnRows", view->sxaxis4Data.bRw);
//CP_XML_ATTR(L"applyNumberFormats", view->fAtrNum);
//CP_XML_ATTR(L"applyBorderFormats", view->fAtrBdr);
//CP_XML_ATTR(L"applyFontFormats", view->fAtrFnt);
//CP_XML_ATTR(L"applyPatternFormats", view->fAtrPat);
//CP_XML_ATTR(L"applyAlignmentFormats", view->fAtrAlc);
//CP_XML_ATTR(L"applyWidthHeightFormats", view->fAtrProc);
//if (!view->stData.value().empty())
//{
// CP_XML_ATTR(L"dataCaption", view->stData.value());
//}
//CP_XML_ATTR(L"asteriskTotals", 1);
//CP_XML_ATTR(L"showMemberPropertyTips", 0);
//CP_XML_ATTR(L"useAutoFormatting", view->fAutoFormat);
//CP_XML_ATTR(L"autoFormatId", view->itblAutoFmt);
CP_XML_ATTR(L"itemPrintTitles", 1);
CP_XML_ATTR(L"indent", 0);
CP_XML_ATTR(L"compact", 0);
CP_XML_ATTR(L"compactData", 0);
CP_XML_ATTR(L"gridDropZones", 1);
CP_XML_NODE(L"location")
{
CP_XML_ATTR(L"ref", current_.location_ref);
//CP_XML_ATTR(L"firstHeaderRow", view->rwFirstHead - view->ref.rowFirst );
//CP_XML_ATTR(L"firstDataRow", view->rwFirstData - view->ref.rowFirst);
//CP_XML_ATTR(L"firstDataCol", view->colFirstData - view->ref.columnFirst);
CP_XML_ATTR(L"rowPageCount", 1);
CP_XML_ATTR(L"colPageCount", 1);
}
CP_XML_NODE(L"pivotFields")
{
CP_XML_ATTR(L"count", current_.fields.size());
for (size_t i = 0; i < current_.fields.size(); i++)
{
CP_XML_NODE(L"pivotField")
{
switch(current_.fields[i].type)
{
case 0: CP_XML_ATTR(L"axis", L"axisCol"); break;
case 1: break;// data,
case 2: break;// hidden,
case 3: CP_XML_ATTR(L"axis", L"axisPage"); break;
case 4: CP_XML_ATTR(L"axis", L"axisRow"); break;
}
CP_XML_ATTR(L"defaultSubtotal", 0);
//compact="0" outline="0" subtotalTop="0" showAll="0" includeNewItemsInFilter="1" sortType="ascending"
CP_XML_NODE(L"items")
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
CP_XML_NODE(L"item")
{
CP_XML_ATTR(L"x", j);
}
}
}
}
//CP_XML_STREAM() << fields_[i].view_;
}
}
CP_XML_NODE(L"rowFields")
{
CP_XML_ATTR(L"count", current_.row_fields.size());
for (size_t i = 0; i < current_.row_fields.size(); i++)
{
CP_XML_NODE(L"field")
{
CP_XML_ATTR(L"x", current_.row_fields[i]);
}
}
}
CP_XML_NODE(L"colFields")
{
CP_XML_ATTR(L"count", current_.col_fields.size());
for (size_t i = 0; i < current_.col_fields.size(); i++)
{
CP_XML_NODE(L"field")
{
CP_XML_ATTR(L"x", current_.col_fields[i]);
}
}
}
CP_XML_NODE(L"pageFields")
{
CP_XML_ATTR(L"count", current_.page_fields.size());
for (size_t i = 0; i < current_.page_fields.size(); i++)
{
CP_XML_NODE(L"pageField")
{
CP_XML_ATTR(L"fld", current_.page_fields[i]);
CP_XML_ATTR(L"item", 0);
CP_XML_ATTR(L"hier", -1);
}
}
}
CP_XML_NODE(L"dataFields")
{
CP_XML_ATTR(L"count", current_.data_fields.size());
for (size_t i = 0; i < current_.data_fields.size(); i++)
{
CP_XML_NODE(L"dataField")
{
CP_XML_ATTR(L"fld", current_.data_fields[i]);
CP_XML_ATTR(L"baseField", 0);
//CP_XML_ATTR(L"baseItem", -1);
//CP_XML_ATTR(L"name", L"");
}
}
}
}
}
}
void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotCacheDefinition")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//{ records file
// CP_XML_ATTR(L"r:id", L"rId1" );
//}
CP_XML_ATTR(L"enableRefresh", 1);
//CP_XML_ATTR(L"refreshedBy", db->rgb.value());
//CP_XML_ATTR(L"refreshedDate", db_ex->numDate.data.value);
CP_XML_ATTR(L"recordCount", 0);
//createdVersion="1"
//refreshedVersion="2"
//upgradeOnRefresh="1">
if (true)
{
CP_XML_NODE(L"cacheSource")
{
CP_XML_ATTR(L"type", L"worksheet");
CP_XML_NODE(L"worksheetSource")
{
CP_XML_ATTR(L"ref", current_.source_ref);
CP_XML_ATTR(L"sheet", current_.source_table_name);
}
}
}
if (current_.fields.empty() == false)
{
CP_XML_NODE(L"cacheFields")
{
CP_XML_ATTR(L"count", current_.fields.size());
for (size_t i = 0; i < current_.fields.size(); i++)
{
CP_XML_NODE(L"cacheField")
{
CP_XML_ATTR(L"name", current_.fields[i].name);
CP_XML_ATTR(L"numFmtId", 0);
if (current_.fields[i].caches.empty() == false)
{
CP_XML_NODE(L"sharedItems")
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
//CP_XML_ATTR(L"containsSemiMixedTypes", );
CP_XML_ATTR(L"containsNonDate", 1);
CP_XML_ATTR(L"containsDate", 0);
CP_XML_ATTR(L"containsBlank", 0);
//CP_XML_ATTR(L"containsString", );
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
std::wstring node_name = L"s";
//switch(current_.fields[i].caches[j].type)
//{
//}
CP_XML_NODE(node_name)
{
CP_XML_ATTR(L"v", current_.fields[i].caches[j]);
}
}
}
}
}
}
}
}
//if (pivot_cache->m_arSXFORMULA.empty() == false)
//{
// CP_XML_NODE(L"calculatedItems")
// {
// CP_XML_ATTR(L"count", pivot_cache->m_arSXFORMULA.size());
// for (size_t i = 0; i < pivot_cache->m_arSXFORMULA.size(); i++)
// {
// pivot_cache->m_arSXFORMULA[i]->serialize(CP_XML_STREAM());
// }
// }
//}
}
}
}
int xlsx_pivots_context::get_count()
{
return (int)impl_->pivot_xmls_.size();
}
bool xlsx_pivots_context::is_connections()
{
return !impl_->connections_.empty();
}
void xlsx_pivots_context::dump_rels_cache(int index, rels & Rels)
{
if (impl_->pivot_xmls_[index].recordsData_.empty() == false)
{
Rels.add(relationship(L"rId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords",
L"pivotCacheRecords" + std::to_wstring(index + 1) + L".xml", L""));
}
}
void xlsx_pivots_context::dump_rels_view(int index, rels & Rels)
{
Rels.add(relationship(L"rId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
L"../pivotCache/pivotCacheDefinition" + std::to_wstring(index + 1) + L".xml", L""));
}
void xlsx_pivots_context::write_cache_definitions_to(int index, std::wostream & strm)
{
strm << impl_->pivot_xmls_[index].definitionsData_;
}
void xlsx_pivots_context::write_connections_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"connections")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_STREAM() << impl_->connections_;
}
}
}
void xlsx_pivots_context::write_cache_records_to(int index, std::wostream & strm)
{
strm << impl_->pivot_xmls_[index].recordsData_;
}
void xlsx_pivots_context::write_table_view_to(int index, std::wostream & strm)
{
strm << impl_->pivot_xmls_[index].viewData_;
}
void xlsx_pivots_context::start_table()
{
impl_->current_.clear();
}
int xlsx_pivots_context::end_table()
{
std::wstringstream view_strm;
std::wstringstream cache_strm;
std::wstringstream rec_strm;
impl_->serialize_view(view_strm);
impl_->serialize_cache(cache_strm);
Impl::_pivot_xml v = {cache_strm.str(), rec_strm.str(), view_strm.str()};
impl_->pivot_xmls_.push_back(v);
return impl_->pivot_xmls_.size();
}
void xlsx_pivots_context::set_view_name(std::wstring name)
{
impl_->current_.name = name;
}
void xlsx_pivots_context::set_view_target_range(std::wstring ref)
{
impl_->current_.location_ref = ref;
}
void xlsx_pivots_context::start_field()
{
Impl::_field f;
impl_->current_.fields.push_back(f);
}
void xlsx_pivots_context::set_field_name(std::wstring name)
{
impl_->current_.fields.back().name = name;
}
void xlsx_pivots_context::set_field_type(int type)
{
impl_->current_.fields.back().type = type;
switch(type)
{
case 0: impl_->current_.col_fields.push_back(impl_->current_.fields.size() - 1); break;// column,
case 1: impl_->current_.data_fields.push_back(impl_->current_.fields.size() - 1); break;// data,
case 2: break;// hidden,
case 3: impl_->current_.page_fields.push_back(impl_->current_.fields.size() - 1); break;// page,
case 4: impl_->current_.row_fields.push_back(impl_->current_.fields.size() - 1); break;// row
}
}
void xlsx_pivots_context::set_field_function(int type)
{
impl_->current_.fields.back().function = type;
}
void xlsx_pivots_context::set_field_user_function(std::wstring f)
{
impl_->current_.fields.back().user_function = f;
}
void xlsx_pivots_context::add_field_subtotal(int function_type)
{
impl_->current_.fields.back().subtotals.push_back(function_type);
}
void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
{
while (index > impl_->current_.fields.back().caches.size())
{
impl_->current_.fields.back().caches.push_back(L"");
}
impl_->current_.fields.back().caches.push_back(value);
}
void xlsx_pivots_context::end_field()
{
}
void xlsx_pivots_context::set_source_range(std::wstring table_name, std::wstring ref)
{
impl_->current_.source_table_name = table_name;
impl_->current_.source_ref = ref;
}
void xlsx_pivots_context::add_connections(std::wstring connections)
{
if (connections.empty()) return;
impl_->connections_ = connections;
}
xlsx_pivots_context::~xlsx_pivots_context()
{
}
}
}

View File

@ -0,0 +1,87 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "oox_package.h"
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/CPOptional.h>
namespace cpdoccore {
namespace oox {
class xlsx_pivot_cache_context;
typedef _CP_PTR(xlsx_pivot_cache_context) xlsx_pivot_cache_context_ptr;
class xlsx_pivots_context
{
public:
xlsx_pivots_context();
~xlsx_pivots_context();
void start_table();
int end_table();
void start_field();
void set_field_name(std::wstring name);
void set_field_type(int type);
void set_field_function(int type);
void set_field_user_function(std::wstring f);
void add_field_subtotal(int function_type);
void add_field_cache(int index, std::wstring value);
void end_field();
int get_count();
void set_view_name(std::wstring name);
void set_view_target_range(std::wstring ref);
void set_source_range(std::wstring table_name, std::wstring ref);
void write_cache_definitions_to (int index, std::wostream & strm);
void write_cache_records_to (int index, std::wostream & strm);
void write_connections_to (std::wostream & strm);
void write_table_view_to (int index, std::wostream & strm);
void dump_rels_cache(int index, rels & Rels);
void dump_rels_view (int index, rels & Rels);
void add_connections(std::wstring connections);
bool is_connections();
private:
class Impl;
_CP_PTR(Impl) impl_;
};
}
}

View File

@ -31,8 +31,6 @@
*/
#include <vector>
#include <boost/foreach.hpp>
#include <cpdoccore/xml/utils.h>
#include "xlsx_sharedstrings.h"
@ -55,10 +53,10 @@ void xlsx_shared_strings::Impl::serialize(std::wostream & _Wostream) const
_Wostream << L"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"" <<
strings_.size() << "\" uniqueCount=\"" << strings_.size() << "\">";
BOOST_FOREACH(const std::wstring & str, strings_)
for (size_t i = 0; i < strings_.size(); i++)
{
_Wostream << L"<si>";
_Wostream << str;
_Wostream << strings_[i];
_Wostream << L"</si>";
}

View File

@ -35,6 +35,7 @@
#include <iostream>
#include <iosfwd>
#include <cpdoccore/CPScopedPtr.h>
#include <boost/noncopyable.hpp>
namespace cpdoccore {
namespace oox {

View File

@ -232,9 +232,9 @@ void xlsx_style_manager::Impl::serialize_xf(std::wostream & _Wostream, const xls
std::sort(xfs_.begin(), xfs_.end(), compare_xlsx_xf());
_Wostream << L"<" << nodeName << L" count=\"" << xfs_.size() << L"\">";
BOOST_FOREACH(const xlsx_xf & xfRecord, xfs_)
for (size_t i = 0; i < xfs_.size(); i++)
{
cpdoccore::oox::xlsx_serialize(_Wostream, xfRecord);
cpdoccore::oox::xlsx_serialize(_Wostream, xfs_[i]);
}
_Wostream << L"</" << nodeName << L">";
}

View File

@ -32,7 +32,6 @@
#include "xlsx_table_metrics.h"
#include <vector>
#include <boost/foreach.hpp>
namespace cpdoccore {
namespace oox

View File

@ -160,7 +160,10 @@ void xlsx_table_state::set_table_row_group(int count, bool collapsed, int level)
group_row_.collapsed = collapsed;
group_row_.level = level;
}
void xlsx_table_state::add_empty_row(int count)
{
current_table_row_ += count;
}
void xlsx_table_state::start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName)
{
empty_row_ = true;

View File

@ -89,6 +89,8 @@ public:
void non_empty_row ();
bool is_empty_row () const;
void end_row ();
void add_empty_row(int count);
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;

View File

@ -40,7 +40,6 @@
#include "logging.h"
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/odf/odf_document.h>
@ -149,9 +148,9 @@ void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableS
void xlsx_table_context::end_table()
{
xlsx_table_states_.pop_back();
//xlsx_table_states_.pop_back();
}
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
{
state()->start_cell(columnsSpanned, rowsSpanned);

View File

@ -48,7 +48,6 @@ class xlsx_table_context
public:
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
public:
void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
void end_table();

View File

@ -36,7 +36,6 @@
#include "xlsx_sharedstrings.h"
#include <list>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/utils.h>

View File

@ -152,8 +152,7 @@ void xlsx_conversion_context::end_document()
content->add_rel(relationship(dId, kType, dName));
}
//////////////////////////////////////////////////////////////////////////////////////////////////
content->add_rels(sheet->hyperlinks_rels());
content->add_rels(sheet->ole_objects_rels());
content->add_rels(sheet->sheet_rels());
/////////////////////////////////////////////////////////////////////////////////////////////////
const std::pair<std::wstring, std::wstring> p2 = sheet->get_comments_link();
if (!p2.first.empty())
@ -232,6 +231,54 @@ void xlsx_conversion_context::end_document()
}
get_xlsx_defined_names().xlsx_serialize(CP_XML_STREAM());
int pivot_cache_count = xlsx_pivots_context_.get_count();
if (pivot_cache_count > 0)
{
CP_XML_NODE(L"pivotCaches")
{
for (int i = 0; i < pivot_cache_count; i++)
{
std::wstring rId = L"pcId" + std::to_wstring(i+1);
static const std::wstring sType = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition";
const std::wstring sName = std::wstring(L"../pivotCache/pivotCacheDefinition" + std::to_wstring(i + 1) + L".xml");
package::pivot_cache_content_ptr content = package::pivot_cache_content::create();
CP_XML_NODE(L"pivotCache")
{
CP_XML_ATTR(L"cacheId", std::to_wstring(i));
CP_XML_ATTR(L"r:id", rId);
}
xlsx_pivots_context_.dump_rels_cache(i, content->get_rels());
xlsx_pivots_context_.write_cache_definitions_to(i, content->definitions());
xlsx_pivots_context_.write_cache_records_to(i, content->records());
output_document_->get_xl_files().add_pivot_cache(content);
}
}
}
int pivot_view_count = xlsx_pivots_context_.get_count();
if (pivot_view_count > 0)
{
for (int i = 0; i < pivot_view_count; i++)
{
package::pivot_table_content_ptr content = package::pivot_table_content::create();
xlsx_pivots_context_.dump_rels_view(i, content->get_rels());
xlsx_pivots_context_.write_table_view_to(i, content->content());
output_document_->get_xl_files().add_pivot_table(content);
}
}
if (xlsx_pivots_context_.is_connections())
{
std::wstringstream strm;
xlsx_pivots_context_.write_connections_to(strm);
output_document_->get_xl_files().set_connections( package::simple_element::create(L"connections.xml", strm.str()) );
}
}
}
@ -316,17 +363,33 @@ oox_chart_context & xlsx_conversion_context::current_chart()
throw std::runtime_error("internal error");
}
}
xlsx_xml_worksheet & xlsx_conversion_context::current_sheet()
xlsx_xml_worksheet & xlsx_conversion_context::current_sheet(int index)
{
if (!sheets_.empty())
{
return *sheets_.back().get();
if (index < 0) return *sheets_.back().get();
else return *sheets_[index].get();
}
else
{
throw std::runtime_error("internal error");
}
}
int xlsx_conversion_context::find_sheet_by_name(std::wstring tableName)
{
if (tableName.empty()) return -1;
if (0 == tableName.find(L"'"))
{
tableName = tableName.substr(1, tableName.length() - 2);
}
for (size_t i = 0; i < sheets_.size(); i++)
{
if (sheets_[i]->name() == tableName)
return i;
}
return -1;
}
void xlsx_conversion_context::create_new_sheet(std::wstring const & name)
{
sheets_.push_back(xlsx_xml_worksheet::create(name));
@ -381,9 +444,8 @@ void xlsx_conversion_context::end_table()
get_table_context().serialize_hyperlinks (current_sheet().hyperlinks());
get_table_context().serialize_ole_objects (current_sheet().ole_objects());
get_table_context().dump_rels_hyperlinks (current_sheet().hyperlinks_rels());
get_table_context().dump_rels_ole_objects (current_sheet().ole_objects_rels());
get_table_context().dump_rels_hyperlinks (current_sheet().sheet_rels());
get_table_context().dump_rels_ole_objects (current_sheet().sheet_rels());
if (!get_drawing_context().empty())
{

View File

@ -48,6 +48,7 @@
#include "xlsx_comments_context.h"
#include "xlsx_defined_names.h"
#include "xlsx_table_metrics.h"
#include "xlsx_pivots_context.h"
#include "oox_chart_context.h"
#include "mediaitems.h"
@ -101,7 +102,10 @@ public:
bool start_table (std::wstring tableName, std::wstring tableStyleName);
void end_table ();
void start_table_column (unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax);
int find_sheet_by_name(std::wstring tableName);
xlsx_xml_worksheet & current_sheet(int index = -1);
void start_table_column (unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax);
void table_column_last_width (double w);
double table_column_last_width ();
void end_table_column ();
@ -161,13 +165,13 @@ public:
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
const xlsx_table_context & get_table_context() const { return xlsx_table_context_; }
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
xlsx_xml_worksheet & current_sheet();
oox_chart_context & current_chart();
math_context & get_math_context() { return math_context_; }
num_format_context & get_num_format_context() { return num_format_context_; }
size_t get_default_cell_style() const { return default_style_; }
xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; }
xlsx_pivots_context & get_pivots_context() { return xlsx_pivots_context_;}
xlsx_table_metrics & get_table_metrics();
xlsx_drawing_context & get_drawing_context();
xlsx_drawing_context_handle & get_drawing_context_handle();
@ -202,6 +206,7 @@ private:
xlsx_table_context xlsx_table_context_;
xlsx_text_context xlsx_text_context_;
math_context math_context_;
xlsx_pivots_context xlsx_pivots_context_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
xlsx_comments_context_handle xlsx_comments_context_handle_;
};

View File

@ -35,7 +35,6 @@
#include <sstream>
#include <string>
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <cpdoccore/xml/xmlchar.h>

View File

@ -29,6 +29,8 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <boost/foreach.hpp>
#include "../docx/xlsx_textcontext.h"
#include "../docx/xlsx_num_format_context.h"
@ -275,12 +277,12 @@ void object_odf_context::calc_cache_series(std::wstring adress, std::vector<std:
oox::getCellAddressInv(ref_1, col_1,row_1);
oox::getCellAddressInv(ref_2, col_2,row_2);
BOOST_FOREACH(_cell & val,cash_values)
for (size_t i = 0; i < cash_values.size(); i++)
{
if (val.col>=col_1 && val.col<=col_2 &&
val.row>=row_1 && val.row<=row_2)
if (cash_values[i].col >= col_1 && cash_values[i].col <= col_2 &&
cash_values[i].row >= row_1 && cash_values[i].row <= row_2)
{
cash.push_back(val.val);
cash.push_back(cash_values[i].val);
}
}
}
@ -315,12 +317,12 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
chart_context.add_chart(class_);
}
BOOST_FOREACH(series & s, series_)
for (size_t i = 0; i < series_.size(); i++)
{
if (s.class_ != last_set_type) //разные типы серий в диаграмме - например бар и линия.
if (series_[i].class_ != last_set_type) //разные типы серий в диаграмме - например бар и линия.
{
chart_context.add_chart(s.class_);
last_set_type = s.class_;
chart_context.add_chart(series_[i].class_);
last_set_type = series_[i].class_;
}
oox::oox_chart_ptr current = chart_context.get_current_chart();
@ -331,11 +333,11 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
current->add_series(series_id++);
if (s.cell_range_address_.empty() )
s.cell_range_address_ = plot_area_.cell_range_address_; //SplitByColumn (ind_ser,range);
if (series_[i].cell_range_address_.empty() )
series_[i].cell_range_address_ = plot_area_.cell_range_address_; //SplitByColumn (ind_ser,range);
//SplitByRow (ind_ser,range);
if (s.cell_range_address_.empty())
s.cell_range_address_ = domain_cell_range_adress2_;
if (series_[i].cell_range_address_.empty())
series_[i].cell_range_address_ = domain_cell_range_adress2_;
//тут данные нужно поделить по столбцам или строкам - так как в плот-ареа общий диапазон
//первый столбец-строка МОЖЕт использоваться для подписей
@ -347,7 +349,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
std::vector<std::wstring> cat_cash;
calc_cache_series (domain_cell_range_adress_, domain_cash);
calc_cache_series (s.cell_range_address_, cell_cash);
calc_cache_series (series_[i].cell_range_address_, cell_cash);
if (categories_.size() >0)
calc_cache_series (categories_[0], cat_cash);
@ -356,8 +358,8 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
_CP_OPT(std::wstring) strVal;
_CP_OPT(bool) boolVal;
odf_reader::GetProperty(s.properties_, L"num_format", strVal);
odf_reader::GetProperty(s.properties_, L"link-data-style-to-source", boolVal);
odf_reader::GetProperty(series_[i].properties_, L"num_format", strVal);
odf_reader::GetProperty(series_[i].properties_, L"link-data-style-to-source", boolVal);
if ((strVal) && (strVal->length() > 1))
{
@ -371,7 +373,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
current->set_formula_series(4, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
current->set_values_series (4, domain_cash);
//y
current->set_formula_series(3, s.cell_range_address_, formatCode, boolVal.get_value_or(true));
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
current->set_values_series (3, cell_cash);
}
else
@ -379,13 +381,13 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
current->set_values_series (2, domain_cash);
//y
current->set_formula_series(3, s.cell_range_address_, formatCode, boolVal.get_value_or(true));
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
current->set_values_series (3, cell_cash);
}
}
else
{ //common
current->set_formula_series(1, s.cell_range_address_, formatCode, boolVal.get_value_or(true));
current->set_formula_series(1, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
current->set_values_series(1, cell_cash);
}
@ -394,9 +396,9 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
current->set_formula_series(0, categories_[0], L"General", true);
current->set_values_series(0, cat_cash);
}
current->set_name(s.name_);
current->set_name(series_[i].name_);
current->set_content_series(s);
current->set_content_series(series_[i]);
}
std::sort(axises_.begin(), axises_.end(), axises_sort());//file_1_ (1).odp
@ -501,9 +503,9 @@ void process_build_object::ApplyChartProperties(std::wstring style, std::vector<
if (!properties)return;
BOOST_FOREACH(_property const & p, properties->content_)
for (size_t i = 0; i < properties->content_.size(); i++)
{
propertiesOut.push_back(p);
propertiesOut.push_back(properties->content_[i]);
}
}
}
@ -835,7 +837,7 @@ void process_build_object::visit(table_table_rows& val)
}
void process_build_object::visit(const table_table_row & val)
{
unsigned int repeated = val.table_table_row_attlist_.table_number_rows_repeated_;
unsigned int repeated = val.attlist_.table_number_rows_repeated_;
ACCEPT_ALL_CONTENT_CONST(val.content_);
visit_rows(repeated);
}
@ -889,13 +891,13 @@ void process_build_object::visit(const table_rows_no_group& val)
}
void process_build_object::visit(const table_table_cell& val)
{
const table_table_cell_attlist & attlist = val.table_table_cell_attlist_;
const table_table_cell_attlist & attlist = val.attlist_;
unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_;
unsigned int repeated = val.attlist_.table_number_columns_repeated_;
std::wstringstream wstream_temp;
val.table_table_cell_content_.text_to_stream(wstream_temp);
val.content_.text_to_stream(wstream_temp);
std::wstring cell_cash = wstream_temp.str();
std::wstring cell_val;
@ -918,7 +920,7 @@ void process_build_object::visit(const table_table_cell& val)
}
void process_build_object::visit(const table_covered_table_cell& val)
{
unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_;
unsigned int repeated = val.attlist_.table_number_columns_repeated_;
if ( repeated <2)
return;

View File

@ -86,10 +86,10 @@ static const class_type_pair class_type_str[] =
chart::class_type static get_series_class_type(std::wstring const & str)
{
BOOST_FOREACH(class_type_pair const & p, class_type_str)
for (size_t i = 0; i < 12/*class_type_str.size()*/; i++)
{
if (p.class_type_str_ == str)
return p.class_type_;
if (class_type_str[i].class_type_str_ == str)
return class_type_str[i].class_type_;
}
return chart::chart_bar; //лучше хоть какой назначить чем никакой !!
}

View File

@ -0,0 +1,85 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "chartlabelposition.h"
#include <boost/algorithm/string.hpp>
#include <ostream>
namespace cpdoccore { namespace odf_types {
std::wostream & operator << (std::wostream & _Wostream, const chart_label_position & _Val)
{
switch(_Val.get_type())
{
case chart_label_position::avoid_overlap: _Wostream << L"avoid-overlap"; break;
case chart_label_position::bottom: _Wostream << L"bottom"; break;
case chart_label_position::bottom_left: _Wostream << L"bottom-left"; break;
case chart_label_position::bottom_right: _Wostream << L"bottom_right"; break;
case chart_label_position::center: _Wostream << L"center"; break;
case chart_label_position::inside: _Wostream << L"insidev"; break;
case chart_label_position::left: _Wostream << L"left"; break;
case chart_label_position::near_origin: _Wostream << L"near-origin"; break;
case chart_label_position::outside: _Wostream << L"outside"; break;
case chart_label_position::right: _Wostream << L"right"; break;
case chart_label_position::top: _Wostream << L"top"; break;
case chart_label_position::top_left: _Wostream << L"top-left"; break;
case chart_label_position::top_right: _Wostream << L"top-right"; break;
}
return _Wostream;
}
chart_label_position chart_label_position::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"avoid-overlap") return chart_label_position( avoid_overlap );
else if (tmp == L"bottom") return chart_label_position( bottom );
else if (tmp == L"bottom-left") return chart_label_position( bottom_left );
else if (tmp == L"bottom-right")return chart_label_position( bottom_right );
else if (tmp == L"center") return chart_label_position( center );
else if (tmp == L"inside") return chart_label_position( inside );
else if (tmp == L"left") return chart_label_position( left );
else if (tmp == L"near-origin") return chart_label_position( near_origin );
else if (tmp == L"outside") return chart_label_position( outside );
else if (tmp == L"right") return chart_label_position( right );
else if (tmp == L"top") return chart_label_position( top );
else if (tmp == L"top-left") return chart_label_position( top_left );
else if (tmp == L"top-right") return chart_label_position( top_right );
else
{
return chart_label_position( near_origin );
}
}
} }

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