Compare commits

..

289 Commits

Author SHA1 Message Date
533bc2c250 OdfFormatReader - presentation - actions 2017-05-17 19:47:34 +03:00
85226c0821 OdfFormatWriter - presentation audio backgrounds 2017-05-17 17:53:48 +03:00
fecefb672d . 2017-05-17 15:55:32 +03:00
f91e030836 . 2017-05-17 12:05:06 +03:00
d0591483bc Merge branches 'develop' and 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-05-17 11:59:41 +03:00
729f9f246f . 2017-05-17 11:57:44 +03:00
17a6ba735b linux & mac fake realize 2017-05-17 11:49:30 +03:00
de22fb4737 OdfFormatWriter - presentation sound, video objects, actions for shapes 2017-05-17 11:32:01 +03:00
751774419e . 2017-05-16 16:34:23 +03:00
8278609f10 . 2017-05-16 15:20:48 +03:00
445eedc7a3 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-05-16 14:46:03 +03:00
ed7661b93c ooxmlsignature library & test (full work version) 2017-05-16 14:22:22 +03:00
a17a04298a build linux 2017-05-16 12:39:01 +03:00
f7ba686f0c TestDocsWithChart 2017-05-15 20:21:11 +03:00
c41385e1ae open/save field ffdata 2017-05-15 20:20:26 +03:00
f582a9b690 . 2017-05-15 19:14:50 +03:00
b36c2dbaf9 verify ooxml file. first worked version 2017-05-15 18:14:19 +03:00
10b9e9e5e8 verify ooxml file. developing... 2017-05-15 16:44:50 +03:00
1beb5440f9 OdfFormatWriter - transitions 2017-05-15 14:03:20 +03:00
9a9ba4cc62 OdfFormatWriter - animations 2017-05-14 16:52:47 +03:00
5b4c6363bb OdfFormat - fix layouts 2017-05-13 16:05:23 +03:00
2026d064ef DocFormatReader - fix shape freeforms 2017-05-13 16:04:54 +03:00
42257ca447 verify ooxml file. developing... 2017-05-12 18:59:57 +03:00
6f2fdcd971 verify ooxml file. developing... 2017-05-12 18:25:18 +03:00
9b4b7a26fd verify ooxml file. developing... 2017-05-12 18:04:13 +03:00
4d688b3922 . 2017-05-12 13:46:13 +03:00
be8d427e26 . 2017-05-12 13:17:26 +03:00
7e0749ddda partly fix bug #18056 2017-05-12 11:33:04 +03:00
9f2324d208 verify ooxml file. developing... 2017-05-12 11:24:04 +03:00
6e258b85d7 . 2017-05-11 19:02:56 +03:00
24e55018a0 . 2017-05-11 18:43:24 +03:00
2352ae5d88 PptFormatReader - fix line shape ends 2017-05-11 18:08:46 +03:00
2cba43e6f3 . 2017-05-11 17:56:47 +03:00
abcf8d0246 x2t version up 2017-05-11 13:25:17 +03:00
c18b955467 . 2017-05-11 12:54:26 +03:00
7896b75001 PptFormatReader - presentation master notes & master handout 2017-05-11 12:52:12 +03:00
7d188b2213 PptFormatReader - presentation slide notes 2017-05-10 18:39:56 +03:00
79ead484cc fix bug #31878 2017-05-10 14:42:52 +03:00
be65f18a0e OdfFormatReader - presentation master notes 2017-05-09 19:04:37 +03:00
60f61109a1 OdfFormatReader - presentation slide notes 2017-05-09 16:08:29 +03:00
4201bcecc6 OdfFormatWriter - presentation notes masters 2017-05-07 11:04:36 +03:00
7b7bfbc5dd fix bug 34916 2017-05-07 09:36:56 +03:00
a70255e500 . 2017-05-06 09:17:04 +03:00
7e9dede9b3 xml sec classes (mscrypto) 2017-05-05 17:37:41 +03:00
9b7ad03465 OdfFormatWriter - presentation notes 2017-05-04 15:12:48 +03:00
3162bb0bfe open/save csv with user defined delimiters 2017-05-04 14:01:01 +03:00
ec95648c43 fix bug 34910 2017-05-04 11:21:05 +03:00
72ac11ac07 fix bug 34901 2017-05-04 11:03:49 +03:00
f70ea2b74f . 2017-05-03 17:49:39 +03:00
db834666ba OdfFormatWriter - colored hyperlink int shape 2017-05-03 12:21:57 +03:00
6ed0e13178 x2t version up 2017-05-03 11:09:07 +03:00
446e519110 . 2017-05-02 20:00:22 +03:00
fb1fc01963 OdfFormat - extended elements for smart arts 2017-05-02 19:09:56 +03:00
4651ae1bbb sign ooxml file (full realize) 2017-05-02 17:46:39 +03:00
18606e23c6 Content types correct 2017-05-02 17:00:15 +03:00
ed6d070d1f presetTableStyles.xml 2017-05-02 16:01:28 +03:00
f00cecbcaf rels transforms realize 2017-05-02 15:03:49 +03:00
c9aee26fd6 . 2017-05-01 17:19:02 +03:00
32d3c0e65c . 2017-04-30 18:19:52 +03:00
33aeef2c02 OdfFormat - spreadsheets - support page cover 2017-04-30 15:55:49 +03:00
7c97941acc . 2017-04-29 16:26:46 +03:00
01a4cd2289 OdfFormatWriter - fix errors after testing 2017-04-29 15:14:03 +03:00
202b58fb10 OdfFormatWriter - fix after testing 2017-04-28 20:02:56 +03:00
b221150797 return AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED in case of error in appling changes 2017-04-28 18:15:46 +03:00
2084587e9a remove res 2017-04-28 16:18:10 +03:00
8332c28ac2 Merge tag 'v4.3.3' into develop
v4.3.3 v4.3.3
2017-04-28 12:44:13 +03:00
435a11d75c . 2017-04-27 19:57:49 +03:00
9a5329f5d6 . 2017-04-27 16:12:28 +03:00
8eecbf5fa5 . 2017-04-27 16:08:38 +03:00
9e1773df65 Used ClrMap in docx settings 2017-04-27 15:57:44 +03:00
39e4140524 for save pivot 2017-04-27 15:46:06 +03:00
bd90de857e Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-04-27 13:51:47 +03:00
57f2ec7b96 graphicFrameLocks 2017-04-27 13:38:40 +03:00
634098a6fa fix reading xml attributes without namespace 2017-04-27 13:24:46 +03:00
bdbf208f6c open/save Sdt 2017-04-27 12:47:39 +03:00
a652f5d73f OdfFormatWriter - fix smart-art 2017-04-26 20:10:04 +03:00
1602843aa6 fix color alpha 2017-04-26 12:58:51 +03:00
cdb7fb8ea6 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  pivotButton; AddNoWrite defDir
  OdfFormat - fix after testing
  save pivotTables to xlsx
  windows sign (worked version)
  .
2017-04-26 12:46:48 +03:00
6387e9fa69 fix build converter ios 2017-04-26 12:46:41 +03:00
4e8097c93d pivotButton; AddNoWrite defDir 2017-04-26 11:10:58 +03:00
65254b57b2 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-04-25 19:31:42 +03:00
95899e23a8 OdfFormat - fix after testing 2017-04-25 19:30:40 +03:00
5c8757d346 save pivotTables to xlsx 2017-04-25 19:25:45 +03:00
234e19d68a Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-04-25 16:06:04 +03:00
62145b7204 windows sign (worked version) 2017-04-25 15:22:19 +03:00
8bcc6d1501 . 2017-04-25 15:05:58 +03:00
09ef46f333 fix bug #34836 2017-04-25 11:33:31 +03:00
1839350526 . 2017-04-24 19:57:38 +03:00
d7587e91b1 windows sign 2017-04-24 18:57:37 +03:00
7b0a342cf9 . 2017-04-24 17:49:47 +03:00
3d01b0782e . 2017-04-24 15:30:57 +03:00
fecfcfa7d2 . 2017-04-24 14:32:57 +03:00
29b5fa513a . 2017-04-24 13:26:50 +03:00
f9a19badbf DocFormatReader - fix embedded docx formula 2017-04-24 13:20:23 +03:00
d2630ea73c toXml - writer instead string; refreshedDate 2017-04-24 10:54:56 +03:00
a4a58c4782 x2t version up 2017-04-24 10:33:47 +03:00
29a3d80071 . 2017-04-23 16:36:12 +03:00
598bb419c0 OdfFormatWriter - presentation - fields 2017-04-23 16:31:00 +03:00
087da9d2ce . 2017-04-23 14:21:07 +03:00
c505aced48 . 2017-04-22 18:34:10 +03:00
959d5e5fcd OdfFormatWriter - presentation - fix multi-level list, master list styles 2017-04-22 13:05:10 +03:00
8ee0cf4b2c . 2017-04-21 19:26:01 +03:00
426342074e . 2017-04-21 19:08:59 +03:00
d2c092fe62 pivot 2017-04-21 15:05:23 +03:00
a336917338 OdfFormatWriter - image bullet presentation list style 2017-04-21 14:12:50 +03:00
8925ddeee5 big integer from buffer bug 2017-04-21 10:24:17 +03:00
84824631b2 OdfFormatWriter - presentation styled list 2017-04-20 19:55:18 +03:00
dc3ecb1fc0 BigInteger as string realization 2017-04-20 18:13:10 +03:00
266cef8c49 tests windows 2017-04-20 14:10:38 +03:00
a5e821cd21 . 2017-04-19 20:06:58 +03:00
cb5d92334e OdfFormatWriter - presentation ... 2017-04-18 16:40:03 +03:00
f6dbc6b9f0 fix bug #34762 2017-04-17 22:16:47 +03:00
c2c6430495 . 2017-04-17 18:55:02 +03:00
9ecf5b7834 Merge pull request #23 from ONLYOFFICE/hotfix/v4.3.2
Hotfix/v4.3.2
2017-04-17 17:12:30 +03:00
1d003863dd . 2017-04-17 17:10:12 +03:00
774561bd00 Merge branch 'develop' into hotfix/v4.3.2 2017-04-17 16:56:05 +03:00
d356a305b9 tests (mscrypto) 2017-04-17 16:45:35 +03:00
95c472c15c Merge branch 'hotfix/v4.3.2' 2017-04-17 14:59:08 +03:00
2dbec241f7 OdfFormatWriter - presentation comments 2017-04-17 14:06:14 +03:00
f3c66cab50 OdfFormatWriter 2017-04-17 09:56:12 +03:00
11e6fc3e06 . 2017-04-14 19:13:53 +03:00
cdf8c0a11b update libxml (for sec) 2017-04-14 19:03:02 +03:00
ae29cebe35 . 2017-04-14 15:26:29 +03:00
e933a1fb42 fix bug #34766 2017-04-14 13:12:50 +03:00
5a3f98c502 open notesMasters rels 2017-04-13 19:40:20 +03:00
8677540a82 . 2017-04-13 16:39:33 +03:00
f4ceac5b2b . 2017-04-13 16:23:43 +03:00
61be4ea100 . 2017-04-13 15:37:04 +03:00
51c6ce2ba2 . 2017-04-13 14:43:14 +03:00
e13bc44198 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-04-13 12:45:51 +03:00
56cefcb1be fix bug #34761 2017-04-13 12:45:11 +03:00
6f860c17e3 . 2017-04-13 11:45:29 +03:00
fb9edc4f81 . 2017-04-13 11:34:14 +03:00
4eb0a73f3c PptxFormat - delete unused
OdfFormatWriter - extended text styles
2017-04-13 11:31:20 +03:00
7929d798c8 open presentation notes 2017-04-12 19:40:09 +03:00
4c3d8ca059 . 2017-04-12 19:14:12 +03:00
ad74a8ea6b fix bug #34747 2017-04-11 17:11:56 +03:00
f50dda7c31 fix bug #34736 2017-04-11 15:28:51 +03:00
f78a805fa3 . 2017-04-11 13:17:58 +03:00
bc177269a9 OdfFormatReader - fix solid background in documents 2017-04-11 10:52:19 +03:00
84cab29276 fix build 2017-04-11 10:32:09 +03:00
d7c7584b4d OdfFormatWriter - slides size, ... 2017-04-11 10:24:53 +03:00
1346072ab2 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  x2t binary - dont write unsupported graphicData (sle:slicer)
  fix bugs after refactoring
  xmlsec
  OdfFormat ...
2017-04-10 16:26:59 +03:00
3b6b463b1b fix build converter ios 2017-04-10 16:26:50 +03:00
a75daf9d90 x2t binary - dont write unsupported graphicData (sle:slicer) 2017-04-10 11:10:22 +03:00
dc81f97bac fix bugs after refactoring 2017-04-09 20:55:53 +03:00
d194249ffb xmlsec 2017-04-08 14:26:26 +03:00
4ec04c31c5 OdfFormat ... 2017-04-07 18:36:47 +03:00
8774035be9 OdfFormatReader - presentation table extended graphics properties 2017-04-06 19:30:44 +03:00
8cec4ce82e OdfFormatWriter presentation layouts, layers
OdfFormat - nation style-name
2017-04-06 17:40:26 +03:00
17e46a2c99 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormatWriter - presentation tables styled
  OdfFormatWriter - presentation tables
2017-04-06 15:26:59 +03:00
c5ffcd4b44 open documents with password (ios) 2017-04-06 15:26:54 +03:00
51c77c3a85 Fixed downloading icu binaries from sourceforge 2017-04-05 19:59:56 +03:00
4326a7d258 fix bug 34695 2017-04-05 19:48:02 +03:00
38813fd105 OdfFormatWriter - presentation tables styled 2017-04-05 18:48:51 +03:00
19960fa3b5 OdfFormatWriter - presentation tables 2017-04-04 20:07:27 +03:00
32121d6d3b Merge tag 'v4.3.0' into develop
v4.3.0
2017-04-03 12:57:47 +03:00
2dcef22681 Merge branch 'release/v4.3.0' 2017-04-03 12:57:28 +03:00
ee5a56183e fix linux build 2017-04-03 12:20:12 +03:00
b90e3a3cd1 . 2017-04-03 11:49:20 +03:00
f074d1252b OdfFormatWriter - odp 2017-04-03 11:15:30 +03:00
30f07d3aa4 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-03-31 17:58:20 +03:00
d27b7b2f56 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  x2t version up
  for bug 34597
  fix bug 34603
  for bug 34498
2017-03-31 17:57:44 +03:00
1dbf3e83ad ios collaboration 2017-03-31 17:57:35 +03:00
a5f70c9740 x2t - change projects 2017-03-31 16:29:15 +03:00
ab72c8973d OdfFormatWriter - presentation hyperlink, backgrounds slides & masters 2017-03-31 16:06:31 +03:00
a204c576ad Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-03-31 11:29:41 +03:00
4a7d40d3fb x2t version up 2017-03-31 08:17:46 +03:00
4f5fb86f87 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-03-30 17:33:49 +03:00
f7f2629e9d for bug 34597 2017-03-30 16:51:08 +03:00
048c2fd034 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-03-30 16:04:22 +03:00
3299c47858 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-03-30 16:03:47 +03:00
8977e2c792 fix bug 34603 2017-03-30 16:02:23 +03:00
089e7d3230 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-03-30 11:00:56 +03:00
bd5863a02d for bug 34498 2017-03-29 20:12:04 +03:00
e0296d5a9a OdfFormatWriter - odp master page 2017-03-29 16:09:39 +03:00
e26cf3bf39 OdfFormatWriter - convert pptx->odp 2017-03-29 13:06:41 +03:00
8525a1e9f0 . 2017-03-29 13:04:40 +03:00
2e8c83a668 RtfFormat, TxtFormat - chage convert from ooxml drawing 2017-03-29 13:04:07 +03:00
e857496565 .. 2017-03-29 13:02:24 +03:00
143f65ae5a BinaryFormat - refactoring drawing objects, convert embedded objects, ole objects 2017-03-29 13:01:22 +03:00
f89d75ae92 PptxFormat refactoring and extending drawing objects 2017-03-29 12:57:07 +03:00
403507206d . 2017-03-29 12:52:52 +03:00
7f6431700c DocxFormat - refactoring, move common drawing in pptx format, ... 2017-03-29 12:52:17 +03:00
7977bcf069 . 2017-03-29 12:47:58 +03:00
32ad6b46e2 ooxml files encrypting 2017-03-29 12:35:09 +03:00
bf6bfce051 fix bug 34509 2017-03-24 20:02:11 +03:00
805c24ff1a fix bug 27498 2017-03-24 18:35:08 +03:00
2c4bb7c808 for bug 34498. ULong 2017-03-23 20:24:52 +03:00
15a711396f x2t xlsx outline level save/read in binary 2017-03-22 17:53:09 +03:00
3d8403346b fix added bug 34297 2017-03-20 17:42:00 +03:00
5700503efe fix build converter ios 2017-03-16 12:56:04 +03:00
d01b1e7d41 fix bug 33781 2017-03-15 13:28:49 +03:00
584cc6ab80 fix bug 34297 2017-03-11 18:47:30 +03:00
4b727edde8 . 2017-03-09 16:05:45 +03:00
9d10c4ddce Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-03-07 12:19:08 +03:00
d5026d014d . 2017-03-06 17:24:29 +03:00
ac0b7e4e22 fix bug 34019 2017-03-06 15:45:43 +03:00
623fe25415 fix 34229 2017-03-06 15:30:54 +03:00
c4c9d50aae fix bug 34222 2017-03-06 14:29:15 +03:00
5d8dda02ec pptx extended reading fix 2017-03-04 16:01:15 +03:00
bc3461147d fix pptx note slide default 2017-03-03 14:29:18 +03:00
80d4e6057b .. 2017-03-03 13:35:37 +03:00
2dc5c2916a .. 2017-03-03 13:28:16 +03:00
5f9631a3c5 .. 2017-03-02 13:14:27 +03:00
ef7df69036 linux build fix 2017-03-01 20:06:37 +03:00
b3961994d2 Pptx .. 2017-03-01 19:40:40 +03:00
927a847607 . 2017-03-01 18:14:33 +03:00
674cc6c1a2 fix doct->docx background page settings 2017-03-01 14:18:35 +03:00
5d77cf9473 add ../ path for dll path 2017-03-01 13:23:11 +03:00
512dad1d24 fix double write attribute in background 2017-02-28 20:02:54 +03:00
3d684934f1 fix ppt background
fix bug 34177
read attributes (from line props, shape props , effects, 3D) without namespace
2017-02-28 19:03:04 +03:00
dd6ac185fb fix - remove tmp pptx folder 2017-02-28 18:27:00 +03:00
9825b6e32e Error writing xlsx (wrong ConditionalFormatting place) 2017-02-27 20:27:31 +03:00
653008ebfc XlsxFormat (graphicFrame) 2017-02-27 18:26:50 +03:00
236e93aa9c add GlobalVariable 2017-02-27 16:46:17 +03:00
164c7faf94 ..fix previus 2017-02-27 12:35:49 +03:00
4c07ddbcc7 . 2017-02-26 22:22:46 +03:00
7be543c3a6 pptx format .. extended reading xml 2017-02-26 18:57:48 +03:00
ccb47b0bda . 2017-02-23 15:20:20 +03:00
8aefacd411 new chart witout office_drawing(faster...) 2017-02-22 19:57:15 +03:00
6cd5fbcaca . 2017-02-21 23:38:23 +03:00
7c964b3f9c .. 2017-02-21 19:17:24 +03:00
8c43c781bd fix build 2017-02-21 18:00:39 +03:00
7496de06f0 . 2017-02-21 13:19:21 +03:00
fdd443a2d7 . 2017-02-21 13:18:29 +03:00
037c4046eb PptxFormat - extending reading xml; sppr, txpr in chart without DrawingConverter 2017-02-21 11:32:31 +03:00
4e5ac14ca9 errors for builder (open/save) 2017-02-18 14:17:42 +03:00
dedf74b366 fix for build 2017-02-18 11:02:42 +03:00
6f2eef1137 .. 2017-02-17 16:42:49 +03:00
9a8d3edbef . 2017-02-17 16:33:19 +03:00
305ebda78d OfficeUtils - add sort for compress 2017-02-17 16:28:00 +03:00
114050c23e fix bug #33849 2017-02-16 19:26:50 +03:00
7eee0755bf RtfFormatReader - generate replacement text hyperlink if absent 2017-02-16 16:23:21 +03:00
c329f29e9a RtfFormatReader - fix hyperlink text 2017-02-16 15:49:08 +03:00
0f3a02ca7c . 2017-02-16 15:20:53 +03:00
62d4860873 pptx - extending reading xml 2017-02-16 15:08:53 +03:00
21666ee309 x2t verion up 2.0.3.440 2017-02-16 11:38:20 +03:00
47ff766e4e . 2017-02-15 11:36:04 +03:00
50cbc671b3 RtfFormatWriter - text in drawing shapes, ... 2017-02-13 20:11:52 +03:00
f2d3390bd4 RtfFormatWriter - fix custom shape path 2017-02-13 14:23:38 +03:00
fb5af12d7a OdfFormat - refactroing svg; RtfFormatWriter - add custom shapes 2017-02-12 15:38:51 +03:00
63655a97e9 .. 2017-02-11 15:32:29 +03:00
fdf032d9f8 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  RtfFormat - add office digital signatures
  bug with some jpeg
  x2t version up 2.0.3.438
  RtfFormat - fix croping image, ...
  RtfFormat - extended drawing
  fix bug #34016
  fix bug #34018
  fix bug 34011
  fix bug #33752 after refactoring
  fix convert oox group shape to vml group shape
  RtfFormatWriter - fix table cell width (auto)
  OdfFormat - Reader/Writer - background page (image, pattern, gradient)
  fix bug #33918
2017-02-10 18:16:27 +03:00
3b85b58558 up 2017-02-10 18:16:18 +03:00
00f1f40a1e RtfFormat - add office digital signatures 2017-02-10 18:09:48 +03:00
46c05a4c27 bug with some jpeg 2017-02-10 17:14:53 +03:00
f3a510bd58 x2t version up 2.0.3.438 2017-02-10 15:49:17 +03:00
45231b822c RtfFormat - fix croping image, ... 2017-02-10 15:02:00 +03:00
e0591675d2 RtfFormat - extended drawing 2017-02-09 17:20:02 +03:00
67a849f110 fix bug #34016 2017-02-09 14:24:31 +03:00
15800296f7 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-02-08 20:04:33 +03:00
52fe741f9a fix bug #34018 2017-02-08 20:03:38 +03:00
b3ee693890 fix bug 34011 2017-02-08 19:35:45 +03:00
8c2e1738ea fix bug #33752 after refactoring 2017-02-07 12:42:46 +03:00
bf33aed853 fix convert oox group shape to vml group shape 2017-02-06 20:07:58 +03:00
5869c7a02e RtfFormatWriter - fix table cell width (auto) 2017-02-06 13:55:01 +03:00
bbd429a994 OdfFormat - Reader/Writer - background page (image, pattern, gradient) 2017-02-05 15:57:17 +03:00
f4d636539e Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-02-03 18:34:43 +03:00
92e02257d7 fix bug #33918 2017-02-03 18:33:50 +03:00
d2046d7ccb add missed include 2017-02-03 18:15:57 +03:00
7bc35a157a Implemented case when the size of the masked image doesn't match to the size of the mask. 2017-02-03 18:02:28 +03:00
903245e8a7 fixed converter for iOS 2017-02-03 17:33:48 +03:00
25ee9c3c1c Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  x2t vesion up  2.0.3.435
  PDFReader: text clip
  .
  fix...
  .
  x2t version up
  DocxFormat - fix vml single geom position RtfFormat - read/write background page (solid, pattern, gradient, image)
2017-02-03 16:28:47 +03:00
9ead40d279 up header 2017-02-03 16:28:42 +03:00
e097379c21 x2t vesion up 2.0.3.435 2017-02-03 15:27:12 +03:00
f86579d601 PDFReader: text clip 2017-02-03 13:02:26 +03:00
de7511f243 . 2017-02-03 12:42:06 +03:00
9a68a75f70 fix... 2017-02-02 18:43:38 +03:00
e04388aa32 . 2017-02-02 16:53:20 +03:00
cee61e7a92 x2t version up 2017-02-02 16:31:02 +03:00
48185ed4e9 DocxFormat - fix vml single geom position
RtfFormat - read/write background page (solid, pattern, gradient, image)
2017-02-02 15:44:03 +03:00
7bea086784 Fixed bugs with reading pdf files. 2017-02-02 14:53:01 +03:00
774f9c42cb PDF bugs 2017-02-01 19:20:12 +03:00
10964d32e6 ... 2017-02-01 17:10:19 +03:00
da2493ed3b OdfFormatReader - fix math matrix 2017-02-01 16:15:32 +03:00
0a183f3505 fix bug #33886 2017-02-01 15:59:28 +03:00
ac6cc1ec24 pptx file with wrong rels 2017-02-01 15:05:08 +03:00
a1846da0da Merge tag 'v4.2.7' into develop
v4.2.7 v4.2.7
2017-02-01 12:49:34 +03:00
0bd10c28ac Merge branch 'hotfix/v4.2.7' 2017-02-01 12:49:29 +03:00
2367cee329 PptxFormat - fix user file with wrong rels 2017-01-31 19:59:20 +03:00
288d89301a fix bug 33801 2017-01-31 17:16:28 +03:00
4d519e8f26 x2t - version up, .. 2017-01-31 15:02:34 +03:00
1bd2c0b852 Merge branch 'hotfix/v4.2.7' into develop
fix bug 33867
2017-01-31 13:57:55 +03:00
82b0f4bce8 DiagramDrawing losing images 2017-01-31 13:50:16 +03:00
5635239274 fix crash on windows 2017-01-31 13:12:43 +03:00
1f979fc4cc . 2017-01-31 12:05:32 +03:00
80c4a65147 PptxFormat- fix convert oox drawing to vml drawing
RtfFormatWriter - convert oox drawing, convert smart art objects
2017-01-31 11:58:09 +03:00
765ca861fb fix bug 33842 (corrupted xlsx->csv convertion) 2017-01-27 15:22:14 +03:00
2181 changed files with 370947 additions and 59489 deletions

1
.gitignore vendored
View File

@ -43,3 +43,4 @@ OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
*.pdb
*.tlb
*.idb
**/.hg

View File

@ -232,7 +232,8 @@ namespace DocFileFormat
case sprmOldCIss:
case sprmCIss:
appendValueElement( parent, L"vertAlign", FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ), true );
if (iter->argumentsSize > 0 && iter->Arguments[0] < 3) //Metaevan.doc
appendValueElement( parent, L"vertAlign", FormatUtils::MapValueToWideString( iter->Arguments[0], &SuperscriptIndex[0][0], 3, 12 ), true );
break;
case sprmCRgLid0_80:

View File

@ -50,8 +50,8 @@ namespace DocFileFormat
EncryptionHeader( FileInformationBlock* fib, POLE::Stream* tableStream );
private:
CRYPT::CryptRC4Data crypt_data_rc4;
CRYPT::ECMADecryptor::_cryptData crypt_data_aes;
bool bStandard;
CRYPT::_rc4CryptData crypt_data_rc4;
CRYPT::_ecmaCryptData crypt_data_aes;
bool bStandard;
};
}

View File

@ -307,13 +307,11 @@ namespace DocFileFormat
if (!FormatUtils::IsControlSymbol(xchBullet))
{
ret.push_back(lvl.xst[0]);
ret.push_back(L'\0');
}
}
else
{
ret.push_back(L'\xF0B7');
ret.push_back(L'\0');
}
}
else

View File

@ -250,10 +250,6 @@ public:
{
pFile->WriteFile((BYTE*)m_pMetaHeader, m_lMetaHeaderSize);
}
if (NULL != m_pMetaFile)
{
pFile->WriteFile((BYTE*)m_pMetaFile, m_lMetaFileSize);
}
}
};

View File

@ -35,11 +35,23 @@
namespace DocFileFormat
{
struct _guides
{
unsigned char type;
unsigned char param_type1;
unsigned char param_type2;
unsigned char param_type3;
WORD param1;
WORD param2;
WORD param3;
};
class PathParser
{
public:
PathParser (const unsigned char* pSegmentInfo, unsigned int pSegmentInfoSize, const unsigned char* pVertices, unsigned int pVerticesSize)
PathParser (const unsigned char* pSegmentInfo, unsigned int pSegmentInfoSize, const unsigned char* pVertices, unsigned int pVerticesSize, std::vector<_guides> & guides)
{
if ((pSegmentInfo != NULL) && (pSegmentInfoSize > 0))
{
@ -105,31 +117,40 @@ namespace DocFileFormat
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pVertices, 2, pVerticesSize);
unsigned short cb = FormatUtils::BytesToUInt16(pVertices, 4, pVerticesSize);
if (0xfff0 == cb)
{
cb = 4;
for (unsigned short i = 0; i < nElems; ++i)
for (unsigned short i = 0; i < nElems; ++i)
{
POINT point;
if (0xfff0 == cb)
{
POINT point;
cb = 4;
point.x = FormatUtils::BytesToInt16(pVertices + 6, (i * cb), pVerticesSize);
point.y = FormatUtils::BytesToInt16(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
m_arPoints.push_back(point);
}
}
else
{
for (unsigned short i = 0; i < nElems; ++i)
else
{
POINT point;
point.x = FormatUtils::BytesToInt32(pVertices + 6, (i * cb), pVerticesSize);
point.y = FormatUtils::BytesToInt32(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
m_arPoints.push_back(point);
}
LONG lMinF = (LONG)0x80000000;
if (lMinF <= point.x)
{
int index = (DWORD)point.x - 0x80000000;
if (index >= 0 && index < guides.size())
{
point.x = guides[index].param3;
}
}
if (lMinF <= point.y)
{
int index = (DWORD)point.y - 0x80000000;
if (index >= 0 && index < guides.size())
{
point.y = guides[index].param3;
}
}
m_arPoints.push_back(point);
}
}
}

View File

@ -106,21 +106,20 @@ namespace DocFileFormat
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
}
std::list<OptionEntry> ExtractOptions() const
std::vector<OptionEntryPtr> ExtractOptions() const
{
std::list<OptionEntry> ret;
std::vector<OptionEntryPtr> ret;
//build the list of all option entries of this shape
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( *iter );
if ( opt != NULL )
if ( opt == NULL ) continue;
for ( size_t i = 0; i < opt->Options.size(); i++)
{
for ( std::vector<OptionEntry>::iterator oeIter = opt->Options.begin(); oeIter != opt->Options.end(); oeIter++ )
{
ret.push_back( *oeIter );
}
ret.push_back( opt->Options[i]);
}
}

View File

@ -568,18 +568,19 @@ namespace DocFileFormat
struct OptionEntry
{
OptionEntry() : pid(PropertyId_left), fBid(false), fComplex(false), op(0), opComplex(NULL)
OptionEntry() : pid(PropertyId_left), fBid(false), fComplex(false), op(0)
{
}
PropertyId pid;
bool fBid;
bool fComplex;
unsigned int op;
unsigned char* opComplex;
std::shared_ptr<unsigned char> opComplex;
};
typedef std::shared_ptr<OptionEntry> OptionEntryPtr;
class ShapeOptions: public Record
{
public:
@ -587,8 +588,8 @@ namespace DocFileFormat
static const unsigned short TYPE_CODE_0xF121 = 0xF121;
static const unsigned short TYPE_CODE_0xF122 = 0xF122;
std::vector<OptionEntry> Options;
std::map<PropertyId, OptionEntry> OptionsByID;
std::vector<OptionEntryPtr> Options;
std::map<PropertyId, OptionEntryPtr> OptionsByID;
ShapeOptions() : Record()
{
@ -596,8 +597,8 @@ namespace DocFileFormat
virtual ~ShapeOptions()
{
for (std::vector<OptionEntry>::iterator iter = Options.begin(); iter != Options.end(); ++iter)
RELEASEARRAYOBJECTS( iter->opComplex );
//for (std::vector<OptionEntry>::iterator iter = Options.begin(); iter != Options.end(); ++iter)
// RELEASEARRAYOBJECTS( iter->opComplex );
}
ShapeOptions (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance)
@ -606,16 +607,16 @@ namespace DocFileFormat
//instance is the count of properties stored in this record
OptionEntry entry;
//parse the flags and the simple values
for (unsigned int i = 0; i < instance; ++i)
{
OptionEntryPtr entry = std::shared_ptr<OptionEntry>(new OptionEntry());
unsigned short flag = Reader->ReadUInt16();
entry.pid = (PropertyId)FormatUtils::BitmaskToInt (flag, 0x3FFF);
entry.fBid = FormatUtils::BitmaskToBool (flag, 0x4000);
entry.fComplex = FormatUtils::BitmaskToBool (flag, 0x8000);
entry.op = Reader->ReadUInt32();
entry->pid = (PropertyId)FormatUtils::BitmaskToInt (flag, 0x3FFF);
entry->fBid = FormatUtils::BitmaskToBool (flag, 0x4000);
entry->fComplex = FormatUtils::BitmaskToBool (flag, 0x8000);
entry->op = Reader->ReadUInt32();
Options.push_back( entry );
}
@ -625,21 +626,12 @@ namespace DocFileFormat
//of the OptionEntry arry, sorted by pid
for (unsigned int i = 0; i < instance; ++i)
{
if (Options[i].fComplex)
{
int read_size = (int)Options[i].op + 6 ; //????
//todooo !!!! проверить все остальные !! тут размер в зависимости от типа Complex!!!
switch(Options[i].pid)
{
case PropertyId::gtextUNICODE:
case PropertyId::gtextFont:
read_size = (int)Options[i].op;
break;
}
Options[i].opComplex = Reader->ReadBytes( read_size, true );
if (Options[i]->fComplex && Options[i]->op > 0)
{
Options[i]->opComplex = std::shared_ptr<unsigned char>(Reader->ReadBytes( Options[i]->op, true ));
}
OptionsByID.insert(std::pair<PropertyId, OptionEntry>(Options[i].pid, Options[i]));
OptionsByID.insert(std::make_pair(Options[i]->pid, Options[i]));
}
Reader->Seek(( pos + size ), 0/*STREAM_SEEK_SET*/);

View File

@ -71,26 +71,26 @@ namespace DocFileFormat
{
struct __BITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
_UINT32 biSize;
_INT32 biWidth;
_INT32 biHeight;
_UINT16 biPlanes;
_UINT16 biBitCount;
_UINT32 biCompression;
_UINT32 biSizeImage;
_INT32 biXPelsPerMeter;
_INT32 biYPelsPerMeter;
_UINT32 biClrUsed;
_UINT32 biClrImportant;
};
struct __BITMAPCOREHEADER
{
DWORD bcSize; /* used to get to color table */
WORD bcWidth;
WORD bcHeight;
WORD bcPlanes;
WORD bcBitCount;
_UINT32 bcSize; /* used to get to color table */
_UINT16 bcWidth;
_UINT16 bcHeight;
_UINT16 bcPlanes;
_UINT16 bcBitCount;
};
Global::BlipType GetFormatPict(unsigned char* data, int size)
{
@ -136,14 +136,18 @@ namespace DocFileFormat
}
return btWin32;
}
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
bool VMLPictureMapping::ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
{
newXmlString.clear();
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(
NSDirectory::GetTempPath(), L"emb");
sTempXmlFile += L".xml";
std::wstring sTempFolder = m_ctx->_doc->m_sTempFolder;
if (sTempFolder.empty())
{
sTempFolder = NSFile::CFileBinary::GetTempPath();
}
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(sTempFolder, L"emb");
NSFile::CFileBinary file;
file.CreateFileW(sTempXmlFile);
file.WriteFile((BYTE*)xmlString.c_str(), xmlString.size());
@ -186,6 +190,7 @@ namespace DocFileFormat
if (res) break;
}
}
NSFile::CFileBinary::Remove(sTempXmlFile);
return res;
}
//---------------------------------------------------------------
@ -236,7 +241,7 @@ namespace DocFileFormat
std::wstring strHeight = FormatUtils::DoubleToWideString( height.ToPoints() );
std::wstring strStyle;
std::list<OptionEntry> options;
std::vector<OptionEntryPtr> options;
PictureFrameType type;
if ((pict->shapeContainer || pict->blipStoreEntry) && pict->shapeContainer->Children.size() > 0)
@ -277,9 +282,9 @@ namespace DocFileFormat
}
//todooo oбъединить с shape_mapping
std::list<OptionEntry>::iterator end = options.end();
for (std::list<OptionEntry>::iterator iter = options.begin(); iter != end; ++iter)
for (size_t i = 0; i < options.size(); i++)
{
OptionEntryPtr & iter = options[i];
switch ( iter->pid )
{
case wzEquationXML:
@ -287,7 +292,7 @@ namespace DocFileFormat
m_isEquation = true;
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
m_embeddedData = std::string((char*)iter->opComplex.get(), iter->op);
if (ParseEmbeddedEquation( m_embeddedData, m_equationXml))
{
@ -297,8 +302,13 @@ namespace DocFileFormat
case metroBlob:
{
//встроенная неведомая хуйня
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex.get(), iter->op);
//if (ParseEmbeddedBlob( m_embeddedData, m_blobXml)) // todoooo
//{
// m_isEmbedded = false;
//}
}break;
//BORDERS
case borderBottomColor:

View File

@ -46,7 +46,6 @@ namespace DocFileFormat
{
class OleObject;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
class VMLPictureMapping: public PropertiesMapping, public IMapping
{
@ -58,6 +57,7 @@ namespace DocFileFormat
/// Writes a border element
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const;
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
protected:
/// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image.

View File

@ -143,8 +143,9 @@ namespace DocFileFormat
ShapeContainer* groupShape = static_cast<ShapeContainer*>(container->Children[0]);
GroupShapeRecord* gsr = static_cast<GroupShapeRecord*>(groupShape->Children[0]);
Shape* shape = static_cast<Shape*>(groupShape->Children[1]);
std::list<OptionEntry> options = groupShape->ExtractOptions();
ChildAnchor* anchor = groupShape->FirstChildWithType<ChildAnchor>();
ChildAnchor* anchor = groupShape->FirstChildWithType<ChildAnchor>();
std::vector<OptionEntryPtr> options = groupShape->ExtractOptions();
m_shapeId = GetShapeID(shape);
@ -155,14 +156,13 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"coordsize", ( FormatUtils::IntToWideString(gsr->rcgBounds.size.cx) + L"," + FormatUtils::IntToWideString(gsr->rcgBounds.size.cy)));
// Write wrap coords
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
for (size_t i = 0; i < options.size(); i++)
{
switch (iter->pid)
switch (options[i]->pid)
{
case pWrapPolygonVertices:
case pWrapPolygonVertices:
{
std::wstring wrapCoords = getWrapCoords(*iter);
std::wstring wrapCoords = GetWrapCoords(options[i]);
if (wrapCoords.length())
m_pXmlWriter->WriteAttribute(L"wrapcoords", wrapCoords);
}
@ -226,9 +226,9 @@ namespace DocFileFormat
bool freeform = true;
std::wstring sShapeId;
std::list<OptionEntry> options = pContainer->ExtractOptions();
ChildAnchor* pAnchor = pContainer->FirstChildWithType<ChildAnchor>();
ClientAnchor* clientAnchor = pContainer->FirstChildWithType<ClientAnchor>();
std::vector<OptionEntryPtr> options = pContainer->ExtractOptions();
ChildAnchor* pAnchor = pContainer->FirstChildWithType<ChildAnchor>();
ClientAnchor* clientAnchor = pContainer->FirstChildWithType<ClientAnchor>();
WriteBeginShapeNode (pShape);
@ -294,13 +294,17 @@ namespace DocFileFormat
std::wstring sTextboxStyle;
std::wstring adjValues[8];
ShadowStyleBooleanProperties shadowBoolean(0);
std::vector<std::wstring> arrInscribe;
OptionEntryPtr opSegmentInfo;
OptionEntryPtr opVerticles;
OptionEntryPtr opInscribe;
OptionEntryPtr opConnectAngles;
OptionEntryPtr opConnectLocs;
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
for (size_t i = 0; i < options.size(); i++)
{
OptionEntryPtr & iter = options[i];
switch (iter->pid)
{
//BOOLEANS
@ -335,19 +339,16 @@ namespace DocFileFormat
}
}
break;
case protectionBooleans:
{
ProtectionBooleanProperties booleans(iter->op);
}
break;
case diagramBooleans:
{
DiagramBooleanProperties booleans(iter->op);
}
break;
case groupShapeBooleans:
{
GroupShapeBooleanProperties booleans(iter->op);
@ -357,56 +358,80 @@ namespace DocFileFormat
}
}
break;
// GEOMETRY
// GEOMETRY
case shapePath :
{
bHavePath = true;
}break;
case pVertices:
{
opVerticles = iter;
}break;
case pSegmentInfo:
{
opSegmentInfo = iter;
}break;
case pGuides:
{
GetGuides(iter);
}break;
case pConnectionSites:
{
opConnectLocs = iter;
}break;
case pConnectionSitesDir:
{
opConnectAngles = iter;
}break;
case pInscribe:
{
opInscribe = iter;
}break;
case adjustValue:
{
adjValues[0] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,1);
m_nAdjValues[0] = (int)iter->op;
nAdjValues = (std::max)(nAdjValues,1);
}
break;
case adjust2Value:
{
adjValues[1] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,2);
m_nAdjValues[1] = (int)iter->op;
nAdjValues = (std::max)(nAdjValues, 2);
}
break;
case adjust3Value:
{
adjValues[2] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,3);
m_nAdjValues[2] = (int)iter->op;
nAdjValues =(std::max)(nAdjValues, 3);
}break;
case adjust4Value:
{
adjValues[3] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,4);
m_nAdjValues[3] = (int)iter->op;
nAdjValues = (std::max)(nAdjValues, 4);
}break;
case adjust5Value:
{
adjValues[4] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,5);
m_nAdjValues[4] = (int)iter->op;
nAdjValues = (std::max)(nAdjValues, 5);
}break;
case adjust6Value:
{
adjValues[5] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,6);
m_nAdjValues[5] = (int)iter->op;
nAdjValues = (std::max)(nAdjValues, 6);
}break;
case adjust7Value:
{
adjValues[6] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,7);
m_nAdjValues[6] = (int)iter->op;
nAdjValues = (std::max)(nAdjValues, 7);
}break;
case adjust8Value:
{
adjValues[7] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,8);
m_nAdjValues[7] = (int)iter->op;
nAdjValues = (std::max)(nAdjValues, 8);
}break;
case pWrapPolygonVertices:
{
std::wstring wrapCoords = getWrapCoords(*iter);
std::wstring wrapCoords = GetWrapCoords(iter);
if (!wrapCoords.empty())
{
@ -421,13 +446,6 @@ namespace DocFileFormat
{
yCoord = iter->op;
}break;
case pGuides:
{
}break;
case pInscribe:
{
arrInscribe = GetTextRectangles(*iter);
}break;
// OUTLINE
case lineColor:
{
@ -497,7 +515,7 @@ namespace DocFileFormat
}break;
case fillShadeColors:
{
appendValueAttribute(&m_fill, L"colors", getFillColorString( iter->opComplex, iter->op ));
appendValueAttribute(&m_fill, L"colors", getFillColorString( iter->opComplex.get(), iter->op ));
}break;
case fillFocus:
{
@ -602,7 +620,7 @@ namespace DocFileFormat
case pibName:
{
std::wstring name;
FormatUtils::GetSTLCollectionFromBytes<std::wstring>(&name, iter->opComplex, iter->op, ENCODING_UTF16);
FormatUtils::GetSTLCollectionFromBytes<std::wstring>(&name, iter->opComplex.get(), iter->op, ENCODING_UTF16);
if (!name.empty())
appendValueAttribute(&m_imagedata, L"o:title", FormatUtils::XmlEncode(name));
}break;
@ -676,10 +694,10 @@ namespace DocFileFormat
hasTextbox = true;
nLTxID = (((iter->op) >> 16) & 0xFFFF);
}break;
case dxTextLeft: {ndxTextLeft = (int)iter->op;break;}
case dyTextTop: {ndyTextTop = (int)iter->op;break;}
case dxTextRight: {ndxTextRight = (int)iter->op;break;}
case dyTextBottom: {ndyTextBottom = (int)iter->op;break;}
case dxTextLeft: {ndxTextLeft = (int)iter->op; break;}
case dyTextTop: {ndyTextTop = (int)iter->op; break;}
case dxTextRight: {ndxTextRight = (int)iter->op; break;}
case dyTextBottom: {ndyTextBottom = (int)iter->op; break;}
case txflTextFlow:
{
switch(iter->op)
@ -700,7 +718,7 @@ namespace DocFileFormat
// Word Art
case gtextUNICODE:
{
std::wstring text = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op)/2);
std::wstring text = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex.get(), (iter->op)/2);
text = FormatUtils::XmlEncode(text);
@ -713,7 +731,7 @@ namespace DocFileFormat
}break;
case gtextFont:
{
std::wstring font = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op)/2);
std::wstring font = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex.get(), (iter->op)/2);
int i = font.size();
while (i > 0)
{
@ -764,31 +782,31 @@ namespace DocFileFormat
appendStyleProperty(&m_textPathStyle, L"font-weight", L"bold");
}
}break;
// PATH
case shapePath :
{
bHavePath = true;
std::wstring path = ParsePath(options);
if (false == path.empty())
m_pXmlWriter->WriteAttribute (L"path", path);
}break;
default:
default:
{
int val = iter->op;
}break;
}
}
if (false == bHavePath) // фигура может быть задана только наборами вершин и индексов
if (opVerticles && opSegmentInfo)
{
std::wstring path = ParsePath(options);
const unsigned char* pVP = opVerticles->opComplex.get();
unsigned int nVP = opVerticles->op;
const unsigned char* pSI = opSegmentInfo->opComplex.get();
unsigned int nSI = opSegmentInfo->op;
PathParser oParser (pSI, nSI, pVP, nVP, m_arrGuides);
std::wstring path = oParser.GetVmlPath();
if (false == path.empty())
m_pXmlWriter->WriteAttribute (L"path", path);
}
if (freeform && (xCoord == 0 || yCoord == 0 ))
{
xCoord = 21600;
yCoord = 21600;
}
if ( !filled )
{
m_pXmlWriter->WriteAttribute( L"filled", L"f" );
@ -804,10 +822,10 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"o:allowincell", L"f");
}
if ( ( xCoord > 0 ) && ( yCoord > 0 ) )
if ( xCoord > 0 && yCoord > 0 )
{
m_pXmlWriter->WriteAttribute( L"coordsize", ( FormatUtils::IntToWideString( xCoord ) + L"," + FormatUtils::IntToWideString( yCoord ) ));
}
}
int nCode = 0;
if (pShape->GetShapeType())
@ -819,17 +837,17 @@ namespace DocFileFormat
{
if (nAdjValues)
{
m_pXmlWriter->WriteAttribute(L"arcsize", adjValues[0]);
m_pXmlWriter->WriteAttribute(L"arcsize", m_nAdjValues[0]);
}
}
else
{
if (nAdjValues)
if (nAdjValues > 0)
{
std::wstring adjTag = adjValues[0];
std::wstring adjTag = std::to_wstring(m_nAdjValues[0]);
for (int i = 1; i < nAdjValues; ++i)
adjTag += std::wstring(L",") + adjValues[i];
adjTag += L"," + std::to_wstring(m_nAdjValues[i]);
m_pXmlWriter->WriteAttribute(L"adj", adjTag);
}
@ -982,10 +1000,24 @@ namespace DocFileFormat
}
if (freeform)
{
if (arrInscribe.size())
if (opInscribe || opConnectAngles || opConnectLocs)
{
std::vector<std::wstring> arrInscribe = GetTextRectangles(opInscribe);
std::wstring strConnectAngles = GetConnectAngles(opConnectAngles);
std::wstring strConnectLocs = GetConnectLocs(opConnectLocs);
m_pXmlWriter->WriteNodeBegin(L"v:path", true);
m_pXmlWriter->WriteAttribute(L"textboxrect", arrInscribe[0]);
if (!arrInscribe.empty())
m_pXmlWriter->WriteAttribute(L"textboxrect", arrInscribe[0]);
if (!strConnectAngles.empty() || !strConnectLocs.empty())
{
m_pXmlWriter->WriteAttribute(L"o:connecttype", L"custom");
if (!strConnectLocs.empty())
m_pXmlWriter->WriteAttribute(L"o:connectlocs", strConnectLocs);
if (!strConnectAngles.empty())
m_pXmlWriter->WriteAttribute(L"o:connectangles", strConnectAngles);
}
m_pXmlWriter->WriteNodeEnd(L"", true);
}
}
@ -1182,11 +1214,13 @@ namespace DocFileFormat
}
/// Build the VML wrapcoords string for a given pWrapPolygonVertices
std::wstring VMLShapeMapping::getWrapCoords(const OptionEntry& pWrapPolygonVertices) const
std::wstring VMLShapeMapping::GetWrapCoords(const OptionEntryPtr& pWrapPolygonVertices) const
{
if (!pWrapPolygonVertices) return L"";
std::wstring coords;
MemoryStream oStream(pWrapPolygonVertices.opComplex, pWrapPolygonVertices.op);
MemoryStream oStream(pWrapPolygonVertices->opComplex.get(), pWrapPolygonVertices->op);
std::list<int> arrVertices;
unsigned short nElems = oStream.ReadUInt16();
@ -1498,7 +1532,7 @@ namespace DocFileFormat
}
}
void VMLShapeMapping::AppendOptionsToStyle (std::wstring* oStyle, const std::list<OptionEntry>& options, int zIndex) const
void VMLShapeMapping::AppendOptionsToStyle (std::wstring* oStyle, const std::vector<OptionEntryPtr>& options, int zIndex) const
{
bool bRelH = false;
bool bRelV = false;
@ -1508,9 +1542,9 @@ namespace DocFileFormat
bool bZIndex = false;
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
for (size_t i = 0; i < options.size(); i++)
{
const OptionEntryPtr & iter = options[i];
switch (iter->pid)
{
// POSITIONING
@ -1616,15 +1650,16 @@ namespace DocFileFormat
}
//
std::wstring VMLShapeMapping::buildStyle (const Shape* shape, const ChildAnchor* anchor, const std::list<OptionEntry>& options, int zIndex) const
std::wstring VMLShapeMapping::buildStyle (const Shape* shape, const ChildAnchor* anchor, const std::vector<OptionEntryPtr>& options, int zIndex) const
{
std::wstring style;
// Check if some properties are set that cause the dimensions to be twisted
bool twistDimensions = false;
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
for (size_t i = 0; i < options.size(); i++)
{
const OptionEntryPtr & iter = options[i];
if (geometryTextBooleanProperties == iter->pid)
{
GeometryTextBooleanProperties props(iter->op);
@ -1860,61 +1895,210 @@ namespace DocFileFormat
return wrapType;
}
std::wstring VMLShapeMapping::ParsePath (const std::list<OptionEntry>& options) const
std::wstring VMLShapeMapping::GetConnectAngles(const OptionEntryPtr& opAngles) const
{
const unsigned char* pVP = NULL;
unsigned int nVP = 0;
const unsigned char* pSI = NULL;
unsigned int nSI = 0;
if (!opAngles) return L"";
if (!opAngles->opComplex) return L"";
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
MemoryStream reader(opAngles->opComplex.get(), opAngles->op);
unsigned short nElems = reader.ReadUInt16();
unsigned short nElemsAlloc = reader.ReadUInt16();
unsigned short nElemSize = reader.ReadUInt16();
bool bTruncated = false;
if (0xFFF0 == nElemSize)
{
nElemSize = 4;
bTruncated = true;
}
long dwSize = nElems * nElemSize;
if (opAngles->op - 6 != (dwSize))
{
bool b = false;
}
if (nElemSize < 1) return L"";
int count = dwSize / nElemSize;
std::wstring angles;
for (int i = 0; i < count; ++i)
{
if (iter->pid == pVertices)
{
pVP = iter->opComplex;
nVP = iter->op;
}
if (iter->pid == pSegmentInfo)
{
pSI = iter->opComplex;
nSI = iter->op;
}
DWORD v = reader.ReadUInt32();
double val = (double)((WORD)(v >> 16) + ((WORD)(v) / 65536.0));
angles += std::to_wstring((int)val) + (i < (count - 1) ? L"," : L"");
}
return angles;
}
int VMLShapeMapping::UpdateFromGuides(const int val) const
{
int new_val = val;
LONG lMinF = (LONG)0x80000000;
if (lMinF <= val)
{
int index = (DWORD)val - 0x80000000;
if (index >= 0 && index < m_arrGuides.size())
{
new_val = m_arrGuides[index].param3;
}
PathParser oParser (pSI, nSI, pVP, nVP);
return oParser.GetVmlPath();
}
return new_val;
}
void VMLShapeMapping::GetGuides( const OptionEntryPtr& opGuides )
{
if (!opGuides) return;
if (!opGuides->opComplex) return;
MemoryStream reader(opGuides->opComplex.get(), opGuides->op);
unsigned short nElems = reader.ReadUInt16();
unsigned short nElemsAlloc = reader.ReadUInt16();
unsigned short nElemSize = reader.ReadUInt16();
bool bTruncated = false;
if (0xFFF0 == nElemSize)
{
nElemSize = 4;
bTruncated = true;
}
long dwSize = nElems * nElemSize;
if (opGuides->op - 6 != (dwSize))
{
bool b = false;
}
int count = dwSize / nElemSize; //1x (int or short)
for (int i = 0; i < count; ++i)
{
_guides g;
WORD flags = reader.ReadUInt16();
g.type = flags & 0x1FFF;
g.param_type1 = (unsigned char)(flags & 0x04);
g.param_type2 = (unsigned char)(flags & 0x02);
g.param_type3 = (unsigned char)(flags & 0x01);
g.param1 = reader.ReadUInt16();
g.param2 = reader.ReadUInt16();
g.param3 = reader.ReadUInt16();
m_arrGuides.push_back(g);
}
}
//
std::vector<std::wstring> VMLShapeMapping::GetTextRectangles(const OptionEntry& inscribe) const
std::wstring VMLShapeMapping::GetConnectLocs( const OptionEntryPtr& opLocs ) const
{
MemoryStream reader(inscribe.opComplex, inscribe.op + 6);
if (!opLocs) return L"";
if (!opLocs->opComplex) return L"";
unsigned short elems = reader.ReadUInt16();
unsigned short allocElems = reader.ReadUInt16();
unsigned short cb = reader.ReadUInt16();
MemoryStream reader(opLocs->opComplex.get(), opLocs->op);
unsigned short nElems = reader.ReadUInt16();
unsigned short nElemsAlloc = reader.ReadUInt16();
unsigned short nElemSize = reader.ReadUInt16();
bool bTruncated = false;
if (0xFFF0 == nElemSize)
{
nElemSize = 4;
bTruncated = true;
}
long dwSize = nElems * nElemSize;
if (opLocs->op - 6 != (dwSize))
{
bool b = false;
}
int count = dwSize / nElemSize; //2x (int or short)
std::wstring locs;
for (int i = 0; i < count; ++i)
{
POINT pt;
if (bTruncated)
{
pt.x = reader.ReadInt16();
pt.y = reader.ReadInt16();
}
else
{
pt.x = reader.ReadInt32();
pt.y = reader.ReadInt32();
}
pt.x = UpdateFromGuides(pt.x);
pt.y = UpdateFromGuides(pt.y);
locs += std::to_wstring(pt.x) + L"," + std::to_wstring(pt.y) + (i < (count - 1) ? L";" : L"");
}
return locs;
}
std::vector<std::wstring> VMLShapeMapping::GetTextRectangles( const OptionEntryPtr& opInscribe ) const
{
std::vector<std::wstring> rectangles;
if (!opInscribe) return rectangles;
if (!opInscribe->opComplex) return rectangles;
if (16 != cb) return rectangles; // TODO: доделать
MemoryStream reader(opInscribe->opComplex.get(), opInscribe->op);
int count = (inscribe.op) / 16;
unsigned short nElems = reader.ReadUInt16();
unsigned short nElemsAlloc = reader.ReadUInt16();
unsigned short nElemSize = reader.ReadUInt16();
bool bTruncated = false;
if (0xFFF0 == nElemSize)
{
nElemSize = 4;
bTruncated = true;
}
long dwSize = nElems * nElemSize;
if (opInscribe->op - 6 != (dwSize))
{
bool b = false;
}
int count = dwSize / nElemSize; //4x (int or short)
for (int i = 0; i < count; ++i)
{
RECT rc;
rc.top = reader.ReadInt32();
rc.left = reader.ReadInt32();
rc.right = reader.ReadInt32();
rc.bottom = reader.ReadInt32();
if (bTruncated)
{
rc.top = reader.ReadInt16();
rc.left = reader.ReadInt16();
rc.right = reader.ReadInt16();
rc.bottom = reader.ReadInt16();
}
else
{
rc.top = reader.ReadInt32();
rc.left = reader.ReadInt32();
rc.right = reader.ReadInt32();
rc.bottom = reader.ReadInt32();
}
rc.top = UpdateFromGuides(rc.top);
rc.left = UpdateFromGuides(rc.left);
rc.right = UpdateFromGuides(rc.right);
rc.bottom = UpdateFromGuides(rc.bottom);
std::wstringstream sstream;
sstream << boost::wformat(L"%d,%d,%d,%d") % rc.top % rc.left % rc.right % rc.bottom;
rectangles.push_back(sstream.str());
rectangles.push_back( std::to_wstring(rc.top) + L"," + std::to_wstring(rc.left) + L"," +
std::to_wstring(rc.right) + L"," + std::to_wstring(rc.bottom));
}
return rectangles;

View File

@ -77,17 +77,10 @@ namespace DocFileFormat
void WritePrimitiveProps(DrawingPrimitive * primitive, bool root);
// Converts a group of shapes
void WriteGroup(const GroupContainer* pContainer);
// Converts a single shape
void WriteShape (const ShapeContainer* pContainer);
/// Generates a string id for the given shape
std::wstring GenShapeId(const Shape* pShape) const;
/// Build the VML wrapcoords string for a given pWrapPolygonVertices
std::wstring getWrapCoords( const OptionEntry& pWrapPolygonVertices ) const;
/// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image.
bool copyPicture( const BlipStoreEntry* bse );
std::wstring GetTargetExt( Global::BlipType _type ) const;
@ -98,21 +91,22 @@ namespace DocFileFormat
std::wstring getTextboxAnchor( unsigned int anchor ) const;
void AppendOptionsToStyle( std::wstring* style, const std::list<OptionEntry>& options, int zIndex ) const;
std::wstring buildStyle ( const Shape* shape, const ChildAnchor* anchor, const std::vector<OptionEntryPtr>& options, int zIndex ) const;
void AppendOptionsToStyle ( std::wstring* style, const std::vector<OptionEntryPtr>& options, int zIndex ) const;
std::wstring buildStyle ( const Shape* shape, const ChildAnchor* anchor, const std::list<OptionEntry>& options, int zIndex ) const;
int UpdateFromGuides(const int val) const;
std::wstring getLineStyle ( unsigned int p ) const;
std::wstring getArrowStyle ( unsigned int op ) const;
std::wstring getArrowLength ( unsigned int op ) const;
std::wstring getArrowWidth ( unsigned int op ) const;
std::wstring getFillMethod ( unsigned int p ) const;
std::wstring getFillColorString( const unsigned char* p, unsigned int size ) const;
/// Returns the OpenXML fill type of a fill effect
std::wstring getFillType ( unsigned int p ) const;
std::wstring getShadowType ( unsigned int p ) const;
/// Returns the OpenXML wrap type of the shape
std::wstring getWrapType (const Spa* pSpa) const;
std::wstring ParsePath (const std::list<OptionEntry>& options) const;
void WriteBeginShapeNode (const Shape* pShape);
void WriteEndShapeNode (const Shape* pShape);
@ -121,9 +115,15 @@ namespace DocFileFormat
std::wstring GetLineFrom (const ChildAnchor* pAnchor) const;
std::wstring GetLineTo (const ChildAnchor* pAnchor) const;
std::vector<std::wstring> GetTextRectangles(const OptionEntry& inscribe) const;
std::wstring GetWrapCoords ( const OptionEntryPtr& pOpt ) const;
std::vector<std::wstring> GetTextRectangles ( const OptionEntryPtr& pOpt ) const;
std::wstring GetConnectAngles ( const OptionEntryPtr& pOpt ) const;
std::wstring GetConnectLocs ( const OptionEntryPtr& pOpt ) const;
void GetGuides ( const OptionEntryPtr& pOpt );
private:
int m_nAdjValues[8];
std::vector<_guides> m_arrGuides;
bool m_isInlineShape;
Spa* m_pSpa;
IMapping* m_pCaller;

View File

@ -86,6 +86,7 @@ namespace DocFileFormat
friend class Table;
friend class TableRow;
friend class VMLShapeMapping;
friend class VMLPictureMapping;
friend class OpenXmlPackage;
friend class TextboxMapping;

View File

@ -37,29 +37,29 @@
namespace ImageHelper
{
struct __BITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
};
struct __BITMAPINFOHEADER
{
_UINT32 biSize;
_INT32 biWidth;
_INT32 biHeight;
_UINT16 biPlanes;
_UINT16 biBitCount;
_UINT32 biCompression;
_UINT32 biSizeImage;
_INT32 biXPelsPerMeter;
_INT32 biYPelsPerMeter;
_UINT32 biClrUsed;
_UINT32 biClrImportant;
};
struct __BITMAPCOREHEADER
{
DWORD bcSize; /* used to get to color table */
WORD bcWidth;
WORD bcHeight;
WORD bcPlanes;
WORD bcBitCount;
};
struct __BITMAPCOREHEADER
{
_UINT32 bcSize; /* used to get to color table */
_UINT16 bcWidth;
_UINT16 bcHeight;
_UINT16 bcPlanes;
_UINT16 bcBitCount;
};
inline Global::_BlipType SaveImageToFileFromDIB(unsigned char* data, int size, const std::wstring& file_name)//without ext
{
@ -152,10 +152,10 @@ namespace ImageHelper
NSFile::CFileBinary file;
if (file.CreateFileW(file_name + L".bmp"))
{
WORD vtType = 0x4D42; file.WriteFile((BYTE*)&vtType, 2);
DWORD dwLen = biSizeImage; file.WriteFile((BYTE*)&dwLen, 4);
DWORD dwRes = 0; file.WriteFile((BYTE*)&dwRes, 4);
DWORD dwOffset = 2; file.WriteFile((BYTE*)&dwOffset, 4);
_UINT16 vtType = 0x4D42; file.WriteFile((BYTE*)&vtType, 2);
_UINT32 dwLen = biSizeImage; file.WriteFile((BYTE*)&dwLen, 4);
_UINT32 dwRes = 0; file.WriteFile((BYTE*)&dwRes, 4);
_UINT32 dwOffset = 2; file.WriteFile((BYTE*)&dwOffset, 4);
file.WriteFile((BYTE*)data, size);
file.CloseFile();

View File

@ -23,9 +23,9 @@ DEFINES += UNICODE \
_UNICODE \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
USE_ATL_CSTRING \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS \
INCLUDEPATH += \
../../../DesktopEditor/freetype-2.5.2/include \

View File

@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@
//
#include "../DocFormatLib/DocFormatLib.h"
#include "../win32/ASCOfficeCriticalSection.h"
#include "../../OfficeUtils/src/ASCOfficeCriticalSection.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
@ -41,6 +41,7 @@
#include <string>
#include <windows.h>
#include <tchar.h>
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
@ -58,7 +59,6 @@ int _tmain(int argc, _TCHAR* argv[])
std::wstring outputDir = NSDirectory::GetFolderPath(sDstDocx);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
// doc->docx
COfficeDocFile docFile;
docFile.m_sTempFolder = outputDir;
@ -71,7 +71,7 @@ int _tmain(int argc, _TCHAR* argv[])
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), sDstDocx, -1);
}
FileSystem::Directory::DeleteDirectory(dstTempPath);
NSDirectory::DeleteDirectory(dstTempPath);
return hRes;
}

View File

@ -338,6 +338,62 @@
<References>
</References>
<Files>
<Filter
Name="Common"
>
<File
RelativePath="..\..\ASCOfficeDocxFile2\BinWriter\BinWriters.cpp"
>
</File>
<File
RelativePath="..\..\XlsxSerializerCom\Reader\ChartFromToBinary.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\ChartWriter.cpp"
>
</File>
<File
RelativePath="..\..\XlsxSerializerCom\Common\Common.cpp"
>
</File>
<File
RelativePath="..\..\XlsxSerializerCom\Reader\CommonWriter.cpp"
>
</File>
<File
RelativePath="..\..\XlsxSerializerCom\Reader\CSVReader.cpp"
>
</File>
<File
RelativePath="..\..\XlsxSerializerCom\Writer\CSVWriter.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\DocxSerializer.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/bigobj&#x0D;&#x0A;"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\FontProcessor.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\BinReader\Readers.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
>
</File>
</Filter>
<File
RelativePath=".\DocFormatTest.cpp"
>
@ -382,10 +438,22 @@
RelativePath="..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
</File>
<File
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmldom.cpp"
>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmllight.cpp"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -38,80 +38,61 @@ namespace Writers
{
class ChartWriter
{
class ChartElem
struct _chartElem
{
public:
std::wstring content;
std::wstring filename;
int index;
std::wstring content;
std::wstring filename;
int index;
};
std::vector<ChartElem*> m_aCharts;
ContentTypesWriter& m_oContentTypesWriter;
int nChartCount;
std::vector<_chartElem> m_aCharts;
public:
std::wstring m_sDir;
public:
ChartWriter(std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
int nEmbeddedCount;
ChartWriter(std::wstring sDir) : m_sDir(sDir)
{
nChartCount = 0;
nEmbeddedCount = 1000;
}
~ChartWriter()
{
for(size_t i = 0, length = m_aCharts.size(); i < length; ++i)
{
delete m_aCharts[i];
}
}
bool IsEmpty()
{
return 0 == m_aCharts.size();
}
void Write()
bool Write()
{
if(false == IsEmpty())
if(IsEmpty()) return false;
OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts");
for(size_t i = 0; i < m_aCharts.size(); ++i)
{
OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts");
NSDirectory::CreateDirectory(pathChartDir.GetPath());
_chartElem & elem = m_aCharts[i];
for(size_t i = 0, length = m_aCharts.size(); i < length; ++i)
{
ChartElem* elem = m_aCharts[i];
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem.filename;
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem->filename;
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
oFile.WriteStringUTF8(elem->content);
oFile.CloseFile();
//Content_Types
std::wstring sRelPath = L"/word/charts/" + elem->filename;
m_oContentTypesWriter.AddOverride(sRelPath, L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
}
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
oFile.WriteStringUTF8(elem.content);
oFile.CloseFile();
}
return true;
}
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index)
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int index)
{
ChartElem* pChartElem = new ChartElem();
pChartElem->content = content;
pChartElem->index = nChartCount + 1;
nChartCount++;
pChartElem->filename = L"chart" + std::to_wstring(pChartElem->index) + L".xml";
_chartElem oChartElem;
sRelsName = L"charts/" + pChartElem->filename;
sFileName = pChartElem->filename;
index = pChartElem->index;
oChartElem.content = content;
oChartElem.index = index;
oChartElem.filename = L"chart" + std::to_wstring(oChartElem.index) + L".xml";
sRelsName = L"charts/" + oChartElem.filename;
sFileName = oChartElem.filename;
m_aCharts.push_back(pChartElem);
}
int getChartCount()
{
return nChartCount;
}
void setChartCount(int val)
{
nChartCount = val;
m_aCharts.push_back(oChartElem);
}
};
}

View File

@ -46,20 +46,19 @@ namespace Writers
class CommentsWriter
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
std::wstring m_sComment;
std::wstring m_sCommentExt;
std::wstring m_sPeople;
public:
CommentsWriter(std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
std::wstring m_sComment;
std::wstring m_sCommentExt;
std::wstring m_sPeople;
CommentsWriter(std::wstring sDir) : m_sDir(sDir)
{
}
void setElements(std::wstring& sComment, std::wstring& sCommentExt, std::wstring& sPeople)
{
m_sComment = sComment;
m_sCommentExt = sCommentExt;
m_sPeople = sPeople;
m_sComment = sComment;
m_sCommentExt = sCommentExt;
m_sPeople = sPeople;
}
void Write()
{
@ -67,42 +66,30 @@ namespace Writers
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("comments.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(g_string_comment_Start);
oFile.WriteStringUTF8(m_sComment);
oFile.WriteStringUTF8(g_string_comment_End);
oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(std::wstring(_T("/word/comments.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml")));
//Rels
//m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"), _T("comments.xml"));
}
if(false == m_sCommentExt.empty())
{
CFile oFile;
oFile.CreateFile(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("commentsExtended.xml"));
NSFile::CFileBinary oFile;
oFile.CreateFileW(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("commentsExtended.xml"));
oFile.WriteStringUTF8(g_string_commentExt_Start);
oFile.WriteStringUTF8(m_sCommentExt);
oFile.WriteStringUTF8(g_string_commentExt_End);
oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(std::wstring(_T("/word/commentsExtended.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml")));
}
if(false == m_sPeople.empty())
{
CFile oFile;
oFile.CreateFile(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("people.xml"));
NSFile::CFileBinary oFile;
oFile.CreateFileW(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("people.xml"));
oFile.WriteStringUTF8(g_string_people_Start);
oFile.WriteStringUTF8(m_sPeople);
oFile.WriteStringUTF8(g_string_people_End);
oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(std::wstring(_T("/word/people.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml")));
}
}
};

View File

@ -1,80 +0,0 @@
/*
* (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
*
*/
#ifndef CONTENT_TYPES_WRITER
#define CONTENT_TYPES_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
static std::wstring g_string_ct_Start = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">";
static std::wstring g_string_ct_Ext = L"<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\"/><Default Extension=\"bmp\" ContentType=\"image/bmp\"/><Default Extension=\"jpg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpe\" ContentType=\"image/jpeg\"/><Default Extension=\"png\" ContentType=\"image/png\"/><Default Extension=\"gif\" ContentType=\"image/gif\"/><Default Extension=\"emf\" ContentType=\"image/x-emf\"/><Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>";
static std::wstring g_string_ct_Override = L"<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/><Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/><Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/><Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>";
static std::wstring g_string_ct_End = L"</Types>";
class ContentTypesWriter
{
XmlUtils::CStringWriter m_oWriter;
std::wstring m_sDir;
XmlUtils::CStringWriter m_oAdditional;
public:
ContentTypesWriter(std::wstring sDir) : m_sDir(sDir)
{
}
void Write()
{
m_oWriter.WriteString(g_string_ct_Start);
m_oWriter.WriteString(g_string_ct_Ext);
m_oWriter.WriteString(g_string_ct_Override);
m_oWriter.Write(m_oAdditional);
m_oWriter.WriteString(g_string_ct_End);
OOX::CPath filePath = m_sDir + L"/[Content_Types].xml";
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
void AddOverride(const std::wstring& PartName, const std::wstring& ContentType)
{
std::wstring sOverride = L"<Override PartName=\"" + PartName+ L"\" ContentType=\"" + ContentType + L"\"/>";
m_oAdditional.WriteString(sOverride);
}
void AddOverrideRaw(const std::wstring& sXml)
{
m_oAdditional.WriteString(sXml);
}
};
}
#endif // #ifndef CONTENT_TYPES_WRITER

View File

@ -39,15 +39,16 @@ namespace Writers
class DefaultThemeWriter
{
public:
DefaultThemeWriter()
std::wstring m_sContent;
DefaultThemeWriter( )
{
}
void Write(std::wstring sThemeFilePath)
{
std::wstring s_Common;
s_Common = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?> \
<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\"> \
if (m_sContent.empty())
{
m_sContent = _T("<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\">\
<a:themeElements> \
<a:clrScheme name=\"Office\"> \
<a:dk1> \
@ -87,7 +88,7 @@ namespace Writers
<a:srgbClr val=\"800080\"/> \
</a:folHlink> \
</a:clrScheme> ");
s_Common +=
m_sContent +=
_T("<a:fontScheme name=\"Office\"> \
<a:majorFont> \
<a:latin typeface=\"Cambria\"/> \
@ -158,7 +159,7 @@ s_Common +=
<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/> \
</a:minorFont> \
</a:fontScheme>");
s_Common +=
m_sContent +=
_T("<a:fmtScheme name=\"Office\"> \
<a:fillStyleLst> \
<a:solidFill> \
@ -329,13 +330,14 @@ s_Common +=
<a:objectDefaults/> \
<a:extraClrSchemeLst/> \
</a:theme>");
}
OOX::CPath fileName = sThemeFilePath;
CFile oFile;
oFile.CreateFile(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
NSFile::CFileBinary oFile;
oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
oFile.WriteStringUTF8(m_sContent);
oFile.CloseFile();
}
};

View File

@ -56,8 +56,8 @@ namespace Writers
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels");
CFile oFile;
oFile.CreateFile(fileName.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
oFile.CloseFile();
}

View File

@ -51,8 +51,8 @@ namespace Writers
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") +FILE_SEPARATOR_STR + _T("document.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8( std::wstring(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
oFile.WriteStringUTF8( std::wstring(_T("<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">")));
@ -61,7 +61,7 @@ namespace Writers
oFile.WriteStringUTF8( std::wstring(_T("<w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8( std::wstring(_T("<w:sectPr >")));
oFile.WriteStringUTF8( std::wstring(_T("<w:sectPr>")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8( std::wstring(_T("</w:sectPr>")));

View File

@ -31,6 +31,7 @@
*/
#ifndef FILE_WRITER
#define FILE_WRITER
#include "../../DesktopEditor/common/Path.h"
#include "NumberingWriter.h"
#include "fontTableWriter.h"
@ -45,19 +46,21 @@
#include "webSettingsWriter.h"
#include "DefaultThemeWriter.h"
namespace BinDocxRW {
namespace BinDocxRW
{
class CComments;
}
namespace NSBinPptxRW
{
class CDrawingConverter;
}
namespace Writers
{
class FileWriter
{
public:
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
std::wstring m_sThemePath;
bool m_bSaveChartAsImg;
ContentTypesWriter m_oContentTypesWriter;
public:
FontTableWriter m_oFontTableWriter;
DocumentWriter m_oDocumentWriter;
MediaWriter m_oMediaWriter;
@ -71,35 +74,57 @@ namespace Writers
ChartWriter m_oChartWriter;
DocumentRelsWriter m_oDocumentRelsWriter;
WebSettingsWriter m_oWebSettingsWriter;
DefaultThemeWriter m_oDefaultTheme;
int m_nDocPrIndex;
BinDocxRW::CComments* m_pComments;
public:
FileWriter(std::wstring sDirOutput,std::wstring sFontDir, bool bNoFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath):
m_pDrawingConverter(pDrawingConverter),m_sThemePath(sThemePath),m_bSaveChartAsImg(bSaveChartAsImg),
m_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir, bNoFontDir),
m_oHeaderFooterWriter(sDirOutput, m_oContentTypesWriter),
m_oFootnotesWriter(sDirOutput, m_oContentTypesWriter),
m_oEndnotesWriter(sDirOutput, m_oContentTypesWriter),
m_oMediaWriter(sDirOutput),
m_oStylesWriter(sDirOutput, nVersion),
m_oNumberingWriter(sDirOutput, m_oContentTypesWriter),
m_oDocumentWriter(sDirOutput, m_oHeaderFooterWriter),
m_oSettingWriter(sDirOutput, m_oHeaderFooterWriter),
m_oCommentsWriter(sDirOutput, m_oContentTypesWriter),
m_oChartWriter(sDirOutput, m_oContentTypesWriter),
m_oDocumentRelsWriter(sDirOutput),
m_oWebSettingsWriter(sDirOutput),
DefaultThemeWriter m_oTheme;
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
bool m_bSaveChartAsImg;
std::wstring m_sThemePath;
int m_nDocPrIndex;
BinDocxRW::CComments* m_pComments;
FileWriter (std::wstring sDirOutput,std::wstring sFontDir, bool bNoFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath)
: m_pDrawingConverter(pDrawingConverter), m_sThemePath(sThemePath), m_bSaveChartAsImg(bSaveChartAsImg),
m_oFontTableWriter (sDirOutput, sFontDir, bNoFontDir),
m_oHeaderFooterWriter (sDirOutput),
m_oFootnotesWriter (sDirOutput),
m_oEndnotesWriter (sDirOutput),
m_oMediaWriter (sDirOutput),
m_oStylesWriter (sDirOutput, nVersion),
m_oNumberingWriter (sDirOutput),
m_oDocumentWriter (sDirOutput, m_oHeaderFooterWriter),
m_oSettingWriter (sDirOutput, m_oHeaderFooterWriter),
m_oCommentsWriter (sDirOutput),
m_oChartWriter (sDirOutput),
m_oDocumentRelsWriter (sDirOutput),
m_oWebSettingsWriter (sDirOutput),
m_nDocPrIndex(0),
m_pComments(NULL)
{
}
public: int getNextDocPr()
{
m_nDocPrIndex++;
return m_nDocPrIndex;
}
int getNextDocPr()
{
m_nDocPrIndex++;
return m_nDocPrIndex;
}
void Write()
{
m_oCommentsWriter.Write();
m_oChartWriter.Write();
m_oStylesWriter.Write();
m_oNumberingWriter.Write();
m_oFontTableWriter.Write();
m_oHeaderFooterWriter.Write();
m_oFootnotesWriter.Write();
m_oEndnotesWriter.Write();
//Setting пишем после HeaderFooter, чтобы заполнить evenAndOddHeaders
m_oSettingWriter.Write();
m_oWebSettingsWriter.Write();
//Document пишем после HeaderFooter, чтобы заполнить sectPr
m_oDocumentWriter.Write();
//Rels и ContentTypes пишем в конце
m_oDocumentRelsWriter.Write();
}
};
}
#endif // #ifndef FILE_WRITER

View File

@ -33,6 +33,7 @@
#define HEADER_FOOTER_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../Common/DocxFormat/Source/Common/SimpleTypes_Word.h"
namespace Writers
{
@ -54,10 +55,10 @@ namespace Writers
{
return m_sFilename.empty();
}
std::wstring m_sFilename;
ContentWriter Header;
std::wstring rId;
SimpleTypes::EHdrFtr eType;
std::wstring m_sFilename;
ContentWriter Header;
std::wstring rId;
SimpleTypes::EHdrFtr eType;
};
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:hdr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_hdr_End = _T("</w:hdr>");
@ -74,12 +75,11 @@ namespace Writers
class HeaderFooterWriter
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
std::vector<HdrFtrItem*> m_aHeaders;
std::vector<HdrFtrItem*> m_aFooters;
public:
HeaderFooterWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter) : m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
HeaderFooterWriter( std::wstring sDir) : m_sDir(sDir)
{
}
~HeaderFooterWriter()
@ -109,8 +109,8 @@ namespace Writers
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_Start);
@ -122,43 +122,33 @@ namespace Writers
else
oFile.WriteStringUTF8(g_string_ftr_End);
oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(L"/word/" + sFilename, L"application/vnd.openxmlformats-officedocument.wordprocessingml." + sHeader + L"+xml");
//Rels
//return m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/") + sHeader, sFilename);
}
};
class FootnotesWriter
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
ContentWriter m_oNotesWriter;
FootnotesWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
FootnotesWriter( std::wstring sDir ):m_sDir(sDir)
{
}
void Write()
{
if(!IsEmpty())
{
std::wstring sFilename = getFilename();
if(IsEmpty()) return;
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + sFilename;
std::wstring sFilename = getFilename();
CFile oFile;
oFile.CreateFile(filePath);
oFile.WriteStringUTF8(g_string_footnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_footnotes_End);
oFile.CloseFile();
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + sFilename;
//ContentType
m_oContentTypesWriter.AddOverride(L"/word/" + sFilename, L"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml");
}
NSFile::CFileBinary oFile;
oFile.CreateFileW (filePath);
oFile.WriteStringUTF8 (g_string_footnotes_Start);
oFile.WriteStringUTF8 (m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8 (g_string_footnotes_End);
oFile.CloseFile();
}
std::wstring getFilename()
std::wstring getFilename()
{
return _T("footnotes.xml");
}
@ -169,33 +159,29 @@ namespace Writers
};
class EndnotesWriter
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
std::wstring m_sDir;
public:
ContentWriter m_oNotesWriter;
EndnotesWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
EndnotesWriter( std::wstring sDir ) : m_sDir(sDir)
{
}
void Write()
{
if(!IsEmpty())
{
std::wstring sFilename = getFilename();
if(IsEmpty()) return;
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
std::wstring sFilename = getFilename();
CFile oFile;
oFile.CreateFile(filePath);
oFile.WriteStringUTF8(g_string_endnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_endnotes_End);
oFile.CloseFile();
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
//ContentType
m_oContentTypesWriter.AddOverride(_T("/word/") + sFilename, _T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"));
}
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath);
oFile.WriteStringUTF8(g_string_endnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_endnotes_End);
oFile.CloseFile();
}
std::wstring getFilename()
std::wstring getFilename()
{
return _T("endnotes.xml");
}

View File

@ -32,7 +32,6 @@
#ifndef NUMBERING_WRITER
#define NUMBERING_WRITER
#include "ContentTypesWriter.h"
#include "DocumentRelsWriter.h"
namespace Writers
@ -43,13 +42,12 @@ namespace Writers
class NumberingWriter
{
XmlUtils::CStringWriter m_oWriter;
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
std::wstring m_sDir;
public:
XmlUtils::CStringWriter m_oANum;
XmlUtils::CStringWriter m_oNumList;
public:
NumberingWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
NumberingWriter( std::wstring sDir) : m_sDir(sDir)
{
}
bool IsEmpty()
@ -58,26 +56,20 @@ namespace Writers
}
void Write()
{
if(false == IsEmpty())
{
m_oWriter.WriteString(g_string_n_Start);
m_oWriter.Write(m_oANum);
m_oWriter.Write(m_oNumList);
m_oWriter.WriteString(g_string_n_End);
if(IsEmpty()) return;
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("numbering.xml");
m_oWriter.WriteString(g_string_n_Start);
m_oWriter.Write(m_oANum);
m_oWriter.Write(m_oNumList);
m_oWriter.WriteString(g_string_n_End);
CFile oFile;
oFile.CreateFile(filePath.GetPath());
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("numbering.xml");
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
//ContentType
m_oContentTypesWriter.AddOverride( std::wstring(_T("/word/numbering.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml")));
//Rels
//m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"), _T("numbering.xml"));
}
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
};
}

View File

@ -34,6 +34,8 @@
#include "../../Common/DocxFormat/Source/XML/Utils.h"
#include <boost/algorithm/string.hpp>
namespace BinDocxRW {
class SectPr
@ -339,9 +341,9 @@ public:
if(ThemeColor.bColor)
sShd += L" w:themeFill=\"" + ThemeColor.ToStringColor() + L"\"";
if(ThemeColor.bTint)
sShd += L" w:themeFillTint=\"" + ThemeColor.ToStringColor() + L"\"";
sShd += L" w:themeFillTint=\"" + ThemeColor.ToStringTint() + L"\"";
if(ThemeColor.bShade)
sShd += L" w:themeFillShade=\"" + ThemeColor.ToStringColor() + L"\"";
sShd += L" w:themeFillShade=\"" + ThemeColor.ToStringShade() + L"\"";
}
sShd += L"/>";
}
@ -876,7 +878,7 @@ public:
pCStringWriter->WriteString(CellPr);
pCStringWriter->WriteString(L"</w:tcPr>");
}
for(int i = 0, length = TblStylePr.size(); i < length; ++i)
for(int i = 0, length = (int)TblStylePr.size(); i < length; ++i)
{
pCStringWriter->WriteString(TblStylePr[i]);
}
@ -1241,7 +1243,7 @@ public:
}
~docLvl()
{
for(int i = 0,length = Text.size(); i < length; i++)
for(int i = 0,length = (int)Text.size(); i < length; i++)
{
delete Text[i];
}
@ -1297,7 +1299,7 @@ public:
if(bText)
{
std::wstring sText;
for(int i = 0, length = Text.size(); i < length; ++i)
for(int i = 0, length = (int)Text.size(); i < length; ++i)
{
docLvlText* item = Text[i];
if(item->bText)
@ -1360,7 +1362,7 @@ public:
}
~docANum()
{
for(int i = 0, length = Lvls.size(); i < length; i++)
for(int i = 0, length = (int)Lvls.size(); i < length; i++)
{
delete Lvls[i];
}
@ -1380,7 +1382,7 @@ public:
std::wstring sCorrectNumStyleLink = XmlUtils::EncodeXmlString(NumStyleLink);
oWriterANum.WriteString(L"<w:numStyleLink w:val=\"" + sCorrectNumStyleLink + L"\"/>");
}
for(int i = 0, length = Lvls.size(); i < length; ++i)
for(int i = 0, length = (int)Lvls.size(); i < length; ++i)
{
Lvls[i]->Write(oWriterANum, i);
}
@ -1453,7 +1455,8 @@ public:
std::vector<std::wstring> aItems;
std::wstring sCurItem;
bool bDQuot = false;
for(int i = 0, length = fld.length(); i < length; ++i)
for(int i = 0, length = (int)fld.length(); i < length; ++i)
{
wchar_t sCurLetter = fld[i];
if('\"' == sCurLetter)
@ -1476,7 +1479,8 @@ public:
}
if(sCurItem.length() > 0)
aItems.push_back(sCurItem);
for(int i = 0, length = aItems.size(); i < length; ++i)
for(int i = 0, length = (int)aItems.size(); i < length; ++i)
{
std::wstring item = aItems[i];
if(bNextLink)
@ -1500,7 +1504,7 @@ public:
res = new WriteHyperlink();
boost::algorithm::trim(sLink);
int nAnchorIndex = sLink.find(L"#");
int nAnchorIndex = (int)sLink.find(L"#");
if(-1 != nAnchorIndex)
{
res->href = sLink.substr(0, nAnchorIndex);
@ -1589,7 +1593,7 @@ public:
}
~CComment()
{
for(int i = 0, length = replies.size(); i < length; ++i)
for(size_t i = 0; i <replies.size(); ++i)
{
delete replies[i];
}
@ -1597,32 +1601,37 @@ public:
}
int getCount()
{
return replies.size() + 1;
return (int)replies.size() + 1;
}
void setFormatStart(int IdFormatStart)
{
bIdFormat = true;
IdFormat = IdFormatStart;
for(int i = 0, length = replies.size(); i < length; ++i)
for(size_t i = 0; i < replies.size(); ++i)
{
CComment* pComment = replies[i];
CComment* pComment = replies[i];
pComment->bIdFormat = true;
pComment->IdFormat = IdFormatStart + i + 1;
pComment->IdFormat = (int)(IdFormatStart + i + 1);
}
}
std::wstring writeRef(const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter)
{
std::wstring sRes;
sRes += (writeRef(this, sBefore, sRef, sAfter));
for(int i = 0, length = replies.size(); i < length; ++i)
for(size_t i = 0; i< replies.size(); ++i)
{
sRes += (writeRef(replies[i], sBefore, sRef, sAfter));
}
return sRes;
}
std::wstring writeTemplates(funcArg fReadFunction)
{
std::wstring sRes;
sRes += (fReadFunction(this));
for(int i = 0, length = replies.size(); i < length; ++i)
for(size_t i = 0; i < replies.size(); ++i)
sRes += (fReadFunction(replies[i]));
return sRes;
}
@ -1708,7 +1717,7 @@ public:
bool bFirst = true;
int nPrevIndex = 0;
for(int i = 0, length = sText.length(); i < length; i++)
for(size_t i = 0; i < sText.length(); i++)
{
wchar_t cToken = sText[i];
if('\n' == cToken)
@ -1717,7 +1726,7 @@ public:
nPrevIndex = i + 1;
}
}
writeContentWritePart(pComment, sText, nPrevIndex, sText.length(), bFirst, sRes);
writeContentWritePart(pComment, sText, nPrevIndex, (int)sText.length(), bFirst, sRes);
}
sRes += L"</w:comment>";
return sRes;
@ -1736,7 +1745,7 @@ w15:paraIdParent=\"" + pComment->m_sParaIdParent + L"\" w15:done=\"" + sDone + L
else
sRes += L"<w15:commentEx w15:paraId=\"" + pComment->m_sParaId + L"\" w15:done=\"" + sDone + L"\"/>";
//расставляем paraIdParent
for(int i = 0, length = pComment->replies.size(); i < length; i++)
for(size_t i = 0; i < pComment->replies.size(); i++)
pComment->replies[i]->m_sParaIdParent = pComment->m_sParaId;
}
return sRes;
@ -1782,7 +1791,7 @@ public:
{
m_mapComments[pComment->IdOpen] = pComment;
addAuthor(pComment);
for(int i = 0, length = pComment->replies.size(); i < length; i++)
for(size_t i = 0; i < pComment->replies.size(); i++)
addAuthor(pComment->replies[i]);
}
}
@ -1866,7 +1875,7 @@ public:
}
~CDrawingPropertyWrap()
{
for(int i = 0, length = Points.size(); i < length; ++i)
for(size_t i = 0; i < Points.size(); ++i)
delete Points[i];
Points.clear();
}
@ -1874,7 +1883,12 @@ public:
class CDrawingProperty
{
public:
long DataPos;
bool bObject;
std::wstring sObjectProgram;
long nObjectId;
BYTE nObjectType;
long DataPos;
long DataLength;
BYTE Type;
bool BehindDoc;
@ -1907,8 +1921,8 @@ public:
int m_nDocPr;
std::wstring sGraphicFramePr;
std::wstring sDocPr;
CDrawingPropertyWrap DrawingPropertyWrap;
CDrawingPropertyWrap DrawingPropertyWrap;
bool bDataPos;
bool bDataLength;
@ -1942,6 +1956,10 @@ public:
CDrawingProperty(int nDocPr)
{
m_nDocPr = nDocPr;
bObject = false;
nObjectType = 0;
nObjectId = 0;
bDataPos = false;
bDataLength = false;
bType = false;
@ -2055,7 +2073,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
int nSimplePos = 0;
if(bBSimplePos && BSimplePos)
nSimplePos = 1;
int nRelativeHeight = 0;
unsigned long nRelativeHeight = 0;
if(bRelativeHeight)
nRelativeHeight = RelativeHeight;
int nBehindDoc = 0;
@ -2211,7 +2229,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
sXml += L"<wp:start x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
}
for(int i = 0, length = DrawingPropertyWrap.Points.size(); i < length; ++i)
for(size_t i = 0; i < DrawingPropertyWrap.Points.size(); ++i)
{
CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i];
if(pWrapPoint->bX && pWrapPoint->bY)

View File

@ -0,0 +1,113 @@
/*
* (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 "Readers.h"
namespace BinDocxRW {
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)
{
}
int Binary_HdrFtrTableReader::Read()
{
return ReadTable(&Binary_HdrFtrTableReader::ReadHdrFtrContent, this);
}
int Binary_HdrFtrTableReader::ReadHdrFtrContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerHdrFtrTypes::Header == type || c_oSerHdrFtrTypes::Footer == type )
{
nCurType = type;
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrFEO, this, poResult);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int Binary_HdrFtrTableReader::ReadHdrFtrFEO(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerHdrFtrTypes::HdrFtr_First == type || c_oSerHdrFtrTypes::HdrFtr_Even == type || c_oSerHdrFtrTypes::HdrFtr_Odd == type )
{
nCurHeaderType = type;
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrItem, this, poResult);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int Binary_HdrFtrTableReader::ReadHdrFtrItem(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerHdrFtrTypes::HdrFtr_Content == type )
{
Writers::HdrFtrItem* poHdrFtrItem = NULL;
switch(nCurHeaderType)
{
case c_oSerHdrFtrTypes::HdrFtr_First:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrFirst);break;
case c_oSerHdrFtrTypes::HdrFtr_Even:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrEven);break;
case c_oSerHdrFtrTypes::HdrFtr_Odd:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrDefault);break;
}
if(NULL != poHdrFtrItem)
{
if(nCurType == c_oSerHdrFtrTypes::Header)
{
m_oHeaderFooterWriter.m_aHeaders.push_back(poHdrFtrItem);
poHdrFtrItem->m_sFilename = L"header" + std::to_wstring((int)m_oHeaderFooterWriter.m_aHeaders.size()) + L".xml";
}
else
{
m_oHeaderFooterWriter.m_aFooters.push_back(poHdrFtrItem);
poHdrFtrItem->m_sFilename = L"footer" + std::to_wstring((int)m_oHeaderFooterWriter.m_aFooters.size()) + L".xml";
}
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
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");
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(fileRelsPath.GetPath());
}
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int Binary_HdrFtrTableReader::ReadHdrFtrItemContent(BYTE type, long length, void* poResult)
{
Binary_DocumentTableReader* pBinary_DocumentTableReader = static_cast<Binary_DocumentTableReader*>(poResult);
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -42,9 +42,9 @@ namespace Writers
class SettingWriter
{
std::wstring m_sDir;
XmlUtils::CStringWriter m_oSettingWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
std::wstring m_sDir;
XmlUtils::CStringWriter m_oSettingWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
public:
SettingWriter(std::wstring sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir),m_oHeaderFooterWriter(oHeaderFooterWriter)
{
@ -54,8 +54,8 @@ namespace Writers
Prepare();
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"settings.xml";
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(g_string_set_Start);
oFile.WriteStringUTF8(m_oSettingWriter.GetData());
oFile.WriteStringUTF8(g_string_set_Default);

View File

@ -58,7 +58,6 @@ namespace Writers
}
void Write()
{
m_oWriter.WriteString(g_string_st_Start);
m_oWriter.WriteString(std::wstring(_T("<w:docDefaults>")));
m_oWriter.WriteString(std::wstring(_T("<w:rPrDefault>")));
@ -81,8 +80,8 @@ namespace Writers
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("styles.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();

View File

@ -34,6 +34,7 @@
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
namespace Writers
{
@ -48,8 +49,8 @@ namespace Writers
CFontManager* m_pFontManager;
public:
std::map<std::wstring, int> m_mapFonts;
public:
FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir)
FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir)
{
m_pFontManager = NULL;
if(!bNoFontDir)
@ -102,8 +103,8 @@ namespace Writers
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("fontTable.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
@ -121,7 +122,7 @@ namespace Writers
CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
if(NULL != pFontInfo)
{
for(int i = 0; i < 10; ++i)
for (size_t i = 0; i < 10; ++i)
{
BYTE cElem = pFontInfo->m_aPanose[i];
if(0 != cElem)

View File

@ -54,8 +54,8 @@ namespace Writers
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("webSettings.xml");
CFile oFile;
oFile.CreateFile(fileName.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
oFile.CloseFile();
}

View File

@ -33,13 +33,11 @@
#define BINEQUATIONWRITER_H
#include "BinReaderWriterDefines.h"
#include "../../Common/DocxFormat/Source/Common/SimpleTypes_OMath.h"
#include "../../Common/DocxFormat/Source/MathEquation/OutputDev.h"
#include <stack>
/*namespace BinDocxRW
{
class BinaryCommonWriter;
}*/
namespace MathEquation
{
class EquationRun

View File

@ -463,7 +463,8 @@ extern int g_nCurFormatVersion;
FldSimple = 11,
Del = 12,
Ins = 13,
Background = 14
Background = 14,
Sdt = 15
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -477,7 +478,8 @@ extern int g_nCurFormatVersion;
Cell = 6,
Cell_Pr = 7,
Cell_Content = 8,
tblGridChange = 9
tblGridChange = 9,
Sdt = 10
};}
namespace c_oSerRunType{enum c_oSerRunType
{
@ -910,7 +912,8 @@ extern int g_nCurFormatVersion;
namespace c_oSer_FldSimpleType{ enum c_oSer_FldSimpleType
{
Content = 0,
Instr = 1
Instr = 1,
FFData = 2
};}
namespace c_oSer_ColorThemeType{ enum c_oSer_ColorThemeType
{
@ -997,6 +1000,79 @@ extern int g_nCurFormatVersion;
Title = 3,
Descr = 4
};}
namespace c_oSerEmbedded{enum c_oSerEmbedded
{
Type = 0,
Data = 1,
Program = 2
};}
namespace c_oSerSdt{enum c_oSerSdt
{
Pr = 0,
EndPr = 1,
Content = 2,
Type = 3,
Alias = 4,
ComboBox = 5,
LastValue = 6,
SdtListItem = 7,
DisplayText = 8,
Value = 9,
DataBinding = 10,
PrefixMappings = 11,
StoreItemID = 12,
XPath = 13,
PrDate = 14,
FullDate = 15,
Calendar = 16,
DateFormat = 17,
Lid = 18,
StoreMappedDataAs = 19,
DocPartList = 20,
DocPartObj = 21,
DocPartCategory = 22,
DocPartGallery = 23,
DocPartUnique = 24,
DropDownList = 25,
Id = 26,
Label = 27,
Lock = 28,
PlaceHolder = 29,
RPr = 30,
ShowingPlcHdr = 31,
TabIndex = 32,
Tag = 33,
Temporary = 34,
MultiLine = 35
};}
namespace c_oSerFFData{enum c_oSerFFData
{
CalcOnExit = 0,
CheckBox = 1,
DDList = 2,
Enabled = 3,
EntryMacro = 4,
ExitMacro = 5,
HelpText = 6,
Label = 7,
Name = 8,
StatusText = 9,
TabIndex = 10,
TextInput = 11,
CBChecked = 12,
CBDefault = 13,
CBSize = 14,
CBSizeAuto = 15,
DLDefault = 16,
DLResult = 17,
DLListEntry = 18,
HTType = 19,
HTVal = 20,
TIDefault = 21,
TIFormat = 22,
TIMaxLength = 23,
TIType = 24,
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

View File

@ -35,9 +35,9 @@
namespace BinDocxRW
{
BinaryHeaderFooterTableWriter::BinaryHeaderFooterTableWriter(ParamsWriter& oParamsWriter, OOX::IFileContainer* oDocumentRels, std::map<int, bool>* mapIgnoreComments):
m_oBcw(oParamsWriter), m_oParamsWriter(oParamsWriter), m_poTheme(oParamsWriter.m_poTheme), m_oFontProcessor(*oParamsWriter.m_pFontProcessor), m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter), m_oDocumentRels(oDocumentRels),m_mapIgnoreComments(mapIgnoreComments)
m_oBcw(oParamsWriter), m_oParamsWriter(oParamsWriter), m_poTheme(oParamsWriter.m_poTheme), m_oFontProcessor(*oParamsWriter.m_pFontProcessor), m_oSettings(oParamsWriter.m_oSettings), m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter), m_oDocumentRels(oDocumentRels),m_mapIgnoreComments(mapIgnoreComments)
{
};
}
void BinaryHeaderFooterTableWriter::Write()
{
int nStart = m_oBcw.WriteItemWithLengthStart();
@ -57,11 +57,11 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
m_oBcw.WriteItemWithLengthEnd(nStart);
};
}
void BinaryHeaderFooterTableWriter::WriteHdrFtrContent(std::vector<OOX::CHdrFtr*>& aHdrFtrs, std::vector<SimpleTypes::EHdrFtr>& aHdrFtrTypes, std::vector<OOX::Logic::CSectionProperty*>& aHdrSectPrs, bool bHdr)
{
int nCurPos = 0;
for(int i = 0, length = aHdrFtrs.size(); i < length; ++i)
for(size_t i = 0; i < aHdrFtrs.size(); ++i)
{
OOX::CHdrFtr* pHdrFtr = aHdrFtrs[i];
SimpleTypes::EHdrFtr eType = aHdrFtrTypes[i];
@ -69,26 +69,28 @@ namespace BinDocxRW
BYTE byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;
switch(eType)
{
case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First;break;
case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even;break;
default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;break;
case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First; break;
case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even; break;
default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd; break;
}
nCurPos = m_oBcw.WriteItemStart(byteHdrFtrType);
WriteHdrFtrItem(pSectPr, pHdrFtr, bHdr);
m_oBcw.WriteItemEnd(nCurPos);
}
};
}
void BinaryHeaderFooterTableWriter::WriteHdrFtrItem(OOX::Logic::CSectionProperty* pSectPr, OOX::CHdrFtr* pHdrFtr, bool bHdr)
{
int nCurPos = 0;
//Content
ParamsDocumentWriter oParamsDocumentWriter(pHdrFtr, pHdrFtr->m_oReadPath.GetPath());
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
m_oParamsWriter.m_sCurDocumentPath = oParamsDocumentWriter.m_sDocumentPath;
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_sDocumentPath, pHdrFtr->m_arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
};
{
int nCurPos = 0;
//Content
ParamsDocumentWriter oParamsDocumentWriter(pHdrFtr);
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, pHdrFtr->m_arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -43,10 +43,16 @@ int BinDocxRW::g_nCurFormatVersion = 0;
BinDocxRW::CDocxSerializer::CDocxSerializer()
{
m_pParamsWriter = NULL;
m_pCurFileWriter = NULL;
m_bIsNoBase64Save = false;
m_bSaveChartAsImg = false;
m_pParamsWriter = NULL;
m_pCurFileWriter = NULL;
m_bIsNoBase64Save = false;
m_bSaveChartAsImg = false;
}
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)
{
@ -61,7 +67,7 @@ bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const std::wstring& sSrcFileN
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
if(saveToFile(strEditorBin, strDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName))
return true;
return false;
}
@ -88,7 +94,7 @@ bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const std::wstring& sSrcFileN
if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
{
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, true))
return true;
}
}
@ -106,6 +112,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
CFontManager* pFontManager = pFontPicker->get_FontManager();
DocWrapper::FontProcessor fp;
fp.setFontManager(pFontManager);
NSBinPptxRW::CDrawingConverter oDrawingConverter;
oDrawingConverter.SetFontManager(pFontManager);
NSBinPptxRW::CBinaryFileWriter& oBufferedStream = *oDrawingConverter.m_pBinaryWriter;
@ -136,10 +143,13 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
m_pParamsWriter = new ParamsWriter(&oBufferedStream, &fp, &oDrawingConverter, pEmbeddedFontsManager);
BinaryFileWriter oBinaryFileWriter(*m_pParamsWriter);
oBinaryFileWriter.intoBindoc(sDstPath);
BYTE* pbBinBuffer = oBufferedStream.GetBuffer();
int nBinBufferLen = oBufferedStream.GetPosition();
if (m_bIsNoBase64Save)
{
NSFile::CFileBinary oFile;
@ -207,6 +217,7 @@ bool BinDocxRW::CDocxSerializer::CreateDocxFolders(std::wstring strDirectory, st
bool BinDocxRW::CDocxSerializer::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 bResultOk = false;
RELEASEOBJECT(m_pCurFileWriter);
NSFile::CFileBinary oFile;
if(oFile.OpenFile(sSrcFileName))
@ -219,7 +230,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
//проверяем формат
bool bValidFormat = false;
std::wstring sSignature(g_sFormatSignature);
int nSigLength = sSignature.length();
int nSigLength = (int)sSignature.length();
if(nBase64DataSize > nSigLength)
{
std::string sCurSig((char*)pBase64Data, nSigLength);
@ -263,7 +274,8 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
if(false != Base64::Base64Decode((const char*)(pBase64Data + nIndex), nBase64DataSize - nIndex, pData, &nDataSize))
{
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pReader;
oBufferedStream.Init(pData, 0, nDataSize);
@ -276,24 +288,26 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
{
g_nCurFormatVersion = nVersion = nTempVersion;
}
}
}
oDrawingConverter.SetMainDocument(this);
oDrawingConverter.SetMediaDstPath(sMediaPath);
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
//папка с картинками
//папка с картинками
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
std::wstring sFileInDir = strFileInDir.c_str();
oDrawingConverter.SetSourceFileDir(sFileInDir);
//default theme
m_pCurFileWriter->m_oDefaultTheme.Write(sThemePath);
BinaryFileReader oBinaryFileReader(sFileInDir, oBufferedStream, *m_pCurFileWriter);
oBinaryFileReader.ReadFile();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OOX::CContentTypes oContentTypes;
//themes
m_pCurFileWriter->m_oTheme.Write(sThemePath);
OOX::CContentTypes *pContentTypes = oDrawingConverter.GetContentTypes();
//docProps
OOX::CPath pathDocProps = sDstPath + FILE_SEPARATOR_STR + _T("docProps");
NSDirectory::CreateDirectory(pathDocProps.GetPath());
@ -304,14 +318,14 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
if (pApp)
{
pApp->SetApplication(_T("OnlyOffice"));
pApp->SetAppVersion(_T("3.0000"));
pApp->SetAppVersion(_T("4.3000"));
pApp->SetDocSecurity(0);
pApp->SetScaleCrop(false);
pApp->SetLinksUpToDate(false);
pApp->SetSharedDoc(false);
pApp->SetHyperlinksChanged(false);
pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, oContentTypes);
pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, *pContentTypes);
delete pApp;
}
OOX::CCore* pCore = new OOX::CCore();
@ -319,34 +333,15 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
{
pCore->SetCreator(_T(""));
pCore->SetLastModifiedBy(_T(""));
pCore->write(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"), DocProps, oContentTypes);
pCore->write(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"), DocProps, *pContentTypes);
delete pCore;
}
/////////////////////////////////////////////////////////////////////////////////////
m_pCurFileWriter->m_oContentTypesWriter.AddOverrideRaw(oDrawingConverter.GetContentTypes());
m_pCurFileWriter->Write();
pContentTypes->Write(sDstPath);
m_pCurFileWriter->m_oCommentsWriter.Write();
m_pCurFileWriter->m_oChartWriter.Write();
m_pCurFileWriter->m_oStylesWriter.Write();
m_pCurFileWriter->m_oNumberingWriter.Write();
m_pCurFileWriter->m_oFontTableWriter.Write();
m_pCurFileWriter->m_oHeaderFooterWriter.Write();
m_pCurFileWriter->m_oFootnotesWriter.Write();
m_pCurFileWriter->m_oEndnotesWriter.Write();
//Setting пишем после HeaderFooter, чтобы заполнить evenAndOddHeaders
m_pCurFileWriter->m_oSettingWriter.Write();
m_pCurFileWriter->m_oWebSettingsWriter.Write();
//Document пишем после HeaderFooter, чтобы заполнить sectPr
m_pCurFileWriter->m_oDocumentWriter.Write();
//Rels и ContentTypes пишем в конце
m_pCurFileWriter->m_oDocumentRelsWriter.Write();
m_pCurFileWriter->m_oContentTypesWriter.Write();
//CSerializer oSerializer = CSerializer();
//if(false != oSerializer.Write(oBufferedStream, sDirectoryOut))
//{
bResultOk = true;
//}
}
}
RELEASEARRAYOBJECTS(pBase64Data);
@ -371,11 +366,6 @@ bool BinDocxRW::CDocxSerializer::getBinaryContent(const std::wstring& bsTxConten
XmlUtils::CXmlLiteReader oReader;
// std::wstring bsTxContentTemp = _T("<root xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">");
//
// bsTxContentTemp += bsTxContent;
// bsTxContentTemp + _T("</root>");
std::wstring sBegin(_T("<root xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">"));
std::wstring sEnd(_T("</root>"));
@ -397,7 +387,8 @@ bool BinDocxRW::CDocxSerializer::getBinaryContent(const std::wstring& bsTxConten
BinDocxRW::BinaryCommonWriter oBinaryCommonWriter(oParamsWriter);
int nCurPos = oBinaryCommonWriter.WriteItemWithLengthStart();
BinDocxRW::ParamsDocumentWriter oParams(oParamsWriter.m_pCurRels, oParamsWriter.m_sCurDocumentPath);
BinDocxRW::ParamsDocumentWriter oParams(oParamsWriter.m_pCurRels);
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(oParamsWriter, oParams, &oParamsWriter.m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.WriteDocumentContent(oSdtContent.m_arrItems);
oBinaryCommonWriter.WriteItemWithLengthEnd(nCurPos);
@ -419,7 +410,8 @@ bool BinDocxRW::CDocxSerializer::getBinaryContentElem(OOX::EElementType eElemTyp
BinDocxRW::BinaryCommonWriter oBinaryCommonWriter(oParamsWriter);
int nCurPos = oBinaryCommonWriter.WriteItemWithLengthStart();
BinDocxRW::ParamsDocumentWriter oParams(oParamsWriter.m_pCurRels, oParamsWriter.m_sCurDocumentPath);
BinDocxRW::ParamsDocumentWriter oParams(oParamsWriter.m_pCurRels);
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(oParamsWriter, oParams, &oParamsWriter.m_mapIgnoreComments, NULL);
if(OOX::et_m_oMathPara == eElemType)
{
@ -431,6 +423,11 @@ bool BinDocxRW::CDocxSerializer::getBinaryContentElem(OOX::EElementType eElemTyp
OOX::Logic::COMath* pMath = static_cast<OOX::Logic::COMath*>(pElem);
oBinaryDocumentTableWriter.WriteMathArgNodes(pMath->m_arrItems);
}
else if(OOX::et_w_sdtContent == eElemType)
{
OOX::Logic::CSdtContent* pContent = static_cast<OOX::Logic::CSdtContent*>(pElem);
oBinaryDocumentTableWriter.WriteDocumentContent(pContent->m_arrItems);
}
oBinaryCommonWriter.WriteItemWithLengthEnd(nCurPos);
oParamsWriter.m_pCBufferedStream = pBufferedStreamOld;

View File

@ -51,14 +51,16 @@ namespace BinDocxRW
class CDocxSerializer
{
public:
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
bool m_bIsNoBase64Save;
bool m_bSaveChartAsImg;
ParamsWriter* m_pParamsWriter;
Writers::FileWriter* m_pCurFileWriter;
public:
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
bool m_bIsNoBase64Save;
bool m_bSaveChartAsImg;
ParamsWriter* m_pParamsWriter;
Writers::FileWriter* m_pCurFileWriter;
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);

View File

@ -58,7 +58,7 @@ namespace DocWrapper {
{
//подбор перенесен в js
return;
for (int i = 0; i < fontTable->m_arrFonts.size(); ++i)
for (size_t i = 0; i < fontTable->m_arrFonts.size(); ++i)
addToFontMap(*fontTable->m_arrFonts[i]);
}
@ -80,24 +80,24 @@ namespace DocWrapper {
return fontName;
}
std::wstring FontProcessor::getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, OOX::CTheme* pTheme)
std::wstring FontProcessor::getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, PPTX::Theme* pTheme)
{
CFontSelectFormat oFontSelectFormat;
std::wstring sFontName;
if(NULL != pTheme && oScheme.IsInit() && oScheme->m_oFontScheme.IsInit())
{
//берем шрифт из темы
//берем шрифт из темы
const SimpleTypes::Spreadsheet::EFontScheme eFontScheme = oScheme->m_oFontScheme->GetValue();
if(SimpleTypes::Spreadsheet::fontschemeMajor == eFontScheme)
sFontName = pTheme->GetMajorFont();
sFontName = pTheme->themeElements.fontScheme.majorFont.latin.typeface;
else if(SimpleTypes::Spreadsheet::fontschemeMinor == eFontScheme)
sFontName = pTheme->GetMinorFont();
sFontName = pTheme->themeElements.fontScheme.minorFont.latin.typeface;
}
if(sFontName.empty() && oRFont.IsInit() && oRFont->m_sVal.IsInit())
sFontName = oRFont->ToString2();
if(sFontName.empty())
sFontName = std::wstring(gc_sNoNameFont);
//подбор перенесен в js
//подбор перенесен в js
return sFontName;
oFontSelectFormat.wsName = new std::wstring(sFontName);

View File

@ -30,26 +30,29 @@
*
*/
#pragma once
//#include "../stdafx.h"
#include <map>
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{
template<class Type> class nullable;
}
namespace ComplexTypes{
namespace Spreadsheet{
namespace ComplexTypes
{
namespace Spreadsheet
{
class String;
}
}
namespace PPTX
{
class Theme;
}
namespace OOX
{
class CFont;
class CFontTable;
class CTheme;
namespace Spreadsheet
{
class CFont;
@ -61,9 +64,10 @@ namespace OOX
}
}
namespace DocWrapper {
class FontProcessor {
namespace DocWrapper
{
class FontProcessor
{
CFontManager* m_pFontManager;
std::map<std::wstring, std::wstring> fontMap;
@ -76,7 +80,7 @@ namespace DocWrapper {
void setFontTable(OOX::CFontTable* fontTable);
std::wstring getFont(const std::wstring& name);
std::wstring getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, OOX::CTheme* pTheme);
std::wstring getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, PPTX::Theme* pTheme);
private:
void addToFontMap(OOX::CFont& font);
};

View File

@ -85,17 +85,17 @@ namespace BinXlsxRW{
}
bool CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
{
NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter;
oOfficeDrawingConverter.SetMediaDstPath(sMediaDir);
oOfficeDrawingConverter.SetEmbedDstPath(sEmbedDir);
NSBinPptxRW::CDrawingConverter oDrawingConverter;
oDrawingConverter.SetMediaDstPath(sMediaDir);
oDrawingConverter.SetEmbedDstPath(sEmbedDir);
//папка с бинарников
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
oOfficeDrawingConverter.SetSourceFileDir(strFileInDir, 2);
oDrawingConverter.SetSourceFileDir(strFileInDir, 2);
BinXlsxRW::BinaryFileReader oBinaryFileReader;
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oOfficeDrawingConverter, sXMLOptions);
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
return true;
}
bool CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
@ -139,105 +139,76 @@ namespace BinXlsxRW{
RELEASEOBJECT(pFontPicker);
return true;
}
bool CXlsxSerializer::loadChart(const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize)
bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilepath, const long& lChartNumber)
{
if (NULL == pReader) return false;
if (NULL == m_pExternalDrawingConverter) return false;
bool bRes = false;
//todo передать нормальный oRootPath
OOX::CPath oRootPath;
OOX::Spreadsheet::CChartSpace oChart(oRootPath, sChartPath);
if(NULL != m_pExternalDrawingConverter)
m_pExternalDrawingConverter->SetDstContentRels();
//получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename
std::wstring sThemePath;
std::wstring sEmbedingPath;
std::wstring sContentTypePath;
int nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR);
nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR, nIndex - 1);
if(-1 != nIndex)
{
long nStartPos = oBufferedStream.GetPosition();
BinXlsxRW::BinaryCommonWriter oBcw(oBufferedStream);
std::wstring sOldRelsPath = m_pExternalDrawingConverter->GetRelsPath();
m_pExternalDrawingConverter->SetRelsPath(sChartPath);
BinXlsxRW::BinaryChartWriter oBinaryChartWriter(oBufferedStream, m_pExternalDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(oChart);
m_pExternalDrawingConverter->SetRelsPath(sOldRelsPath);
long nEndPos = oBufferedStream.GetPosition();
lDataSize = nEndPos - nStartPos;
bRes = true;
std::wstring sFilepathLeft = sFilepath.substr(0, nIndex + 1);
sThemePath = sFilepathLeft + L"theme";
sEmbedingPath = sFilepathLeft + L"embeddings";
}
return bRes;
}
bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, const std::wstring& sFilepath, const std::wstring& sContentTypePath, std::wstring** sContentTypeElement, const long& lChartNumber)
{
bool bRes = false;
*sContentTypeElement = NULL;
if(NULL != m_pExternalDrawingConverter)
{
m_pExternalDrawingConverter->SetDstContentRels();
//получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename
std::wstring sThemePath;
std::wstring sEmbedingPath;
int nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR);
nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR, nIndex - 1);
if(-1 != nIndex)
{
std::wstring sFilepathLeft = sFilepath.substr(0, nIndex + 1);
sThemePath = sFilepathLeft + L"theme";
sEmbedingPath = sFilepathLeft + L"embeddings";
}
if (pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) sContentTypePath = L"/word/charts/";
else if (pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_XLSX) sContentTypePath = L"/xl/charts/";
else sContentTypePath = L"/ppt/charts/";
//todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath);
OOX::Spreadsheet::CChartSpace oChartSpace;
BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);
BinXlsxRW::SaveParams oSaveParams(sThemePath, m_pExternalDrawingConverter->GetContentTypes());
OOX::Spreadsheet::CChartSpace oChartSpace;
BinXlsxRW::BinaryChartReader oBinaryChartReader(*pReader, oSaveParams, m_pExternalDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);
if(oChartSpace.isValid())
if(oChartSpace.isValid())
{
//save xlsx embedded for chart
if(pReader->m_nDocumentType != XMLWRITER_DOC_TYPE_XLSX && !sEmbedingPath.empty())
{
//todo не делать embeddings, если пишем xlsx
//save xlsx
if(!sEmbedingPath.empty())
{
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
writeChartXlsx(sXlsxPath, oChartSpace);
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
writeChartXlsx(sXlsxPath, oChartSpace);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
std::wstring bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
std::wstring strFilepath = sFilepath;
std::wstring strDir = NSSystemPath::GetDirectoryName(strFilepath);
std::wstring strFilename = NSSystemPath::GetFileName(strFilepath);
OOX::CPath pathRelsDir = strDir + FILE_SEPARATOR_STR + _T("_rels");
OOX::CSystemUtility::CreateDirectories(pathRelsDir.GetPath());
oChartSpace.write2(sFilepath);
OOX::CPath pathRelsFile = pathRelsDir + FILE_SEPARATOR_STR + strFilename + _T(".rels");
m_pExternalDrawingConverter->SaveDstContentRels(pathRelsFile.GetPath());
std::wstring sContentType(sContentTypePath);
sContentType += strFilename;
std::wstring sContent = L"<Override PartName=\"" + sContentType + L"\" ContentType=\"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\"/>";
sContent += oSaveParams.sAdditionalContentTypes;
(*sContentTypeElement) = new std::wstring(sContent);
bRes = true;
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
std::wstring strFilepath = sFilepath;
std::wstring strDir = NSSystemPath::GetDirectoryName(strFilepath);
std::wstring strFilename = NSSystemPath::GetFileName(strFilepath);
OOX::CPath pathRelsDir = strDir + FILE_SEPARATOR_STR + _T("_rels");
OOX::CSystemUtility::CreateDirectories(pathRelsDir.GetPath());
oChartSpace.write2(sFilepath);
OOX::CPath pathRelsFile = pathRelsDir + FILE_SEPARATOR_STR + strFilename + _T(".rels");
m_pExternalDrawingConverter->SaveDstContentRels(pathRelsFile.GetPath());
pReader->m_pRels->m_pManager->m_pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml", sContentTypePath, strFilename);
bRes = true;
}
return bRes;
}
@ -255,28 +226,28 @@ namespace BinXlsxRW{
}
void CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
{
//анализируем chart
//анализируем chart
BinXlsxRW::ChartWriter helper;
helper.parseChart(oChart.m_oChartSpace.m_chart);
//создаем temp
//создаем temp
std::wstring sTempDir = NSSystemPath::GetDirectoryName(sDstFile) + FILE_SEPARATOR_STR + NSSystemPath::GetFileName(sDstFile) + L"_TEMP";
NSDirectory::CreateDirectory(sTempDir);
OOX::CPath oPath(sTempDir.c_str());
//шиблонные папки
//шиблонные папки
std::wstring sXmlOptions = _T("");
std::wstring sMediaPath;// will be filled by 'CreateXlsxFolders' method
std::wstring sEmbedPath; // will be filled by 'CreateXlsxFolders' method
CreateXlsxFolders (sXmlOptions, sTempDir, sMediaPath, sEmbedPath);
//заполняем Xlsx
//заполняем Xlsx
OOX::Spreadsheet::CXlsx oXlsx;
helper.toXlsx(oXlsx);
//write
std::wstring sAdditionalContentTypes;
oXlsx.Write(oPath, sAdditionalContentTypes);
//write
OOX::CContentTypes oContentTypes;
oXlsx.Write(oPath, oContentTypes);
//zip
COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, -1);
//clean
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
//clean
NSDirectory::DeleteDirectory(sTempDir);
}
};

View File

@ -59,13 +59,12 @@ namespace BinXlsxRW {
CXlsxSerializer();
~CXlsxSerializer();
void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath);
static void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath);
bool loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
bool saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
bool loadChart (const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
bool saveChart (NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, const std::wstring& sFilename, const std::wstring& sContentTypePath, std::wstring** sContentTypeElement, const long& lChartNumber);
bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilename, const long& lChartNumber);
void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);

View File

@ -16,15 +16,15 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
NODOCX \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
USE_ATL_CSTRING \
USE_AVSOFFICESTUDIO_XMLUTILS \
SOLUTION_ASCOFFICEDOCXFILE2 \
#DISABLE_FILE_DOWNLOADER \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS
INCLUDEPATH += \
../../DesktopEditor/freetype-2.5.2/include \
@ -42,15 +42,15 @@ SOURCES += \
../../XlsxSerializerCom/Reader/CommonWriter.cpp \
../../XlsxSerializerCom/Reader/CSVReader.cpp \
../../XlsxSerializerCom/Writer/CSVWriter.cpp \
../../OfficeCryptReader/source/ECMACryptReader.cpp \
../../OfficeCryptReader/source/CryptTransform.cpp
../../OfficeCryptReader/source/ECMACryptFile.cpp \
../../OfficeCryptReader/source/CryptTransform.cpp \
../BinReader/Readers.cpp
HEADERS += ../DocWrapper/DocxSerializer.h \
../DocWrapper/FontProcessor.h \
../DocWrapper/XlsxSerializer.h \
../BinReader/ChartWriter.h \
../BinReader/CommentsWriter.h \
../BinReader/ContentTypesWriter.h \
../BinReader/DocumentRelsWriter.h \
../BinReader/DocumentWriter.h \
../BinReader/FileWriter.h \
@ -78,5 +78,5 @@ HEADERS += ../DocWrapper/DocxSerializer.h \
../../Common/FileDownloader/FileDownloader.h \
../BinReader/DefaultThemeWriter.h \
../DocWrapper/ChartWriter.h \
../../OfficeCryptReader/source/ECMACryptReader.h \
../../OfficeCryptReader/source/ECMACryptFile.h \
../../OfficeCryptReader/source/CryptTransform.h

View File

@ -34,7 +34,6 @@
17C1FEB11ACC42C4006B99B3 /* Common.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17F1F1AC4549B00BEA2EA /* Common.h */; };
17C1FEB21ACC42C4006B99B3 /* XlsxSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17F131AC4546100BEA2EA /* XlsxSerializer.h */; };
17C1FEB31ACC42C4006B99B3 /* CSVReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17F271AC4549B00BEA2EA /* CSVReader.h */; };
17C1FEB41ACC42C4006B99B3 /* ContentTypesWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17EED1AC4544900BEA2EA /* ContentTypesWriter.h */; };
17C1FEB51ACC42C4006B99B3 /* HeaderFooterWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17EF41AC4544900BEA2EA /* HeaderFooterWriter.h */; };
17C1FEB61ACC42C4006B99B3 /* webSettingsWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17EFB1AC4544900BEA2EA /* webSettingsWriter.h */; };
17C1FEB71ACC42C4006B99B3 /* SettingWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17EF91AC4544900BEA2EA /* SettingWriter.h */; };
@ -43,6 +42,7 @@
17C1FEBC1ACC42C4006B99B3 /* DocxSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17F0F1AC4546100BEA2EA /* DocxSerializer.h */; };
17C1FEBD1ACC42C4006B99B3 /* FileWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17EF21AC4544900BEA2EA /* FileWriter.h */; };
17C1FEBE1ACC42C4006B99B3 /* CSVWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 17E17F301AC4549B00BEA2EA /* CSVWriter.h */; };
690FE0851E9BBD68004B26D0 /* Readers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 690FE0841E9BBD68004B26D0 /* Readers.cpp */; };
69414A301CB51666003E771B /* ChartWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69414A2E1CB51666003E771B /* ChartWriter.cpp */; };
69414A311CB51666003E771B /* ChartWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 69414A2F1CB51666003E771B /* ChartWriter.h */; };
6967917C1D9E8AEE002CA4BA /* BinEquationWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 696791781D9E8AEE002CA4BA /* BinEquationWriter.h */; };
@ -58,7 +58,6 @@
17C1FEC21ACC42C4006B99B3 /* libASCOfficeDocxFile2Lib_ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libASCOfficeDocxFile2Lib_ios.a; sourceTree = BUILT_PRODUCTS_DIR; };
17E17EEB1AC4544900BEA2EA /* ChartWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartWriter.h; sourceTree = "<group>"; };
17E17EEC1AC4544900BEA2EA /* CommentsWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentsWriter.h; sourceTree = "<group>"; };
17E17EED1AC4544900BEA2EA /* ContentTypesWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentTypesWriter.h; sourceTree = "<group>"; };
17E17EF01AC4544900BEA2EA /* DocumentRelsWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentRelsWriter.h; sourceTree = "<group>"; };
17E17EF11AC4544900BEA2EA /* DocumentWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentWriter.h; sourceTree = "<group>"; };
17E17EF21AC4544900BEA2EA /* FileWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileWriter.h; sourceTree = "<group>"; };
@ -91,6 +90,7 @@
17E17F2E1AC4549B00BEA2EA /* BinaryReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinaryReader.h; sourceTree = "<group>"; };
17E17F2F1AC4549B00BEA2EA /* CSVWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSVWriter.cpp; sourceTree = "<group>"; };
17E17F301AC4549B00BEA2EA /* CSVWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSVWriter.h; sourceTree = "<group>"; };
690FE0841E9BBD68004B26D0 /* Readers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Readers.cpp; sourceTree = "<group>"; };
69414A2E1CB51666003E771B /* ChartWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChartWriter.cpp; sourceTree = "<group>"; };
69414A2F1CB51666003E771B /* ChartWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartWriter.h; sourceTree = "<group>"; };
696791781D9E8AEE002CA4BA /* BinEquationWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BinEquationWriter.h; path = ../../BinWriter/BinEquationWriter.h; sourceTree = "<group>"; };
@ -145,7 +145,6 @@
children = (
17E17EEB1AC4544900BEA2EA /* ChartWriter.h */,
17E17EEC1AC4544900BEA2EA /* CommentsWriter.h */,
17E17EED1AC4544900BEA2EA /* ContentTypesWriter.h */,
17A765271B0F3DC30046BC0B /* DefaultThemeWriter.h */,
17E17EF01AC4544900BEA2EA /* DocumentRelsWriter.h */,
17E17EF11AC4544900BEA2EA /* DocumentWriter.h */,
@ -159,6 +158,7 @@
17E17EF91AC4544900BEA2EA /* SettingWriter.h */,
17E17EFA1AC4544900BEA2EA /* StylesWriter.h */,
17E17EFB1AC4544900BEA2EA /* webSettingsWriter.h */,
690FE0841E9BBD68004B26D0 /* Readers.cpp */,
);
name = BinReader;
path = ../../BinReader;
@ -277,7 +277,6 @@
17C1FEB31ACC42C4006B99B3 /* CSVReader.h in Headers */,
6967917D1D9E8AEE002CA4BA /* BinReaderWriterDefines.h in Headers */,
69414A311CB51666003E771B /* ChartWriter.h in Headers */,
17C1FEB41ACC42C4006B99B3 /* ContentTypesWriter.h in Headers */,
17C1FEB51ACC42C4006B99B3 /* HeaderFooterWriter.h in Headers */,
17C1FEB61ACC42C4006B99B3 /* webSettingsWriter.h in Headers */,
17C1FEB71ACC42C4006B99B3 /* SettingWriter.h in Headers */,
@ -350,6 +349,7 @@
69414A301CB51666003E771B /* ChartWriter.cpp in Sources */,
6967917E1D9E8AEE002CA4BA /* BinWriters.cpp in Sources */,
17C1FE9C1ACC42C4006B99B3 /* XlsxSerializer.cpp in Sources */,
690FE0851E9BBD68004B26D0 /* Readers.cpp in Sources */,
17C1FE9D1ACC42C4006B99B3 /* FontProcessor.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -378,6 +378,7 @@
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (
@ -414,6 +415,7 @@
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (

View File

@ -2,6 +2,9 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml_wrapper", "..\win32\cpxml.vcproj", "{41BED424-4EAF-4053-8A5F-1E2A387D53D1}"
ProjectSection(ProjectDependencies) = postProject
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormatReaderLib", "..\win32\cpodf.vcproj", "{50E20601-4A8D-4AFB-8870-63828D328429}"
ProjectSection(ProjectDependencies) = postProject
@ -21,7 +24,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormulasConvert", "..\wi
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFileReaderTest", "OdfFileTest.vcproj", "{C2882DDD-07E6-4314-AD4B-48F43F38D722}"
ProjectSection(ProjectDependencies) = postProject
{41BED424-4EAF-4053-8A5F-1E2A387D53D1} = {41BED424-4EAF-4053-8A5F-1E2A387D53D1}
{50E20601-4A8D-4AFB-8870-63828D328429} = {50E20601-4A8D-4AFB-8870-63828D328429}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
@ -30,7 +35,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFileReaderTest", "OdfFil
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\..\DesktopEditor\graphics\graphics_vs2005.vcproj", "{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}"

View File

@ -31,18 +31,22 @@
*/
// OdfFileTest.cpp
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include <stdio.h>
#include <tchar.h>
#include "../../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../src/ConvertOO2OOX.h"
#include "../../src/ConvertOO2OOX.h"
#if defined(_WIN64)
#pragma comment(lib, "../../../build/bin/icu/win_64/icuuc.lib")
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#pragma comment(lib, "../../../build/bin/icu/win_32/icuuc.lib")
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
@ -50,12 +54,12 @@ int _tmain(int argc, _TCHAR* argv[])
HRESULT hr = S_OK;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx"; //xlsx pptx
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx docx
std::wstring outputDir = FileSystem::Directory::GetFolderPath(dstPath);
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
std::wstring srcTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
std::wstring srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
// распаковываем исходник во временную директорию
COfficeUtils oCOfficeUtils(NULL);
@ -64,14 +68,14 @@ int _tmain(int argc, _TCHAR* argv[])
hr = ConvertOO2OOX(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", false, NULL);
FileSystem::Directory::DeleteDirectory(srcTempPath);
NSDirectory::DeleteDirectory(srcTempPath);
if (hr != S_OK) return hr;
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), -1))
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), true))
return hr;
FileSystem::Directory::DeleteDirectory(dstTempPath);
NSDirectory::DeleteDirectory(dstTempPath);
////////////////////////////////////////////////////////////////////////
return 0;

View File

@ -43,11 +43,11 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE;UNICODE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
@ -63,7 +63,9 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="gdi32.lib"
AdditionalDependencies="gdi32.lib Rpcrt4.lib"
ShowProgress="0"
Version=""
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
@ -329,22 +331,10 @@
</References>
<Files>
<Filter
Name="Source Files"
Name="Common"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="OdfFileTest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
@ -369,7 +359,43 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmldom.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmllight.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath="OdfFileTest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>

View File

@ -34,18 +34,15 @@
#include <boost/optional/optional_io.hpp>
#include <boost/optional.hpp>
namespace cpdoccore
/// внешнее объявление для Optional, используем boost::optional
template <class T>
struct optional
{
/// внешнее объявление для Optional, используем boost::optional
template <class T>
struct optional
{
typedef T Base;
typedef boost::optional<T> Type;
};
typedef T Base;
typedef boost::optional<T> Type;
};
#define _CP_OPT(V) optional<V>::Type
#define _CP_OPT(V) optional<V>::Type
}

View File

@ -24,7 +24,8 @@ DEFINES += UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS
INCLUDEPATH += ../include
INCLUDEPATH += ../../DesktopEditor/freetype-2.5.2/include

View File

@ -46,7 +46,6 @@
#include "../odf/style_text_properties.h"
#include "../odf/style_table_properties.h"
#include "../odf/style_graphic_properties.h"
#include "../odf/datatypes/style_ref.h"
#include "docx_package.h"
#include "oox_rels.h"
@ -189,7 +188,7 @@ std::wstring styles_map::get(const std::wstring & Name, odf_types::style_family:
}
else
{
const std::wstring id = std::wstring(L"style") + boost::lexical_cast<std::wstring>(count_++);
const std::wstring id = std::wstring(L"style") + std::to_wstring(count_++);
map_.insert(std::make_pair(n, id));
return id;
}
@ -569,7 +568,8 @@ mc:Ignorable=\"w14 wp14\">";
strm << L"<w:abstractNum w:abstractNumId=\"" << abstractNumId << "\">";
numIds.push_back(abstractNumId);
for (int i = 0; i < (std::min)( content.size(), (size_t)9); i++)
for (size_t i = 0; i < (std::min)( content.size(), (size_t)9); i++)
{
start_text_list_style(inst->get_text_list_style()->get_style_name());
content[i]->docx_convert(*this);
@ -1060,7 +1060,7 @@ void docx_conversion_context::start_list_item(bool restart)
if (restart && !list_style_stack_.empty())
{
const std::wstring curStyleName = current_list_style();
const std::wstring newStyleName = curStyleName + boost::lexical_cast<std::wstring>(new_list_style_number_++);
const std::wstring newStyleName = curStyleName + std::to_wstring(new_list_style_number_++);
list_style_renames_[curStyleName] = newStyleName;
odf_reader::list_style_container & lists = root()->odf_context().listStyleContainer();
@ -1195,7 +1195,7 @@ void docx_conversion_context::process_headers_footers()
// проходим по всем page layout
BOOST_FOREACH(const odf_reader::style_master_page* page, pageLayouts.master_pages())
{
const std::wstring & styleName = page->style_master_page_attlist_.style_name_.get_value_or( odf_types::style_ref(L"") ).style_name();
const std::wstring & styleName = page->attlist_.style_name_.get_value_or( L"" );
const std::wstring masterPageNameLayout =context.pageLayoutContainer().page_layout_name_by_style(styleName);
add_page_properties(masterPageNameLayout);
@ -1240,7 +1240,7 @@ std::wstring notes_context::add(const std::wstring & Content, const std::wstring
std::wstring notes_context::next_id()
{
instances_map & map = (type_ == odf_types::noteclass::Endnote) ? instances_endnotes_ : instances_footnotes_;
const std::wstring s = boost::lexical_cast<std::wstring>(map.size() + 1);
const std::wstring s = std::to_wstring(map.size() + 1);
return s;
}
@ -1291,14 +1291,14 @@ void docx_conversion_context::start_text_changes (std::wstring id)
if (state.type == 1)
{
output_stream() << L"<w:ins" << format_change << L" w:id=\"" << boost::lexical_cast<std::wstring>(current_id_changes++) << L"\">";
output_stream() << L"<w:ins" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
}
if (state.type == 2)
{
for (int i = 0 ; i < state.content.size(); i++)
for (size_t i = 0 ; i < state.content.size(); i++)
{
output_stream() << L"<w:del" << format_change << L" w:id=\"" << boost::lexical_cast<std::wstring>(current_id_changes++) << L"\">";
output_stream() << L"<w:del" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
output_stream() << state.content[i];
@ -1330,7 +1330,7 @@ void docx_conversion_context::start_changes()
std::wstring change_attr;
change_attr += L" w:date=\"" + state.date + L"\"";
change_attr += L" w:author=\"" + state.author + L"\"";
change_attr += L" w:id=\"" + boost::lexical_cast<std::wstring>(current_id_changes++) + L"\"";
change_attr += L" w:id=\"" + std::to_wstring(current_id_changes++) + L"\"";
if (state.type == 1)
{

View File

@ -53,7 +53,6 @@ namespace cpdoccore {
namespace odf_types
{
class style_ref;
class length_or_percent;
}
namespace odf_reader

View File

@ -317,7 +317,8 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
{
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
CP_XML_NODE(L"wp:cNvGraphicFramePr")
@ -529,10 +530,10 @@ mso-position-vertical-relative:text;";
strStyle += L"margin-top:" + boost::lexical_cast<std::wstring>(val.y / 12700.) + L"pt;";
strStyle += L"width:" + boost::lexical_cast<std::wstring>(val.cx / 12700.) + L"pt;";
strStyle += L"height:" + boost::lexical_cast<std::wstring>(val.cy / 12700.) + L"pt;";
strStyle += L"z-index:" + boost::lexical_cast<std::wstring>(0xF000800 - val.id);
strStyle += L"z-index:" + std::to_wstring(0xF000800 - val.id);
CP_XML_ATTR(L"id", L"Rect" + boost::lexical_cast<std::wstring>(val.id));
CP_XML_ATTR(L"o:spid", L"_x0000_s" + boost::lexical_cast<std::wstring>(1024 + val.id));
CP_XML_ATTR(L"id", L"Rect" + std::to_wstring(val.id));
CP_XML_ATTR(L"o:spid", L"_x0000_s" + std::to_wstring(1024 + val.id));
CP_XML_ATTR(L"style", strStyle);
CP_XML_ATTR(L"fillcolor", L"#4f81bd [3204]");
CP_XML_ATTR(L"strokecolor", L"#243f60 [1604]");

View File

@ -47,12 +47,12 @@ docx_content_types_file::docx_content_types_file()
content()->add_default(L"jpg", L"image/jpeg");
content()->add_default(L"png", L"image/png");
//
content()->add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml");
content()->add_override(L"/word/_rels/document.xml.rels", L"application/vnd.openxmlformats-package.relationships+xml");
content()->add_override(L"/word/document.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
content()->add_override(L"/word/settings.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml");
content()->add_override(L"/word/styles.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml");
content()->add_override(L"/word/fontTable.xml", L"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml");
//content()->add_override(L"/word/_rels/document.xml.rels", L"application/vnd.openxmlformats-package.relationships+xml");
//content()->add_override(L"/_rels/.rels", L"application/vnd.openxmlformats-package.relationships+xml");
content()->add_override(L"/docProps/app.xml", L"application/vnd.openxmlformats-officedocument.extended-properties+xml");
content()->add_override(L"/docProps/core.xml", L"application/vnd.openxmlformats-package.core-properties+xml");
}
@ -223,7 +223,7 @@ void docx_charts_files::write(const std::wstring & RootPath)
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"chart") + boost::lexical_cast<std::wstring>(count) + L".xml";
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();

View File

@ -49,6 +49,8 @@ struct _rect
struct drawing_object_description
{
bool bNotes_;
oox::RelsType type_;
std::wstring name_;
@ -60,7 +62,9 @@ struct drawing_object_description
double anchor_x_;
double anchor_y_;
_action_desc action_;
std::vector<_hlink_desc> hlinks_;
std::vector<odf_reader::_property> additional_; //shape properties
std::wstring xlink_href_; //ссылка на внешний объект

View File

@ -39,13 +39,13 @@ namespace oox {
std::wstring headers_footers::create_id(size_t i)
{
return std::wstring(L"rHFId") + boost::lexical_cast<std::wstring>(i);
return std::wstring(L"rHFId") + std::to_wstring(i);
}
std::wstring headers_footers::create_name(size_t i, headers_footers::Type _Type)
{
return ((_Type == header || _Type == headerLeft || _Type == headerFirst) ? std::wstring(L"header") : std::wstring(L"footer") )
+ boost::lexical_cast<std::wstring>(i) + L".xml";
+ std::to_wstring(i) + L".xml";
}
std::wstring headers_footers::add(const std::wstring & StyleName,
@ -64,9 +64,10 @@ std::wstring headers_footers::add(const std::wstring & StyleName,
}
instance_ptr inst = instance_ptr( new instance(id, Content, type, name) );
BOOST_FOREACH(const relationship & r, _rels.relationships())
std::vector<relationship> & rels = _rels.relationships();
for (size_t i = 0; i < rels.size(); i++)
{
inst->rels_.add(r);
inst->rels_.add(rels[i]);
}
instances_[StyleName].push_back(inst);
return id;

View File

@ -44,7 +44,8 @@ namespace oox {
hyperlinks::_ref hyperlinks::last()
{
_ref r={};
if (hrefs_.size()>0)
if (!hrefs_.empty())
r = hrefs_.back();
return r;
@ -52,9 +53,9 @@ hyperlinks::_ref hyperlinks::last()
std::wstring hyperlinks::add(const std::wstring & href, _type_place type_place, bool drawing)
{
std::wstring id = std::wstring(L"rHpId") + boost::lexical_cast<std::wstring>(hrefs_.size()+1);
std::wstring id = std::wstring(L"rHpId") + std::to_wstring(hrefs_.size() + 1);
_ref r ={xml::utils::replace_text_to_xml(href), type_place, drawing, id, false};
_ref r = {xml::utils::replace_text_to_xml(href), type_place, drawing, id};
hrefs_.push_back(r);
@ -65,14 +66,14 @@ std::wstring hyperlinks::add(const std::wstring & href, _type_place type_place,
void hyperlinks::dump_rels(rels & Rels, _type_place type)
{
size_t i = 0;
BOOST_FOREACH(_ref & elm, hrefs_)
for (size_t i = 0; i < hrefs_.size(); i++)
{
if (elm.used_rels)continue; // уже использовали этот релс
if (hrefs_[i].used_rels)continue; // уже использовали этот релс
if (elm.type_place == type)
if (hrefs_[i].type_place == type)
{
Rels.add( relationship(elm.id, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", elm.href, L"External" ) );
elm.used_rels = true;
Rels.add( relationship(hrefs_[i].id, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hrefs_[i].href, L"External" ) );
hrefs_[i].used_rels = true;
}
}
}

View File

@ -71,7 +71,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
// for (int i = 0; i <= 9; ++i)
{
//if (FALSE == (hr = pFontManager->LoadString2( boost::lexical_cast<std::wstring>(i), 0, 0)))
//if (FALSE == (hr = pFontManager->LoadString2( std::to_wstring(i), 0, 0)))
// return std::pair<float, float>(7,8);
if (FALSE == (hr = pFontManager->LoadString2( L"xxxxx" , 0, 0)))

View File

@ -58,7 +58,7 @@ bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
return NSDirectory::Exists(resultPath) || NSDirectory::Exists(mediaPath);
return NSFile::CFileBinary::Exists(resultPath) || NSDirectory::Exists(mediaPath);
}
mediaitems::item::item( std::wstring const & _href,
@ -140,7 +140,7 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
if (type == typeOleObject && sExt.empty())
sExt = L".bin";
return get_default_file_name(type) + boost::lexical_cast<std::wstring>(Num) + sExt;
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
}
std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
@ -166,8 +166,7 @@ std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
{
bool isMediaInternal = is_internal(href, odf_packet_);
bool isMediaInternal = true;
std::wstring sub_path = L"media/";
std::wstring inputFileName;
@ -175,10 +174,13 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
sub_path = L"charts/";
}
if ( type == typeMsObject || type == typeOleObject)
else if ( type == typeMsObject || type == typeOleObject)
{
sub_path = L"embeddings/";
}
else
isMediaInternal = is_internal(href, odf_packet_);
int number=0;
if ( type == typeChart) number = count_charts + 1;
@ -217,7 +219,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
if ( type == typeChart)
{
id = std::wstring(L"chId") + boost::lexical_cast<std::wstring>(count_charts + 1);
id = std::wstring(L"chId") + std::to_wstring(count_charts + 1);
count_charts++;
}
else if ( type == typeImage)
@ -230,17 +232,17 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
//------------------------------------------------
if (inputFileName.empty()) return L"";
id = std::wstring(L"picId") + boost::lexical_cast<std::wstring>(count_image + 1);
id = std::wstring(L"picId") + std::to_wstring(count_image + 1);
count_image++;
}
else if ( type == typeMsObject || type == typeOleObject)
{
id = std::wstring(L"objId") + boost::lexical_cast<std::wstring>(count_object + 1);
id = std::wstring(L"objId") + std::to_wstring(count_object + 1);
count_object++;
}
else
{
id = std::wstring(L"rId") + boost::lexical_cast<std::wstring>(count_shape + 1);
id = std::wstring(L"rId") + std::to_wstring(count_shape + 1);
count_shape++;
}

View File

@ -88,16 +88,19 @@ public:
{
switch (type)
{
case typeImage: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
case typeChart: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
case typeMsObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
case typeOleObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
case typeHyperlink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
default:
return L"";
case typeImage: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
case typeChart: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
case typeMsObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
case typeOleObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
case typeHyperlink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
case typeMedia: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/media";
case typeAudio: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio";
case typeVideo: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video";
case typeSlide: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
default:
return L"";
}
}
private:
std::wstring create_file_name (const std::wstring & uri, RelsType type, bool & isInternal, size_t Num);
std::wstring detectImageFileExtension (std::wstring &fileName);

View File

@ -139,7 +139,7 @@ void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values)
if (ind == 0) values_[ind].strRef_.present = true;
else values_[ind].numRef_.present = true;
for (int i = 0; i < values.size(); i++)
for (size_t i = 0; i < values.size(); i++)
{
boost::algorithm::trim(values[i]);
if (ind == 0)
@ -240,7 +240,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
{
CP_XML_ATTR(L"val", values_[i].numRef_.num_cache_count);
}
for (int j = 0; j < values_[i].numRef_.num_cache.size(); j++)
for (size_t j = 0; j < values_[i].numRef_.num_cache.size(); j++)
{
std::wstring & v = values_[i].numRef_.num_cache[j];
@ -275,7 +275,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
CP_XML_ATTR(L"val", values_[i].numRef_.num_cache_count);
}
for (int j = 0; j < values_[i].numRef_.num_cache.size(); j++)
for (size_t j = 0; j < values_[i].numRef_.num_cache.size(); j++)
{
std::wstring & v = values_[i].numRef_.num_cache[j];
@ -312,7 +312,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
{
CP_XML_ATTR(L"val", values_[i].strRef_.str_cache_count);
}
for (int j = 0; j < values_[i].strRef_.str_cache.size(); j++)
for (size_t j = 0; j < values_[i].strRef_.str_cache.size(); j++)
{
std::wstring & v = values_[i].strRef_.str_cache[j];
@ -336,7 +336,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
{
CP_XML_ATTR(L"val", values_[i].strRef_.str_cache_count);
}
for (int j = 0; j < values_[i].strRef_.str_cache.size(); j++)
for (size_t j = 0; j < values_[i].strRef_.str_cache.size(); j++)
{
std::wstring & v = values_[i].strRef_.str_cache[j];
CP_XML_NODE(L"c:pt")
@ -405,7 +405,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
bool bEmpty_dPt = true;
for (int i = 0 ; i < content_.points_.size(); i++)
for (size_t i = 0 ; i < content_.points_.size(); i++)
{
if (content_.points_[i].bEnabled)
{
@ -415,9 +415,9 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
int indPoint = 0;
for (int i = 0 ; !bEmpty_dPt && i < content_.points_.size(); i++)
for (size_t i = 0 ; !bEmpty_dPt && i < content_.points_.size(); i++)
{
for (int j = 0 ; j < content_.points_[i].repeated_; j++)
for (size_t j = 0 ; j < content_.points_[i].repeated_; j++)
{
CP_XML_NODE(L"c:dPt")
{

View File

@ -144,7 +144,8 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
}
namespace oox
{
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) : base_font_size_(12), fonts_container_(fonts)
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :
base_font_size_(12), fonts_container_(fonts)
{
graphRPR_ = graphic;

View File

@ -35,9 +35,65 @@
#include "oox_drawing.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/svg_parser.h"
#include "../odf/datatypes/custom_shape_types_convert.h"
using namespace cpdoccore;
namespace svg_path
{
void oox_serialize(std::wostream & strm, std::vector<_polyline> & path)
{
CP_XML_WRITER(strm)
{
for (size_t i = 0; i < path.size(); i++)
{
oox_serialize(strm, path[i]);
}
}
}
void oox_serialize(std::wostream & strm, _polyline & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(val.command)
{
if (val.command == L"a:ArcTo")
{
if (val.points.size() > 0)
{
CP_XML_ATTR(L"wR", (int)(val.points[0].x.get()));
CP_XML_ATTR(L"hR", (int)(val.points[0].y.get()));
}
if (val.points.size() > 1)
{
CP_XML_ATTR(L"stAng", (int)(val.points[1].x.get() * 60000));
CP_XML_ATTR(L"swAng", (int)(val.points[1].y.get() * 60000));
}
}
else
{
for (size_t i = 0; i < val.points.size(); i++)
{
oox_serialize(CP_XML_STREAM(), val.points[i]);
}
}
}
}
}
void oox_serialize(std::wostream & strm, _point & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pt")
{
if (val.x)CP_XML_ATTR(L"x", (int)(val.x.get()));
if (val.y)CP_XML_ATTR(L"y", (int)(val.y.get()));
}
}
}
}
namespace cpdoccore {
static const std::wstring _ooxShapeType[]=
@ -53,41 +109,6 @@ static const std::wstring _ooxShapeType[]=
L"polygon",
};
void svg_path::oox_serialize(std::wostream & strm, std::vector<svg_path::_polyline> & path)
{
CP_XML_WRITER(strm)
{
BOOST_FOREACH(svg_path::_polyline & p, path)
{
oox_serialize(strm, p);
}
}
}
void svg_path::oox_serialize(std::wostream & strm, svg_path::_polyline const & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(val.command)
{
BOOST_FOREACH(svg_path::_point const & p, val.points)
{
oox_serialize(CP_XML_STREAM(), p);
}
}
}
}
void svg_path::oox_serialize(std::wostream & strm, svg_path::_point const & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pt")
{
if (val.x)CP_XML_ATTR(L"x", (int)(val.x.get()));
if (val.y)CP_XML_ATTR(L"y", (int)(val.y.get()));
}
}
}
namespace oox {
@ -107,7 +128,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
_CP_OPT(std::wstring) strStrokeColor;
_CP_OPT(int) iStroke;
_CP_OPT(double) dStrokeWidth;
_CP_OPT(double) dStrokeOpacity;
_CP_OPT(double) dStrokeOpacity;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(prop, L"wordArt", bWordArt);
@ -146,15 +167,23 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
{
if (fill != L"a:noFill")
{
if (color.length() < 1 && always_draw) color = L"000000";
else if (color.length() <1 ) color = L"ffffff";
if ( color.empty() )
{
if (always_draw) color = L"000000";
else color = L"ffffff";
}
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val",color);
if (dStrokeOpacity) CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val", *dStrokeOpacity);}
if (dStrokeOpacity)
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val", (int)(*dStrokeOpacity * 1000));
}
}
}
}
}
@ -182,69 +211,33 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
}
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
{
_CP_OPT(int) iShapeIndex;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(prop, L"wordArt" , bWordArt);
odf_reader::GetProperty(prop, L"odf-custom-draw-index" , iShapeIndex);
int count_values = 0, min_value = 0, max_value = 0;
if (!bWordArt && iShapeIndex)
{
count_values = _OO_OOX_custom_shapes[*iShapeIndex].count_values;
min_value = _OO_OOX_custom_shapes[*iShapeIndex].min;
max_value = _OO_OOX_custom_shapes[*iShapeIndex].max;
}
else if (iShapeIndex)
{
count_values = _OO_OOX_wordart[*iShapeIndex].count_values;
min_value = _OO_OOX_wordart[*iShapeIndex].min;
max_value = _OO_OOX_wordart[*iShapeIndex].max;
}
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:avLst")
{
_CP_OPT(std::wstring) strVal;
if (odf_reader::GetProperty(prop,L"draw-modifiers",strVal) && iShapeIndex)
_CP_OPT(bool) bModifiers;
_CP_OPT(std::wstring) strModifiers;
odf_reader::GetProperty(prop, L"bModifiers", bModifiers);
odf_reader::GetProperty(prop, L"oox-draw-modifiers", strModifiers);
if (strModifiers)
{
std::vector< std::wstring > values;
boost::algorithm::split(values, strVal.get(), boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
boost::algorithm::split(values, strModifiers.get(), boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if( count_values >0 && values.size()>0 && count_values < 3)//временное ограниечение .. хз как там свойства путаются
{//если не заданы доп свойства - нефиг мучится
int i=1;
if (!values.empty() && values.back().empty()) values.pop_back();
_CP_OPT(int) iMax,iMin;
odf_reader::GetProperty(prop,L"draw-modifiers-min",iMin);
odf_reader::GetProperty(prop,L"draw-modifiers-max",iMax);
values.resize(count_values);
BOOST_FOREACH(std::wstring & v, values)
for (size_t i = 0; i < values.size(); i++)
{
if (values[i].empty()) continue;
CP_XML_NODE(L"a:gd")
{
CP_XML_NODE(L"a:gd")
{
if (values.size() >1)
CP_XML_ATTR(L"name",(L"adj" + boost::lexical_cast<std::wstring>(i++)));
else
CP_XML_ATTR(L"name",L"adj");
double val=0;
if (v.length()>0)val= boost::lexical_cast<double>(v);
if (iMin && iMax && iShapeIndex)
{
if (min_value < max_value)
{
double W = *iMax - *iMin;
val = (val- (*iMin))/W * (max_value - min_value) + min_value;
}
}
CP_XML_ATTR(L"fmla",L"val " + boost::lexical_cast<std::wstring>(static_cast<int>(val)));
}
if (values.size() > 1 || bModifiers)
//весьма странное .. для некоторых модификаторов (напр math...) нужно указывать множественность их
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i+1));
else
CP_XML_ATTR(L"name", L"adj");
CP_XML_ATTR(L"fmla", L"val " + values[i]);
}
}
}
@ -337,37 +330,39 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
void _oox_drawing::serialize_shape(std::wostream & strm)
{
_CP_OPT(std::wstring) strVal;
_CP_OPT(double) dVal;
_CP_OPT(int) iOoxShapeIndex;
_CP_OPT(bool) bWordArt, bOoxShape;
_CP_OPT(std::wstring) sCustomPath;
odf_reader::GetProperty(additional, L"wordArt", bWordArt);
odf_reader::GetProperty(additional, L"oox-geom-index", iOoxShapeIndex);
odf_reader::GetProperty(additional, L"oox-geom", bOoxShape);
std::wstring shapeType;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(additional,L"wordArt", bWordArt);
odf_reader::GetProperty(additional, L"custom_path", sCustomPath);
std::wstring shapeGeomPreset;
if (sub_type == 7)//custom
{
_CP_OPT(int) iVal;
odf_reader::GetProperty(additional, L"odf-custom-draw-index",iVal);
if (iVal)
shapeType = _OO_OOX_custom_shapes[*iVal].oox;
else
if (iOoxShapeIndex)
shapeGeomPreset = _OO_OOX_custom_shapes[*iOoxShapeIndex].oox;
else if (sCustomPath)
sub_type = 6; //path
if (shapeType == L"textBox")
if (shapeGeomPreset == L"textBox")
{
sub_type = 1;
shapeType = L"rect";
shapeGeomPreset = L"rect";
}
}
else if (sub_type < 9 && sub_type >= 0)
{
shapeType = _ooxShapeType[sub_type];
shapeGeomPreset = _ooxShapeType[sub_type]; //odf -> oox
}
if (bWordArt) sub_type = 1;
CP_XML_WRITER(strm)
{
if (sub_type == 6 || sub_type == 8)
@ -386,36 +381,44 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
CP_XML_ATTR(L"t", 0);
}
//<a:rect b="b" l="0" r="r" t="0"/>
if (odf_reader::GetProperty(additional, L"custom_path", strVal))
{
_CP_OPT(int) w, h;
odf_reader::GetProperty(additional, L"custom_path_w", w);
odf_reader::GetProperty(additional, L"custom_path_h", h);
_CP_OPT(int) w, h;
odf_reader::GetProperty(additional, L"custom_path_w", w);
odf_reader::GetProperty(additional, L"custom_path_h", h);
CP_XML_NODE(L"a:pathLst")
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : cy);
CP_XML_STREAM() << strVal.get();
CP_XML_NODE(L"a:pathLst")
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : cy);
if (sCustomPath)
{
CP_XML_STREAM() << *sCustomPath;
}
}
}
}
}
}
else
{
if (shapeType.length() < 1)
if (shapeGeomPreset.empty())
{
shapeType = L"rect";
sub_type = 2;
shapeGeomPreset = L"rect";
sub_type = 2;
}
CP_XML_NODE(L"a:prstGeom")//автофигура
{
CP_XML_ATTR(L"prst", shapeType);
if (!bWordArt) oox_serialize_aLst(CP_XML_STREAM(), additional);
CP_XML_ATTR(L"prst", shapeGeomPreset);
if (!bWordArt)
{
if (std::wstring::npos != shapeGeomPreset.find(L"mathPlus"))
{
additional.push_back(odf_reader::_property(L"bModifiers", true));
}
oox_serialize_aLst(CP_XML_STREAM(), additional);
}
}
}
if (bWordArt)
@ -513,23 +516,24 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
}
}
}
void oox_serialize_hlink(std::wostream & strm, std::vector<_hlink_desc> const & val)
void oox_serialize_action(std::wostream & strm, _action_desc const & val)
{
if (val.enabled == false) return;
CP_XML_WRITER(strm)
{
BOOST_FOREACH(const _hlink_desc & h, val)
CP_XML_NODE(L"a:hlinkClick")
{
if (h.in_object == true)
{
CP_XML_NODE(L"a:hlinkClick")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"r:id", h.hId);
}
break;
}
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"r:id", val.hId);
if (!val.action.empty())
CP_XML_ATTR(L"action", val.action);
if (val.highlightClick)
CP_XML_ATTR(L"highlightClick", val.highlightClick);
}
}
}

View File

@ -40,6 +40,8 @@
#include "mediaitems.h"
#include "oox_drawing_fills.h"
#include "../odf/svg_parser.h"
#include "../../../Common/DocxFormat/Source/Base/Types_32.h"
namespace cpdoccore {
@ -49,10 +51,28 @@ namespace oox {
{
std::wstring hId;
std::wstring hRef;
};
struct _action_desc
{
_action_desc() : enabled(false), highlightClick(false) {}
void clear()
{
enabled = false;
highlightClick = false;
hId.clear();
hRef.clear();
action.clear();
}
bool enabled;
bool in_object;
};
std::wstring hId;
std::wstring hRef;
std::wstring action;
RelsType typeRels;
bool highlightClick;
};
class _oox_drawing
{
public:
@ -72,10 +92,12 @@ namespace oox {
_oox_fill fill;
std::wstring objectId;
std::wstring objectProgId;
std::wstring objectId;
std::wstring objectProgId;
_action_desc action;
std::vector<_hlink_desc> hlinks;
std::vector<_hlink_desc> hlinks;
std::vector<odf_reader::_property> additional;
virtual void serialize (std::wostream & strm) = 0;
@ -83,13 +105,19 @@ namespace oox {
void serialize_shape (std::wostream & strm);
void serialize_xfrm (std::wostream & strm, const std::wstring & namespace_ = L"a", bool always_position = false);
void serialize_bodyPr (std::wostream & strm, const std::wstring & namespace_ = L"a");
};
};
typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
void oox_serialize_hlink (std::wostream & strm, const std::vector<_hlink_desc> & val);
void oox_serialize_action (std::wostream & strm, const _action_desc & val);
}
}
}
namespace svg_path
{
void oox_serialize (std::wostream & strm, _point & val);
void oox_serialize (std::wostream & strm, _polyline & val);
void oox_serialize (std::wostream & strm, std::vector<_polyline> & path);
}

View File

@ -66,12 +66,12 @@ void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double)
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val",color);
CP_XML_ATTR(L"val", color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val", boost::lexical_cast<std::wstring>((int)(*opacity)*1000));// + L"%");
CP_XML_ATTR(L"val", std::to_wstring((int)(*opacity)*1000));// + L"%");
}
}
}
@ -88,7 +88,7 @@ void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf_type
{
CP_XML_NODE(L"a:alpha")
{
CP_XML_ATTR(L"val", boost::lexical_cast<std::wstring>((int)opacity->get_value()*1000));// + L"%");
CP_XML_ATTR(L"val", std::to_wstring((int)opacity->get_value()*1000));// + L"%");
}
}
}
@ -101,11 +101,56 @@ void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val)
{
CP_XML_NODE(L"a:solidFill")
{
oox_serialize_srgb(CP_XML_STREAM(),val.solid->color,val.opacity);
oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity);
}
}
}
void vml_serialize_solid_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.solid) return;
if (!val.opacity) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"v:fill")
{
if (val.opacity)
{
CP_XML_ATTR(L"opacity", (int)(*val.opacity));
}
}
}
}
void vml_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.bitmap) return;
if (!val.bitmap->isInternal) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"v:fill")
{
CP_XML_ATTR(L"r:id", val.bitmap->rId );
if (val.opacity)
{
CP_XML_ATTR(L"opacity",(int)(*val.opacity));
}
if (val.bitmap->bTile)
{
CP_XML_ATTR(L"type", L"pattern");
}
else
{
CP_XML_ATTR(L"type", L"frame");
}
CP_XML_ATTR(L"recolor", L"t");
}
}
}
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.bitmap) return;
@ -164,20 +209,69 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
CP_XML_NODE(L"a:fillRect");
}
}
}
}
}
}
void vml_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.gradient) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"v:fill")
{
if (!val.gradient->colors.empty())
{
CP_XML_ATTR(L"color2", val.gradient->colors[val.gradient->colors.size() - 1].color_ref);
std::wstring colors_value;
for (size_t i = 0; i < val.gradient->colors.size(); i++)
{
colors_value += std::to_wstring(val.gradient->colors[i].pos) + L"% #" +
val.gradient->colors[i].color_ref + L",";
}
if (!colors_value.empty())
{
CP_XML_ATTR(L"colors", colors_value.substr(0, colors_value.length() - 1));
}
}
double angle =/*360 - */val.gradient->angle/* * 180./3.14159265358979323846*/;
CP_XML_ATTR(L"focus", L"100%");
switch(val.gradient->style)
{
case 0:
CP_XML_ATTR(L"type", L"gradient");
CP_XML_ATTR(L"method", L"linear");
CP_XML_ATTR(L"angle", angle);
break;
case 1:
//CP_XML_ATTR(L"type", L"gradientRadial");
//break;
case 2:
//CP_XML_ATTR(L"type", L"gradientCenter");
//break;
case 3:
//CP_XML_ATTR(L"type", L"gradientUnscaled");
//break;
CP_XML_ATTR(L"type", L"gradientRadial");
}
if (val.gradient->style > 0)
{
double focus_x = ((val.gradient->rect[2] - val.gradient->rect[0]) /2. + val.gradient->rect[0]) / 100.;
double focus_y = ((val.gradient->rect[3] - val.gradient->rect[1]) /2. + val.gradient->rect[1]) / 100.;
CP_XML_ATTR(L"focusposition", XmlUtils::DoubleToString(focus_x, L"%.2f") + L"," + XmlUtils::DoubleToString(focus_y, L"%.2f"));
}
}
}
}
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.gradient)
{
return;
}
if (!val.gradient) return;
CP_XML_WRITER(strm)
{
@ -233,6 +327,7 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val)
{
if (!val.hatch)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pattFill")
@ -253,7 +348,38 @@ void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val)
}
}
}
void oox_serialize_fill(std::wostream & strm, const _oox_fill & val)
void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring & color, int id)
{
if (val.type == 0) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"v:background")
{
CP_XML_ATTR(L"id", L"_x0000_s" + std::to_wstring(1024 + id));
CP_XML_ATTR(L"o:bwmode", L"white");
CP_XML_ATTR(L"fillcolor", L"#" + color);
CP_XML_ATTR(L"o:targetscreensize", L"1024,768");
switch (val.type)
{
case 1:
vml_serialize_solid_fill(CP_XML_STREAM(), val);
break;
case 2:
vml_serialize_bitmap_fill(CP_XML_STREAM(), val);
break;
case 3:
vml_serialize_gradient_fill(CP_XML_STREAM(), val);
break;
case 4:
//vml_serialize_hatch_fill(CP_XML_STREAM(), val);
break;
}
}
}
}
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val)
{
switch (val.type)
{

View File

@ -143,9 +143,10 @@ namespace oox {
}
};
void oox_serialize_fill(std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity);
void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring & color, int id);
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity);
}
}

View File

@ -56,18 +56,6 @@ std::wostream & relationship::xml_to_stream(std::wostream & _Wostream) const
CP_XML_ATTR(L"TargetMode", target_mode());
}
}
//_Wostream << L"<Relationship ";
//CP_XML_SERIALIZE_ATTR(L"Id", id());
//CP_XML_SERIALIZE_ATTR(L"Type", type());
//CP_XML_SERIALIZE_ATTR(L"Target", target());
//
//if (!target_mode().empty())
//{
// CP_XML_SERIALIZE_ATTR(L"TargetMode", target_mode());
//}
//_Wostream << L" />";
return _Wostream;
}
@ -82,23 +70,12 @@ std::wostream & rels::xml_to_stream(std::wostream & _Wostream) const
{
CP_XML_ATTR(L"xmlns", xmlns::rels.value);
BOOST_FOREACH(const relationship & r, relationship_)
for (size_t i = 0; i < relationship_.size(); i++)
{
r.xml_to_stream(CP_XML_STREAM());
relationship_[i].xml_to_stream(CP_XML_STREAM());
}
} // "Relationships"
}
}
//_Wostream << L"<Relationships ";
//CP_XML_SERIALIZE_ATTR(L"xmlns", xmlns::rels.value);
//_Wostream << L">";
//BOOST_FOREACH(const relationship & r, relationship_)
//{
// r.xml_to_stream(_Wostream);
//}
//_Wostream << L"</Relationships>";
return _Wostream;
}

View File

@ -52,7 +52,10 @@ enum RelsType
typeMedia,
typeGroupShape,
typeMsObject,
typeOleObject
typeOleObject,
typeSlide,
typeVideo,
typeAudio
};
struct _rel

View File

@ -54,13 +54,13 @@ public:
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content,pptx_comments_ptr comments)
{
const std::wstring file_id = boost::lexical_cast<std::wstring>(next_file_id_++);
const std::wstring file_id = std::to_wstring(next_file_id_++);
const std::wstring fileName = std::wstring(L"comment") + file_id + L".xml";
comments_.push_back(pptx_comment_elm(fileName, content, comments));
const std::wstring id = boost::lexical_cast<std::wstring>(next_comments_id_++);
const std::wstring id = std::to_wstring(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(fileName, rId);
}

View File

@ -99,7 +99,7 @@ void pptx_conversion_context::process_layouts()
get_text_context().set_process_layouts(true);
//актуальные
for (int layout_index =0; layout_index < layouts.content.size(); layout_index++)
for (size_t layout_index =0; layout_index < layouts.content.size(); layout_index++)
{
start_layout(layout_index);
@ -116,23 +116,24 @@ void pptx_conversion_context::process_layouts()
if (master)
{
for (int i = 0; i < master->content_.size(); i++)
for (size_t i = 0; i < master->content_.size(); i++)
{
odf_reader::office_element_ptr elm = master->content_[i];
if (elm->get_type() == odf_reader::typeDrawFrame)
odf_reader::draw_frame* frame = dynamic_cast<odf_reader::draw_frame*>(master->content_[i].get());
if (frame)
{
odf_reader::draw_frame* frame = dynamic_cast<odf_reader::draw_frame *>(elm.get());
if ((frame) && (frame->common_presentation_attlist_.presentation_class_))
odf_types::common_presentation_attlist &common_presentation_attlist_= frame->common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_;
if (common_presentation_attlist_.presentation_class_)
{
odf_types::presentation_class::type type = frame->common_presentation_attlist_.presentation_class_->get_type();
odf_types::presentation_class::type type = common_presentation_attlist_.presentation_class_->get_type();
if (type==odf_types::presentation_class::footer ||
type==odf_types::presentation_class::date_time ||
type==odf_types::presentation_class::header ||
type==odf_types::presentation_class::page_number)
if (type == odf_types::presentation_class::footer ||
type == odf_types::presentation_class::date_time ||
type == odf_types::presentation_class::header ||
type == odf_types::presentation_class::page_number)
{
if (frame->idx_in_owner <0)frame->idx_in_owner = last_idx_placeHolder++;
if (frame->idx_in_owner < 0)
frame->idx_in_owner = last_idx_placeHolder++;
frame->pptx_convert_placeHolder(*this);
}
@ -152,7 +153,9 @@ void pptx_conversion_context::process_master_pages()
get_text_context().set_process_layouts(true);
//берем только актуальные
for (int master_index =0; master_index < masters.content.size();master_index++)
odf_reader::office_element_ptr master_notes_;
for (size_t master_index = 0; master_index < masters.content.size(); master_index++)
{
start_master(master_index);
@ -162,10 +165,21 @@ void pptx_conversion_context::process_master_pages()
if (master)
{
master->pptx_convert(*this);
if (!master_notes_ && master->presentation_notes_)
master_notes_ = master->presentation_notes_;
}
end_master();
}
if (master_notes_)
{
start_master_notes();
master_notes_->pptx_convert(*this);
end_master_notes();
}
process_masters_ = false;
get_text_context().set_process_layouts(false);
@ -179,15 +193,15 @@ void pptx_conversion_context::process_theme(std::wstring name)
{
int current = themes_.size() + 1;
if (name.length()<1)
if (name.empty())
{
name = L"User Theme: " + boost::lexical_cast<std::wstring>(current);
name = L"User Theme: " + std::to_wstring(current);
}
start_theme(name);
//
pptx_serialize_clrScheme(current_theme().clrSchemeData());
pptx_serialize_fmtScheme(current_theme().fmtSchemeData());
pptx_serialize_fontScheme(current_theme().fontSchemeData());
pptx_serialize_clrScheme (current_theme().clrSchemeData());
pptx_serialize_fmtScheme (current_theme().fmtSchemeData());
pptx_serialize_fontScheme (current_theme().fontSchemeData());
//
end_theme();
@ -208,9 +222,7 @@ void pptx_conversion_context::start_document()
void pptx_conversion_context::end_document()
{
unsigned int count = 1;
for (int i = 0; i < slideMasters_.size(); i++)
for (size_t i = 0; i < slideMasters_.size(); i++)
{
pptx_xml_slideMaster_ptr& slideM = slideMasters_[i];
@ -229,11 +241,12 @@ void pptx_conversion_context::end_document()
CP_XML_ATTR(L"r:id", slideM->rId());
}
}
count++;
}
if (!slideMasters_.empty())
presentation_.slidesProperties() << slideMasters_[0]->Sizes().str();
////////////////////////////////////////////////////////////////////////////////////////////////////
count=0;
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
pptx_xml_slide_ptr& slide = slides_[i];
@ -248,14 +261,13 @@ void pptx_conversion_context::end_document()
{
CP_XML_NODE(L"p:sldId")
{
CP_XML_ATTR(L"id", 0x100 + count);
CP_XML_ATTR(L"id", 0x100 + i);
CP_XML_ATTR(L"r:id", slide->rId());
}
}
count++;
}
///////////////////////////////////////////////////////////////////////////////////////////
for (int i = 0; i < slideLayouts_.size(); i++)
//----------------------------------------------------------------------------------
for (size_t i = 0; i < slideLayouts_.size(); i++)
{
pptx_xml_slideLayout_ptr& slideL = slideLayouts_[i];
@ -266,30 +278,42 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().add_slideLayout(content);//slideMaster.xml
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//размеры страниц в презентации
odf_reader::odf_read_context & context = root()->odf_context();
odf_reader::page_layout_container & pageLayouts = context.pageLayoutContainer();
if ((pageLayouts.master_pages().size()>0) && (pageLayouts.master_pages()[0]->style_master_page_attlist_.style_name_))//default
{
const std::wstring masterStyleName = pageLayouts.master_pages()[0]->style_master_page_attlist_.style_name_->style_name();
const std::wstring pageProperties = root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterStyleName);
//----------------------------------------------------------------------------------
for (size_t i = 0; i < notes_.size(); i++)
{
pptx_xml_slideNotes_ptr& slideN = notes_[i];
odf_reader::page_layout_instance *pages_layouts = root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties);
if (pages_layouts)pages_layouts->pptx_convert(*this);
package::slide_content_ptr content = package::slide_content::create();
slideN->write_to(content->content());
content->add_rels(slideN->Rels());//media & links rels
output_document_->get_ppt_files().add_notes(content);
}
/////////////////////////////////////////////////////////////////////////////////////////////
pptx_serialize_size(current_presentation().notesSlidesSize(),6858000,9144000,L"p:notesSz");
if (slideNotesMaster_)
{
package::slide_content_ptr content = package::slide_content::create();
slideNotesMaster_->write_to(content->content());
content->add_rels(slideNotesMaster_->Rels());//media & links rels
output_document_->get_ppt_files().add_notesMaster(content);
CP_XML_WRITER(presentation_.slideNotesMastersData())//presentation.xml
{
CP_XML_NODE(L"p:notesMasterId")
{
CP_XML_ATTR(L"r:id", slideNotesMaster_->rId());
}
}
}
//else
pptx_serialize_size(current_presentation().slidesNotesProperties(), 6858000, 9144000, L"p:notesSz");
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//добавляем диаграммы
count = 0;
for (int i = 0; i < charts_.size(); i++)
for (size_t i = 0; i < charts_.size(); i++)
{
count++;
package::chart_content_ptr content = package::chart_content::create();
charts_[i]->serialize(content->content());
@ -299,18 +323,17 @@ void pptx_conversion_context::end_document()
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//добавляем темы
for (int i=0; i < themes_.size();i++)
for (size_t i=0; i < themes_.size(); i++)
{
output_document_->get_ppt_files().add_theme(themes_[i]);
}
package::ppt_comments_files_ptr comments = package::ppt_comments_files::create(comments_context_handle_.content());
output_document_->get_ppt_files().set_presentation(presentation_);
output_document_->get_ppt_files().set_comments(comments);
output_document_->get_ppt_files().set_authors_comments(authors_comments_);
output_document_->get_ppt_files().set_media(get_mediaitems(), applicationFonts_);
output_document_->get_ppt_files().set_presentation (presentation_);
output_document_->get_ppt_files().set_comments (comments);
output_document_->get_ppt_files().set_authors_comments (authors_comments_);
output_document_->get_ppt_files().set_media (get_mediaitems(), applicationFonts_);
output_document_->get_content_types_file().set_media(get_mediaitems());
}
@ -320,7 +343,28 @@ void pptx_conversion_context::start_body()
void pptx_conversion_context::end_body()
{}
pptx_xml_slideNotesMaster & pptx_conversion_context::current_notesMaster()
{
if (slideNotesMaster_)
{
return *slideNotesMaster_;
}
else
{
throw std::runtime_error("internal error");
}
}
pptx_xml_slideNotes & pptx_conversion_context::current_notes()
{
if (!notes_.empty())
{
return *notes_.back().get();
}
else
{
throw std::runtime_error("internal error");
}
}
pptx_xml_slide & pptx_conversion_context::current_slide()
{
if (!slides_.empty())
@ -383,9 +427,18 @@ pptx_xml_slideMaster & pptx_conversion_context::current_master()
}
void pptx_conversion_context::create_new_slide(std::wstring const & name)
{
pptx_xml_slide_ptr s = pptx_xml_slide::create(name,slides_.size()+1);
pptx_xml_slide_ptr s = pptx_xml_slide::create(name,slides_.size() + 1);
slides_.push_back(s);
}
void pptx_conversion_context::create_new_slideNotes()
{
pptx_xml_slideNotes_ptr s = pptx_xml_slideNotes::create( notes_.size() + 1);
notes_.push_back(s);
}
void pptx_conversion_context::create_new_slideNotesMaster()
{
slideNotesMaster_ = pptx_xml_slideNotesMaster::create();
}
void pptx_conversion_context::create_new_slideLayout(int id)
{
pptx_xml_slideLayout_ptr s = pptx_xml_slideLayout::create(id);
@ -396,7 +449,6 @@ void pptx_conversion_context::create_new_slideMaster(int id)
pptx_xml_slideMaster_ptr s = pptx_xml_slideMaster::create(id);
slideMasters_.push_back(s);
}
bool pptx_conversion_context::start_page(const std::wstring & pageName, const std::wstring & pageStyleName,
const std::wstring & pageLayoutName,
const std::wstring & pageMasterName)
@ -413,7 +465,7 @@ bool pptx_conversion_context::start_page(const std::wstring & pageName, const st
root()->odf_context().styleContainer().presentation_layouts().add_or_find(pageLayoutName,pageMasterName);
current_slide().Rels().add(relationship(layout_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
std::wstring(L"../slideLayouts/slideLayout") + boost::lexical_cast<std::wstring>(layout_id.first) + L".xml"));
std::wstring(L"../slideLayouts/slideLayout") + std::to_wstring(layout_id.first) + L".xml"));
return true;
}
@ -437,7 +489,7 @@ bool pptx_conversion_context::start_layout(int layout_index)
root()->odf_context().styleContainer().presentation_masters().add_layout_to(layouts.content[layout_index].master_name,layouts.content[layout_index]);
current_layout().Rels().add(relationship(L"smId1"/*master_id.second*/, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
std::wstring(L"../slideMasters/slideMaster") + boost::lexical_cast<std::wstring>(master_id.first) + L".xml"));
std::wstring(L"../slideMasters/slideMaster") + std::to_wstring(master_id.first) + L".xml"));
//
}
@ -500,11 +552,19 @@ bool pptx_conversion_context::start_master(int master_index)
process_theme(masters.content[master_index].master_name);//add default theme - одинаковые но под разными именами
current_master().add_theme(current_theme().id(), L"tId1");
for (long i=0;i<masters.content[master_index].layouts.size();i++)
for (size_t i = 0; i < masters.content[master_index].layouts.size(); i++)
{
current_master().add_layout(masters.content[master_index].layouts[i].Id, masters.content[master_index].layouts[i].rId, 0x80000000 + last_uniq_big_id++);
}
//----------------------------------------------------------------------------------
//размеры страниц в презентации
const std::wstring pageProperties = root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masters.content[master_index].master_name);
odf_reader::page_layout_instance *pages_layouts = root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties);
if (pages_layouts)
pages_layouts->pptx_serialize(current_master().Sizes(), *this);
return true;
}
@ -529,6 +589,59 @@ void pptx_conversion_context::end_page()
get_slide_context().end_slide();
}
bool pptx_conversion_context::start_page_notes()
{
create_new_slideNotes( );
current_slide().Rels().add(relationship(notes_.back()->rId(), L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
L"../notesSlides/notesSlide" + std::to_wstring(notes_.size()) + L".xml"));
get_slide_context().start_slide();
current_notes().Rels().add(relationship(L"nId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
L"../slides/slide" + std::to_wstring(slides_.size()) + L".xml"));
return true;
}
void pptx_conversion_context::end_page_notes()
{
get_slide_context().serialize_background(current_notes().Background());
get_slide_context().serialize_objects(current_notes().Data());
get_slide_context().dump_rels(current_notes().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
}
bool pptx_conversion_context::start_master_notes()
{
create_new_slideNotesMaster( );
get_slide_context().start_slide();
process_theme(L"");//add default theme - одинаковые но под разными именами
current_notesMaster().add_theme(current_theme().id(), L"tId1");
get_slide_context().start_slide();
return true;
}
void pptx_conversion_context::end_master_notes()
{
get_slide_context().serialize_background(current_notesMaster().Background());
get_slide_context().serialize_objects(current_notesMaster().Data());
get_slide_context().dump_rels(current_notesMaster().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
for (size_t i = 0; i < notes_.size(); i++)
{
notes_[i]->Rels().add(relationship(L"nmId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
L"../notesMasters/notesMaster1.xml"));
}
}
void pptx_conversion_context::end_layout()
{
get_slide_context().serialize_objects(current_layout().Data());

View File

@ -88,6 +88,12 @@ public:
const std::wstring & pageMasterName);
void end_page();
bool start_page_notes();
void end_page_notes();
bool start_master_notes();
void end_master_notes();
bool start_layout( int layout_index);
void end_layout();
@ -107,10 +113,13 @@ public:
return odf_document_;
}
pptx_xml_slide & current_slide();
pptx_xml_slideLayout & current_layout();
pptx_xml_slideMaster & current_master();
pptx_xml_theme & current_theme();
pptx_xml_slide & current_slide();
pptx_xml_slideLayout & current_layout();
pptx_xml_slideMaster & current_master();
pptx_xml_theme & current_theme();
pptx_xml_slideNotes & current_notes();
pptx_xml_slideNotesMaster & current_notesMaster();
pptx_xml_presentation & current_presentation();//собственно она одна
oox_chart_context & current_chart();
@ -138,6 +147,8 @@ private:
void create_new_slide(std::wstring const & name);
void create_new_slideLayout(int id);
void create_new_slideMaster(int id);
void create_new_slideNotes();
void create_new_slideNotesMaster();
package::pptx_document * output_document_;
odf_reader::odf_document * odf_document_;
@ -152,10 +163,12 @@ private:
std::vector<oox_chart_context_ptr> charts_;
std::vector<pptx_xml_slide_ptr> slides_;
std::vector<pptx_xml_slideNotes_ptr> notes_;
std::vector<pptx_xml_slideMaster_ptr> slideMasters_;
std::vector<pptx_xml_slideLayout_ptr> slideLayouts_;
std::vector<pptx_xml_theme_ptr> themes_;
pptx_xml_slideNotesMaster_ptr slideNotesMaster_;
pptx_xml_authors_comments_ptr authors_comments_;
pptx_xml_presentation presentation_;

View File

@ -76,7 +76,7 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
CP_XML_NODE(L"p:cNvPicPr")
@ -109,6 +109,55 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
}
}
}
void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:pic")
{
CP_XML_NODE(L"p:nvPicPr")
{
CP_XML_NODE(L"p:cNvPr")
{
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
CP_XML_NODE(L"p:cNvPicPr")
{
}
CP_XML_NODE(L"p:nvPr")
{
CP_XML_NODE(L"a:videoFile")
{
CP_XML_ATTR(L"r:link", val.objectId);
}
}
}
if (val.fill.bitmap)
val.fill.bitmap->name_space = L"p";
oox_serialize_fill(CP_XML_STREAM(), val.fill);
CP_XML_NODE(L"p:spPr")
{
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
//_CP_OPT(std::wstring) strTextContent;
//odf::GetProperty(properties,L"text-content",strTextContent);
//pptx_serialize_text(CP_XML_STREAM(),val.additional);
//на картинке тект нельзя... - выше сменили тип на рект с заливкой
}
}
}
void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
{
@ -123,7 +172,7 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
CP_XML_ATTR(L"id", val.id);//числовое значение val.rId
CP_XML_ATTR(L"name", val.name);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
oox_serialize_action(CP_XML_STREAM(),val.action);
}
CP_XML_NODE(L"p:cNvSpPr")//non visual properies (собственно тока 1 там)
{
@ -155,8 +204,11 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
odf_reader::GetProperty(val.additional,L"no_rect",bNoRect);
if (!bNoRect)
{
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
{
if (val.cx != 0 || val.cy != 0) //layout
{
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
}
val.serialize_shape(CP_XML_STREAM());
oox_serialize_ln(CP_XML_STREAM(), val.additional);
@ -312,6 +364,10 @@ void _pptx_drawing::serialize(std::wostream & strm)
{
pptx_serialize_object(strm, *this);
}
else if (type == typeMedia)
{
pptx_serialize_media(strm, *this);
}
}

View File

@ -65,11 +65,15 @@ public:
{
pptx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
for (int i = 0; i < d.hlinks.size(); i++)
for (size_t i = 0; i < d.hlinks.size(); i++)
{
pptx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
}
}
if (!d.action.hId.empty())
{
pptx_drawing_rels_.push_back(_rel(false, d.action.hId, d.action.hRef, d.action.typeRels));
}
}
void add(/**/
bool isInternal,

View File

@ -41,7 +41,7 @@
namespace cpdoccore {
namespace oox {
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slide::name() const
{
return name_;
@ -53,7 +53,7 @@ std::wstring pptx_xml_slide::rId() const
pptx_xml_slide_ptr pptx_xml_slide::create(std::wstring const & name,int id)
{
const std::wstring rId = std::wstring(L"sId") + boost::lexical_cast<std::wstring>(id);
const std::wstring rId = std::wstring(L"sId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slide>(name,rId);
}
@ -68,15 +68,15 @@ pptx_xml_slide::~pptx_xml_slide()
}
std::wostream & pptx_xml_slide::Data()
{
return slideData_;
return strmData_;
}
std::wostream & pptx_xml_slide::Background()
{
return slideBackground_;
return strmBackground_;
}
std::wostream & pptx_xml_slide::Timing()
{
return slideTiming_;
return strmTiming_;
}
rels & pptx_xml_slide::Rels()
{
@ -100,14 +100,14 @@ void pptx_xml_slide::write_to(std::wostream & strm)
{
CP_XML_ATTR(L"name", name());
CP_XML_STREAM() << slideBackground_.str();
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideData_.str();
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_STREAM() << slideTiming_.str();
CP_XML_STREAM() << strmTiming_.str();
CP_XML_NODE(L"p:clrMapOvr")
{
CP_XML_NODE(L"a:masterClrMapping");
@ -115,7 +115,7 @@ void pptx_xml_slide::write_to(std::wostream & strm)
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideLayout::rId() const
{
return rId_;
@ -123,7 +123,7 @@ std::wstring pptx_xml_slideLayout::rId() const
pptx_xml_slideLayout_ptr pptx_xml_slideLayout::create(int id)
{
const std::wstring rId = std::wstring(L"lrId") + boost::lexical_cast<std::wstring>(id);
const std::wstring rId = std::wstring(L"lrId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slideLayout>(rId);
}
@ -137,7 +137,7 @@ pptx_xml_slideLayout::~pptx_xml_slideLayout()
}
std::wostream & pptx_xml_slideLayout::Data()
{
return slideLayoutData_;
return strmData_;
}
rels & pptx_xml_slideLayout::Rels()
{
@ -166,7 +166,7 @@ void pptx_xml_slideLayout::write_to(std::wostream & strm)
{
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideLayoutData_.str();
CP_XML_STREAM() << strmData_.str();
//в slideLayoutData_
//contentPart (Content Part) §19.3.1.14
@ -189,7 +189,7 @@ void pptx_xml_slideLayout::write_to(std::wostream & strm)
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideMaster::rId() const
{
return rId_;
@ -197,7 +197,7 @@ std::wstring pptx_xml_slideMaster::rId() const
pptx_xml_slideMaster_ptr pptx_xml_slideMaster::create(int id)
{
const std::wstring rId = std::wstring(L"smId") + boost::lexical_cast<std::wstring>(id);
const std::wstring rId = std::wstring(L"smId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slideMaster>(rId,id);
}
@ -212,15 +212,19 @@ pptx_xml_slideMaster::~pptx_xml_slideMaster()
}
std::wostream & pptx_xml_slideMaster::Data()
{
return slideMasterData_;
return strmData_;
}
std::wostream & pptx_xml_slideMaster::DataExtra()
{
return slideMasterDataExtra_;
return strmDataExtra_;
}
std::wostream & pptx_xml_slideMaster::Background()
{
return slideMasterBackground_;
return strmBackground_;
}
std::wstringstream & pptx_xml_slideMaster::Sizes()
{
return strmSizes_;
}
rels & pptx_xml_slideMaster::Rels()
{
@ -229,7 +233,7 @@ rels & pptx_xml_slideMaster::Rels()
void pptx_xml_slideMaster::add_theme(int id, const std::wstring & tId)
{
rels_.add(relationship( tId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
std::wstring(L"../theme/theme") + boost::lexical_cast<std::wstring>(id) + L".xml"));
std::wstring(L"../theme/theme") + std::to_wstring(id) + L".xml"));
}
void pptx_xml_slideMaster::add_layout(int id, const std::wstring & rId, const unsigned int & uniqId)
@ -237,7 +241,7 @@ void pptx_xml_slideMaster::add_layout(int id, const std::wstring & rId, const un
layoutsId_.push_back(std::pair<std::wstring, unsigned int>(rId, uniqId));
rels_.add(relationship( rId,L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
std::wstring(L"../slideLayouts/slideLayout") + boost::lexical_cast<std::wstring>(id) + L".xml"));
std::wstring(L"../slideLayouts/slideLayout") + std::to_wstring(id) + L".xml"));
}
void pptx_xml_slideMaster::write_to(std::wostream & strm)
@ -255,11 +259,11 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << slideMasterBackground_.str();
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideMasterData_.str();
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_NODE(L"p:clrMap")
@ -288,7 +292,7 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
}
}
}
CP_XML_STREAM() << slideMasterDataExtra_.str();
CP_XML_STREAM() << strmDataExtra_.str();
CP_XML_NODE(L"p:txStyles")
{
CP_XML_NODE(L"p:titleStyle");
@ -299,6 +303,7 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
}
}
//---------------------------------------------------------------------------------------------------------
pptx_xml_theme_ptr pptx_xml_theme::create(std::wstring const & name,int id)
{
return boost::make_shared<pptx_xml_theme>(name,id);
@ -336,6 +341,7 @@ void pptx_xml_theme::write_to(std::wostream & strm)
}
}
}
//---------------------------------------------------------------------------------------------------------
pptx_xml_authors_comments_ptr pptx_xml_authors_comments::create()
{
return boost::make_shared<pptx_xml_authors_comments>();
@ -399,6 +405,7 @@ void pptx_xml_authors_comments::write_to(std::wostream & strm)
}
}
//---------------------------------------------------------------------------------------------------------
void pptx_xml_presentation::write_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
@ -412,14 +419,18 @@ void pptx_xml_presentation::write_to(std::wostream & strm)
CP_XML_NODE(L"p:sldMasterIdLst")
{
CP_XML_STREAM() << slideMastersData_.str();
}
}
CP_XML_NODE(L"p:notesMasterIdLst")
{
CP_XML_STREAM() << slideNotesMastersData_.str();
}
CP_XML_NODE(L"p:sldIdLst")
{
CP_XML_STREAM() << slidesData_.str();
}
CP_XML_STREAM() << slidesProperties_.str();
CP_XML_STREAM() << notesSlidesSize_.str();
CP_XML_STREAM() << slidesNotesProperties_.str();
CP_XML_NODE(L"p:defaultTextStyle")//??
{
@ -428,5 +439,155 @@ void pptx_xml_presentation::write_to(std::wostream & strm)
}
}
}
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideNotes::rId() const
{
return rId_;
}
pptx_xml_slideNotes_ptr pptx_xml_slideNotes::create(int id)
{
const std::wstring rId = std::wstring(L"nId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slideNotes>(rId);
}
pptx_xml_slideNotes::pptx_xml_slideNotes(std::wstring const & id)
{
rId_ = id;
}
pptx_xml_slideNotes::~pptx_xml_slideNotes()
{
}
std::wostream & pptx_xml_slideNotes::Data()
{
return strmData_;
}
std::wostream & pptx_xml_slideNotes::Background()
{
return strmBackground_;
}
rels & pptx_xml_slideNotes::Rels()
{
return rels_;
}
void pptx_xml_slideNotes::write_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:notes")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"xmlns:p15", L"http://schemas.microsoft.com/office/powerpoint/2012/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_NODE(L"p:clrMapOvr")
{
CP_XML_NODE(L"a:masterClrMapping");
}
}
}
}
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideNotesMaster::rId() const
{
return rId_;
}
pptx_xml_slideNotesMaster_ptr pptx_xml_slideNotesMaster::create()
{
const std::wstring rId = std::wstring(L"nmId1");
return boost::make_shared<pptx_xml_slideNotesMaster>(rId, 1);
}
pptx_xml_slideNotesMaster::pptx_xml_slideNotesMaster(std::wstring const & rId, int id)
{
rId_ = rId;
id_ = id;
}
pptx_xml_slideNotesMaster::~pptx_xml_slideNotesMaster()
{
}
std::wostream & pptx_xml_slideNotesMaster::Data()
{
return strmData_;
}
std::wostream & pptx_xml_slideNotesMaster::Background()
{
return strmBackground_;
}
std::wostream & pptx_xml_slideNotesMaster::Sizes()
{
return strmSizes_;
}
rels & pptx_xml_slideNotesMaster::Rels()
{
return rels_;
}
void pptx_xml_slideNotesMaster::add_theme(int id, const std::wstring & tId)
{
rels_.add(relationship( tId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
std::wstring(L"../theme/theme") + std::to_wstring(id) + L".xml"));
}
void pptx_xml_slideNotesMaster::write_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:notesMaster")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"xmlns:p15", L"http://schemas.microsoft.com/office/powerpoint/2012/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_NODE(L"p:clrMap")
{
CP_XML_ATTR(L"folHlink",L"folHlink");
CP_XML_ATTR(L"hlink",L"hlink");
CP_XML_ATTR(L"accent6",L"accent6");
CP_XML_ATTR(L"accent5",L"accent5");
CP_XML_ATTR(L"accent4",L"accent4");
CP_XML_ATTR(L"accent3",L"accent5");
CP_XML_ATTR(L"accent2",L"accent2");
CP_XML_ATTR(L"accent1",L"accent1");
CP_XML_ATTR(L"tx2",L"dk2");
CP_XML_ATTR(L"tx1",L"dk1");
CP_XML_ATTR(L"bg2",L"lt2");
CP_XML_ATTR(L"bg1",L"lt1");
}
CP_XML_NODE(L"p:notesStyle")
{
}
}
}
}
//---------------------------------------------------------------------------------------------------------
}
}

View File

@ -49,7 +49,7 @@ class pptx_xml_slide: noncopyable
public:
pptx_xml_slide(std::wstring const & name,std::wstring const & id);
~pptx_xml_slide();
public:
std::wstring name() const;
std::wstring rId() const;
@ -65,41 +65,68 @@ public:
private:
std::wstring name_;
std::wstringstream slideData_;
std::wstringstream slideBackground_;
std::wstringstream slideTiming_;
std::wstringstream strmData_;
std::wstringstream strmBackground_;
std::wstringstream strmTiming_;
std::wstring rId_;
rels rels_;
};
////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------
class pptx_xml_slideNotes;
typedef _CP_PTR(pptx_xml_slideNotes) pptx_xml_slideNotes_ptr;
class pptx_xml_slideNotes: noncopyable
{
public:
pptx_xml_slideNotes(std::wstring const & id);
~pptx_xml_slideNotes();
std::wstring rId() const;
std::wostream & Data();
std::wostream & Background();
rels & Rels();
void write_to(std::wostream & strm);
static pptx_xml_slideNotes_ptr create(int id);
private:
std::wstringstream strmData_;
std::wstringstream strmBackground_;
std::wstring rId_;
rels rels_;
};
//------------------------------------------------------------------------------------
class pptx_xml_presentation: noncopyable
{
public:
pptx_xml_presentation(){}
~pptx_xml_presentation(){}
std::wstringstream & slidesData(){return slidesData_;}
std::wstringstream & slideMastersData(){return slideMastersData_;}
std::wstringstream & notesSlidesData(){return notesSlidesData_;}
std::wstringstream & slidesData() {return slidesData_;}
std::wstringstream & slideMastersData() {return slideMastersData_;}
std::wstringstream & slideNotesMastersData() {return slideNotesMastersData_;}
std::wstringstream & slidesProperties(){return slidesProperties_;}
std::wstringstream & notesSlidesSize(){return notesSlidesSize_;}
std::wstringstream & slidesProperties() {return slidesProperties_;}
std::wstringstream & slidesNotesProperties() {return slidesNotesProperties_;}
void write_to(std::wostream & strm);
private:
std::wstringstream slidesProperties_;
std::wstringstream notesSlidesSize_;
std::wstringstream slidesNotesProperties_;
std::wstringstream slidesData_;
std::wstringstream slideMastersData_;
std::wstringstream notesSlidesData_;
std::wstringstream handoutMasterData_;
std::wstringstream slideNotesMastersData_;
std::wstringstream slideHandoutMasterData_;
};
//////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------
class pptx_xml_slideLayout;
typedef _CP_PTR(pptx_xml_slideLayout) pptx_xml_slideLayout_ptr;
@ -121,12 +148,12 @@ public:
static pptx_xml_slideLayout_ptr create(int id);
private:
std::wstringstream slideLayoutData_;
std::wstringstream strmData_;
std::wstring rId_;
rels rels_;
};
///////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------
class pptx_xml_slideMaster;
typedef _CP_PTR(pptx_xml_slideMaster) pptx_xml_slideMaster_ptr;
@ -135,12 +162,13 @@ class pptx_xml_slideMaster: noncopyable
public:
pptx_xml_slideMaster(std::wstring const & rId, int id);
~pptx_xml_slideMaster();
public:
std::wstring rId() const;
std::wostream & Data();
std::wostream & DataExtra();
std::wostream & Background();
std::wostream & Data();
std::wostream & DataExtra();
std::wostream & Background();
std::wstringstream & Sizes();
rels & Rels();
void add_layout(int id, const std::wstring & rId, const unsigned int & uniqId);
@ -151,9 +179,10 @@ public:
static pptx_xml_slideMaster_ptr create(int id);
private:
std::wstringstream slideMasterData_;
std::wstringstream slideMasterDataExtra_;
std::wstringstream slideMasterBackground_;
std::wstringstream strmData_;
std::wstringstream strmDataExtra_;
std::wstringstream strmBackground_;
std::wstringstream strmSizes_;
std::vector<std::pair<std::wstring, unsigned int>> layoutsId_;
std::wstring rId_;
@ -163,7 +192,42 @@ private:
rels rels_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------
class pptx_xml_slideNotesMaster;
typedef _CP_PTR(pptx_xml_slideNotesMaster) pptx_xml_slideNotesMaster_ptr;
class pptx_xml_slideNotesMaster: noncopyable
{
public:
pptx_xml_slideNotesMaster(std::wstring const & rId, int id);
~pptx_xml_slideNotesMaster();
std::wstring rId() const;
std::wostream & Data();
std::wostream & Background();
std::wostream & Sizes();
rels & Rels();
void add_theme(int id, const std::wstring & tId);
void write_to(std::wostream & strm);
static pptx_xml_slideNotesMaster_ptr create();
private:
std::wstringstream strmData_;
std::wstringstream strmBackground_;
std::wstringstream strmSizes_;
std::wstring rId_;
int id_;
std::wstring themeId_;
rels rels_;
};
//------------------------------------------------------------------------------------
class pptx_xml_theme;
typedef _CP_PTR(pptx_xml_theme) pptx_xml_theme_ptr;
@ -192,7 +256,7 @@ private:
std::wstring name_;
int id_;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------
class pptx_xml_authors_comments;
typedef _CP_PTR(pptx_xml_authors_comments) pptx_xml_authors_comments_ptr;

View File

@ -100,15 +100,16 @@ void slide_content::add_rels(rels & _r)
{
std::vector<relationship> & r = _r.relationships();
for (int i = 0; i < r.size(); i++)
for (size_t i = 0; i < r.size(); i++)
{
rels_->get_rels().add(r[i]);
}
}
////////////
//---------------------------------------------------------------------------
slides_files::slides_files()
{}
{
rels_ = NULL;
}
void slides_files::add_slide(slide_content_ptr slide)
{
@ -127,13 +128,13 @@ void slides_files::write(const std::wstring & RootPath)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slide") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml";
const std::wstring fileName = std::wstring(L"slide") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slides/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"sId") + boost::lexical_cast<std::wstring>( i + 1);
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/slide";
const std::wstring fileRef = std::wstring(L"slides/") + fileName;
rels_->add(id, kWSRel, fileRef);
@ -149,7 +150,42 @@ void slides_files::write(const std::wstring & RootPath)
}
}
////////////////////////////////////////////
//---------------------------------------------------------------------------
void notes_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"notesSlides" ;
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.presentationml.notesSlide+xml";
for (int i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"notesSlide") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/notesSlides/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"nId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide";
const std::wstring fileRef = std::wstring(L"notesSlides/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(slides_[i]->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, slides_[i]->str()).write(path);
}
}
//---------------------------------------------------------------------------
slideMasters_files::slideMasters_files()
{}
@ -170,12 +206,12 @@ void slideMasters_files::write(const std::wstring & RootPath)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slideMaster") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml";
const std::wstring fileName = std::wstring(L"slideMaster") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slideMasters/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"smId") + boost::lexical_cast<std::wstring>( i + 1);
const std::wstring id = std::wstring(L"smId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
const std::wstring fileRef = std::wstring(L"slideMasters/") + fileName;
rels_->add(id, kWSRel, fileRef);
@ -191,7 +227,41 @@ void slideMasters_files::write(const std::wstring & RootPath)
}
}
////////////////////////////////////////////
//---------------------------------------------------------------------------
void notesMaster_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"notesMasters" ;
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.presentationml.notesMaster+xml";
for (int i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"notesMaster") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/notesMasters/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"nmId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster";
const std::wstring fileRef = std::wstring(L"notesMasters/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(slides_[i]->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, slides_[i]->str()).write(path);
}
}
slideLayouts_files::slideLayouts_files()
{}
@ -209,7 +279,7 @@ void slideLayouts_files::write(const std::wstring & RootPath)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slideLayout") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml";
const std::wstring fileName = std::wstring(L"slideLayout") + std::to_wstring( i + 1 ) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
@ -225,7 +295,7 @@ void slideLayouts_files::write(const std::wstring & RootPath)
}
}
///////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------
authors_comments_element::authors_comments_element(pptx_xml_authors_comments_ptr & authors_comments) : authors_comments_(authors_comments)
{
}
@ -261,7 +331,7 @@ void ppt_charts_files::write(const std::wstring & RootPath)
{
if (!charts_[i]) continue;
const std::wstring fileName = std::wstring(L"chart") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml";
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring( i + 1 ) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
@ -291,7 +361,7 @@ void ppt_themes_files::write(const std::wstring & RootPath)
{
if (!themes_[i]) continue;
const std::wstring fileName = std::wstring(L"theme") + boost::lexical_cast<std::wstring>( i + 1) + L".xml";
const std::wstring fileName = std::wstring(L"theme") + std::to_wstring( i + 1) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
@ -345,6 +415,12 @@ void ppt_files::write(const std::wstring & RootPath)
slideMasters_files_.set_main_document( this->get_main_document() );
slideMasters_files_.write(path);
notes_files_.set_main_document( this->get_main_document() );
notes_files_.write(path);
notesMaster_files_.set_rels(&rels_files_);
notesMaster_files_.set_main_document( this->get_main_document() );
notesMaster_files_.write(path);
//rels_files_.add( relationship( L"hId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"ppt/presentation.xml" ) );
@ -412,6 +488,10 @@ void ppt_files::add_slide(slide_content_ptr slide)
{
slides_files_.add_slide(slide);
}
void ppt_files::add_notes(slide_content_ptr slide)
{
notes_files_.add_slide(slide);
}
void ppt_files::add_slideLayout(slide_content_ptr slide)
{
slideLayouts_files_.add_slide(slide);
@ -420,7 +500,10 @@ void ppt_files::add_slideMaster(slide_content_ptr slide)
{
slideMasters_files_.add_slide(slide);
}
void ppt_files::add_notesMaster(slide_content_ptr slide)
{
notesMaster_files_.add_slide(slide);
}
void ppt_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)

View File

@ -41,8 +41,10 @@ namespace cpdoccore {
namespace oox {
class pptx_xml_presentation;
class pptx_xml_theme;
typedef _CP_PTR(pptx_xml_theme) pptx_xml_theme_ptr;
class pptx_xml_authors_comments;
typedef _CP_PTR(pptx_xml_authors_comments) pptx_xml_authors_comments_ptr;
@ -55,7 +57,7 @@ public:
};
///////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
class slide_content;
typedef _CP_PTR(slide_content) slide_content_ptr;
@ -72,11 +74,10 @@ public:
static _CP_PTR(slide_content) create();
private:
std::wstringstream content_;
rels_file_ptr rels_;
std::wstringstream content_;
rels_file_ptr rels_;
};
// slides_files
//------------------------------------------------------------------------------
class slides_files : public element
{
public:
@ -92,12 +93,18 @@ public:
virtual void write(const std::wstring & RootPath);
void set_slide_ref(const std::wstring & ref_file_path,const std::wstring & ref_file_name);
public:
std::vector<slide_content_ptr> slides_;
rels_files * rels_;
};
// slideLayouts_files
//------------------------------------------------------------------------------
class notes_files : public slides_files
{
public:
virtual void write(const std::wstring & RootPath);
};
//------------------------------------------------------------------------------
class slideLayouts_files : public element
{
public:
@ -107,12 +114,9 @@ public:
virtual void write(const std::wstring & RootPath);
public:
std::vector<slide_content_ptr> slides_;
};
///////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
class authors_comments_element : public element
{
public:
@ -123,9 +127,7 @@ private:
pptx_xml_authors_comments_ptr & authors_comments_;
};
/////////////////////////////////////////////////////////////////////////////////////////
// slideMasters_files
//------------------------------------------------------------------------------
class slideMasters_files : public element
{
public:
@ -140,16 +142,19 @@ public:
virtual void write(const std::wstring & RootPath);
public:
std::vector<slide_content_ptr> slides_;
rels_files * rels_;
};
///////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
class notesMaster_files : public slideMasters_files
{
public:
virtual void write(const std::wstring & RootPath);
};
//------------------------------------------------------------------------------
class ppt_comments_files;
typedef _CP_PTR(ppt_comments_files) ppt_comments_files_ptr;
// ppt_comments
class ppt_comments_files: public element
{
public:
@ -165,9 +170,7 @@ private:
const std::vector<pptx_comment_elm> & comments_;
};
//////////////////////////////////////////////////////////////////////////////
// ppt_charts_files
//------------------------------------------------------------------------------
class ppt_charts_files : public element
{
public:
@ -179,8 +182,8 @@ public:
std::vector<chart_content_ptr> charts_;
};
//////////////////////////////////////////////////////////////////////////////
// ppt_theme_files
//------------------------------------------------------------------------------
class ppt_themes_files : public element
{
public:
@ -192,13 +195,12 @@ public:
std::vector<pptx_xml_theme_ptr> themes_;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
class ppt_files : public element
{
public:
ppt_files();
public:
virtual void write(const std::wstring & RootPath);
void set_presentation(pptx_xml_presentation & presentation);
@ -206,9 +208,11 @@ public:
void set_styles(element_ptr Element);
void set_comments(element_ptr Element);
void add_slide(slide_content_ptr sheet);
void add_slide (slide_content_ptr sheet);
void add_slideLayout(slide_content_ptr sheet);
void add_slideMaster(slide_content_ptr sheet);
void add_notes (slide_content_ptr sheet);
void add_notesMaster(slide_content_ptr sheet);
void set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts);
void add_charts(chart_content_ptr chart);
@ -217,25 +221,21 @@ public:
void set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments);
private:
rels_files rels_files_;
rels_files rels_files_;
slides_files slides_files_;
slideLayouts_files slideLayouts_files_;
slideMasters_files slideMasters_files_;
slides_files slides_files_;
slideLayouts_files slideLayouts_files_;
slideMasters_files slideMasters_files_;
notes_files notes_files_;
notesMaster_files notesMaster_files_;
//slides_files handoutMasters_files_;
ppt_themes_files themes_files_;
ppt_charts_files charts_files_;
//slides_files notesSlides_files_;
//slides_files notesMasters_files_;
//slides_files handoutMasters_files_;
element_ptr authors_comments_;
element_ptr authors_comments_;
element_ptr presentation_;
element_ptr tableStyles_;
element_ptr comments_;
element_ptr media_;
element_ptr embeddings_;
@ -247,7 +247,6 @@ class pptx_document : public document
public:
pptx_document();
public:
virtual void write(const std::wstring & RootPath);
virtual content_types_file & get_content_types_file() { return content_type_file_; }

View File

@ -53,7 +53,6 @@ typedef _CP_PTR(pptx_drawings) pptx_drawings_ptr;
class pptx_slide_context::Impl
{
public:
struct _transition
{
bool Enabled;
@ -66,7 +65,7 @@ public:
bool onClick;
};
Impl(const std::wstring & odfPacket) : mediaitems_(odfPacket),odfPacket_(odfPacket)
Impl(const std::wstring & odfPacket) : mediaitems_(odfPacket), odfPacket_(odfPacket)
{
clear();
}
@ -75,24 +74,17 @@ public:
std::vector<drawing_object_description> objects_;
_CP_OPT(_oox_fill) background_fill_;
_transition transition_;
bool use_image_replacement_;
bool header, footer, date_time, slideNum;
void add_drawing(_pptx_drawing const & d,
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
RelsType type)
void add_drawing(_pptx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
pptx_drawings_->add(d, isInternal, rid, ref, type);
}
void add_additional_rels(
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
RelsType type)
void add_additional_rels (bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
pptx_drawings_->add(isInternal, rid, ref, type);
}
@ -107,16 +99,16 @@ public:
{
objects_.clear();
background_fill_ = boost::none;
background_fill_ = boost::none;
header=false;
footer=false;
date_time=false;
slideNum=false;
header = false;
footer = false;
date_time = false;
slideNum = false;
rId_ = 1;
pptx_drawings_ = pptx_drawings::create();
pptx_drawings_ = pptx_drawings::create();
transition_.Enabled = false;
transition_.Speed = boost::none;
@ -127,7 +119,6 @@ public:
{
return rId_++;;
}
pptx_drawings_ptr get_drawings()
{
return pptx_drawings_;
@ -137,7 +128,7 @@ public:
void process_drawings();
private:
void process_common_properties(drawing_object_description& obj,_pptx_drawing & drawing);
void process_common_properties(drawing_object_description& obj, _pptx_drawing & drawing);
void process_shape (drawing_object_description& obj, _pptx_drawing & drawing);
void process_image (drawing_object_description& obj, _pptx_drawing & drawing);
@ -145,14 +136,15 @@ private:
void process_table (drawing_object_description& obj, _pptx_drawing & drawing);
void process_object (drawing_object_description& obj, _pptx_drawing & drawing);
size_t rId_;
mediaitems mediaitems_;
pptx_drawings_ptr pptx_drawings_;
size_t rId_;
mediaitems mediaitems_;
pptx_drawings_ptr pptx_drawings_;
pptx_drawings_ptr pptx_notes_drawings_;
};
void pptx_slide_context::Impl::process_drawings()
{
for (int i = 0; i < objects_.size(); i++)
for (size_t i = 0; i < objects_.size(); i++)
{
_pptx_drawing drawing =_pptx_drawing();
@ -168,6 +160,7 @@ void pptx_slide_context::Impl::process_drawings()
case typeChart: process_chart(objects_[i], drawing); break;
case typeShape: process_shape(objects_[i], drawing); break;
case typeTable: process_table(objects_[i], drawing); break;
case typeMedia:
case typeMsObject:
case typeOleObject: process_object(objects_[i], drawing); break;
}
@ -175,17 +168,19 @@ void pptx_slide_context::Impl::process_drawings()
}
pptx_slide_context::pptx_slide_context(pptx_conversion_context & Context)
: impl_(new pptx_slide_context::Impl(Context.root()->get_folder()))
: impl_(new pptx_slide_context::Impl(Context.root()->get_folder()))
{
hlinks_size_ = 0;
hlinks_size_ = 0;
}
void pptx_slide_context::start_slide()
{
impl_->clear(); // objects
hlinks_size_ = 0;
hlinks_size_ = 0;
default_set(); //for current object
}
/////////////////////////////////////////////////////////////////////////////////////////////////
void pptx_slide_context::start_slide_animation()
{
@ -202,10 +197,10 @@ void pptx_slide_context::start_slide_animation()
void pptx_slide_context::set_transitionFilter(std::wstring & type,_CP_OPT(std::wstring) & dir,_CP_OPT(std::wstring) & dop,_CP_OPT(int) & time)
{
impl_->transition_.Type = type;
impl_->transition_.Time = time; // не путать длительность перехода с длительностью эффекта перехода (в oo его нет)
impl_->transition_.Dir = dir;
impl_->transition_.Param = dop;
impl_->transition_.Type = type;
impl_->transition_.Time = time; // не путать длительность перехода с длительностью эффекта перехода (в oo его нет)
impl_->transition_.Dir = dir;
impl_->transition_.Param = dop;
}
void pptx_slide_context::set_transitionAction(bool val)
@ -215,8 +210,8 @@ void pptx_slide_context::set_transitionAction(bool val)
void pptx_slide_context::set_transitionSpeed(std::wstring val)
{
if (val == L"medium")impl_->transition_.Speed=L"med";
else impl_->transition_.Speed= val;//fast / slow
if (val == L"medium") impl_->transition_.Speed = L"med";
else impl_->transition_.Speed = val;//fast / slow
}
@ -227,12 +222,15 @@ void pptx_slide_context::default_set()
impl_->object_description_.name_ = L"";
impl_->object_description_.descriptor_ = L"";
impl_->object_description_.anchor_ = L"";
impl_->object_description_.additional_.clear();
impl_->object_description_.clipping_string_= L"";
impl_->object_description_.svg_rect_ = boost::none;
impl_->object_description_.hlinks_.clear();
impl_->object_description_.action_.clear();
impl_->object_description_.additional_.clear();
impl_->object_description_.fill_.clear();
@ -247,10 +245,10 @@ void pptx_slide_context::set_use_image_replacement()
void pptx_slide_context::set_placeHolder_type(std::wstring typeHolder)
{
if (typeHolder == L"ftr") impl_->footer= true;
if (typeHolder == L"hdr") impl_->header= true;
if (typeHolder == L"dt") impl_->date_time= true;
if (typeHolder == L"sldNum")impl_->slideNum= true;
if (typeHolder == L"ftr") impl_->footer = true;
if (typeHolder == L"hdr") impl_->header = true;
if (typeHolder == L"dt") impl_->date_time = true;
if (typeHolder == L"sldNum")impl_->slideNum = true;
impl_->object_description_.additional_.push_back(odf_reader::_property(L"PlaceHolderType",typeHolder));
}
@ -328,15 +326,15 @@ void pptx_slide_context::set_fill(_oox_fill & fill)
impl_->object_description_.fill_= fill;
}
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & href,bool object)
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & href)
{
++hlinks_size_;
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
std::wstring hId = L"hId" + std::to_wstring(hlinks_size_);
std::wstring href_correct = xml::utils::replace_text_to_xml(href);
XmlUtils::replace_all( href_correct, L" .", L".");//1 (130).odt
_hlink_desc desc={hId, href_correct, object};
_hlink_desc desc = {hId, href_correct};
impl_->object_description_.hlinks_.push_back(desc);
return hId;
@ -352,14 +350,12 @@ void pptx_slide_context::add_background(_oox_fill & fill)
fill.bitmap->rId = get_mediaitems().add_or_find(fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_rels(isMediaInternal, fill.bitmap->rId, ref, typeImage);
}
impl_->background_fill_ = fill;
}
void pptx_slide_context::set_name(std::wstring const & name)
{
impl_->object_description_.name_ = name;
}
void pptx_slide_context::start_shape(int type)
@ -367,6 +363,62 @@ void pptx_slide_context::start_shape(int type)
impl_->object_description_.type_ = typeShape;
impl_->object_description_.shape_type_ = type; //2,3...
}
void pptx_slide_context::start_action(std::wstring action)
{
impl_->object_description_.action_.enabled = true;
if (action == L"sound")
{
impl_->object_description_.action_.typeRels = typeAudio;
impl_->object_description_.action_.highlightClick = true;
}
else if (action == L"next-page")
{
impl_->object_description_.action_.action = L"ppaction://hlinkshowjump?jump=nextslide";
impl_->object_description_.action_.highlightClick = true;
}
else if (action == L"previous-page")
{
impl_->object_description_.action_.action = L"ppaction://hlinkshowjump?jump=previousslide";
impl_->object_description_.action_.highlightClick = true;
}
else if (action == L"first-page")
{
impl_->object_description_.action_.action = L"ppaction://hlinkshowjump?jump=firstslide";
impl_->object_description_.action_.highlightClick = true;
}
else if (action == L"last-page")
{
impl_->object_description_.action_.action = L"ppaction://hlinkshowjump?jump=lastslide";
impl_->object_description_.action_.highlightClick = true;
}
//ppaction://hlinkshowjump?jump=endshow
else if (action == L"execute")
{
impl_->object_description_.action_.action = L"ppaction://program";
impl_->object_description_.action_.typeRels = typeHyperlink;
impl_->object_description_.action_.highlightClick = true;
}
}
void pptx_slide_context::set_link(std::wstring link, RelsType typeRels)
{
++hlinks_size_;
std::wstring hId = L"hId" + std::to_wstring(hlinks_size_);
link = xml::utils::replace_text_to_xml(link);
if (typeRels == typeHyperlink)
XmlUtils::replace_all( link, L" .", L"."); //1 (130).odt
impl_->object_description_.action_.highlightClick = true;
impl_->object_description_.action_.hId = hId;
impl_->object_description_.action_.hRef = link;
impl_->object_description_.action_.typeRels = typeRels;
}
void pptx_slide_context::end_action()
{
}
void pptx_slide_context::start_table()
{
@ -390,6 +442,20 @@ void pptx_slide_context::set_ole_object(const std::wstring & path, const std::ws
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
}
void pptx_slide_context::set_media(const std::wstring & path)
{
if (path.empty()) return;
impl_->object_description_.type_ = typeMedia;
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.action_.enabled = true;
impl_->object_description_.action_.action = L"ppaction://media";
}
void pptx_slide_context::set_media_param(std::wstring name, std::wstring value)
{
}
void pptx_slide_context::set_image(const std::wstring & path)
{
@ -433,8 +499,6 @@ void pptx_slide_context::end_shape()
void pptx_slide_context::end_table()
{
impl_->objects_.push_back(impl_->object_description_);
default_set();
}
bool pptx_slide_context::empty() const
@ -447,7 +511,7 @@ void pptx_slide_context::process_drawings()
return impl_->process_drawings();
}
void pptx_slide_context::Impl::process_image(drawing_object_description& pic, _pptx_drawing & drawing)
void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _pptx_drawing & drawing)
{
int pos_replaicement = 0, pos_preview = 0;
@ -455,22 +519,22 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& pic, _p
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent;
GetProperty(pic.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"text-content", sTextContent);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = typeShape;
drawing.sub_type = 2;//rect
}
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect, NULL);
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + obj.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL);
drawing.fill.bitmap->bStretch = true;
///////////////////////////////////////////////////////////////////////////////////////////////////
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(pic.xlink_href_, typeImage, isMediaInternal, ref);
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
if (drawing.type == typeShape)
{
@ -478,11 +542,13 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& pic, _p
isMediaInternal = true;
std::wstring rId = get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
}else if (!drawing.fill.bitmap->rId.empty())
}
else if (!drawing.fill.bitmap->rId.empty())
{
add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);//объект
add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId, ref, drawing.type);//объект
}
}
void pptx_slide_context::Impl::process_chart(drawing_object_description & obj, _pptx_drawing & drawing)
@ -490,8 +556,9 @@ void pptx_slide_context::Impl::process_chart(drawing_object_description & obj, _
std::wstring ref;
bool isMediaInternal = true;
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
}
void pptx_slide_context::Impl::process_table(drawing_object_description & obj, _pptx_drawing & drawing)
@ -501,6 +568,7 @@ void pptx_slide_context::Impl::process_table(drawing_object_description & obj, _
std::wstring rId = get_mediaitems().add_or_find(L"", obj.type_, isMediaInternal, ref);
add_drawing(drawing, isMediaInternal, rId, ref, drawing.type);
}
void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _pptx_drawing & drawing)
@ -513,6 +581,7 @@ void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
@ -534,7 +603,6 @@ void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _
add_drawing(drawing, isMediaInternal, rId, ref, typeShape);
}
void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _pptx_drawing & drawing)
{
std::wstring ref;
@ -543,11 +611,12 @@ void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
}
@ -558,26 +627,24 @@ void pptx_slide_context::Impl::process_common_properties(drawing_object_descript
{
//todooo непонятки с отрицательными значениями
int val = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >= 0) drawing.x = val;
if ( val >= 0) drawing.x = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >= 0) drawing.y = val;
if ( val >= 0 ) drawing.y = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_->cx, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >=0) drawing.cx = val;
if ( val >=0 ) drawing.cx = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_->cy, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if (val >=0) drawing.cy = val;
if ( val >=0 ) drawing.cy = val;
}
drawing.additional = pic.additional_;
drawing.hlinks = pic.hlinks_;
drawing.fill = pic.fill_;
drawing.additional = pic.additional_;
drawing.hlinks = pic.hlinks_;
drawing.action = pic.action_;
drawing.fill = pic.fill_;
}
void pptx_slide_context::dump_rels(rels & Rels)
{
impl_->get_drawings()->dump_rels(Rels);
@ -592,6 +659,7 @@ void pptx_slide_context::add_rels( bool isInternal, std::wstring const & rid, st
{
impl_->add_additional_rels(isInternal, rid, ref, type);
}
void pptx_slide_context::set_footer()
{
impl_->footer = true;
@ -610,7 +678,7 @@ void pptx_slide_context::set_date_time()
}
void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
{
if (!always && ( (!impl_->background_fill_) || (impl_->background_fill_->type==0))) return;
if (!always && ( (!impl_->background_fill_) || (impl_->background_fill_->type == 0))) return;
CP_XML_WRITER(strm)
{
@ -620,7 +688,7 @@ void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
{
if (impl_->background_fill_)
{
oox_serialize_fill(CP_XML_STREAM(),impl_->background_fill_.get());
oox_serialize_fill(CP_XML_STREAM(), impl_->background_fill_.get());
}
else
{
@ -691,7 +759,6 @@ void pptx_slide_context::serialize_HeaderFooter(std::wostream & strm)
}
}
}
void pptx_slide_context::serialize_objects(std::wostream & strm)
{
int next_id = impl_->next_rId();
@ -703,8 +770,8 @@ void pptx_slide_context::serialize_objects(std::wostream & strm)
{
CP_XML_NODE(L"p:cNvPr")
{
CP_XML_ATTR(L"name",L"noGroup");
CP_XML_ATTR(L"id",next_id);
CP_XML_ATTR(L"name", L"noGroup");
CP_XML_ATTR(L"id", next_id);
}
CP_XML_NODE(L"p:cNvGrpSpPr");
CP_XML_NODE(L"p:nvPr");

View File

@ -75,7 +75,7 @@ public:
void set_placeHolder_type (std::wstring typeHolder);
void set_placeHolder_idx (int idx);
std::wstring add_hyperlink(std::wstring const & ref, bool object);
std::wstring add_hyperlink(std::wstring const & ref);
void start_frame();
void set_image (const std::wstring & path);
@ -83,22 +83,31 @@ public:
void set_ms_object (const std::wstring & path, const std::wstring & progId);
void set_ole_object (const std::wstring & path, const std::wstring & progId);
void set_text_box ();
void set_media (const std::wstring & path);
void set_media_param(std::wstring name, std::wstring value);
void end_frame();
void start_action (std::wstring action);
void set_link (std::wstring link, RelsType typeRels = typeHyperlink);
void end_action ();
void start_table();
void end_table();
void start_shape(int type);
void end_shape();
void end_shape ();
void set_use_image_replacement();
bool empty() const;
//////////////////////////////////////////////////////////////////////////////////////////////
void serialize_objects(std::wostream & strm);
void serialize_HeaderFooter(std::wostream & strm);
void serialize_background(std::wostream & strm, bool always=false);
void serialize_animations(std::wostream & strm);
void serialize_HeaderFooter (std::wostream & strm);
void serialize_animations (std::wostream & strm);
void serialize_objects (std::wostream & strm);
void serialize_background (std::wostream & strm, bool always = false);
void dump_rels(rels & Rels);
@ -106,7 +115,7 @@ public:
mediaitems & get_mediaitems();
void add_background(_oox_fill & fill);
void add_background (_oox_fill & fill);
void add_rels( bool isInternal,
std::wstring const & rid,

View File

@ -376,7 +376,7 @@ void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::styl
if (fill.bitmap)
{
bool isMediaInternal = false;
bool isMediaInternal = true;
std::wstring ref;
fill.bitmap->rId = Context.get_slide_context().get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::typeImage, isMediaInternal, ref);
Context.get_slide_context().add_rels(isMediaInternal, fill.bitmap->rId, ref, oox::typeImage);

View File

@ -72,8 +72,8 @@ public:
void start_base_style(const std::wstring baseStyleName, const odf_types::style_family::type baseStyleType);
void end_base_style();
void ApplyTextProperties (std::wstring style,odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void ApplyParagraphProperties (std::wstring style,odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type);
void ApplyTextProperties (std::wstring style, std::wstring para_style, odf_reader::text_format_properties_content & propertiesOut);
void ApplyParagraphProperties (std::wstring para_style, odf_reader::paragraph_format_properties & propertiesOut);
void ApplyListProperties (odf_reader::paragraph_format_properties & propertiesOut, int Level);
void set_local_styles_container(odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
@ -239,32 +239,37 @@ void pptx_text_context::Impl::end_hyperlink(std::wstring hId)
dump_run();
hyperlink_hId = L"";
}
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name,odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type)
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name, std::wstring para_style_name, odf_reader::text_format_properties_content & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* style = NULL;
odf_reader::style_instance* baseStyle = NULL;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* para_style = NULL;
odf_reader::style_instance* text_style = NULL;
odf_reader::style_instance* baseStyle = NULL;
if (local_styles_ptr_)
{
style = local_styles_ptr_->style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
baseStyle = local_styles_ptr_->style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
para_style = local_styles_ptr_->style_by_name (para_style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
text_style = local_styles_ptr_->style_by_name (style_name, odf_types::style_family::Text, false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type (odf_types::style_family::Text);
baseStyle = local_styles_ptr_->style_by_name (base_style_name_, base_style_family_, false/*process_headers_footers_*/);
}
else
{
style = odf_context_.styleContainer().style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
baseStyle = odf_context_.styleContainer().style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
para_style = odf_context_.styleContainer().style_by_name (para_style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
text_style = odf_context_.styleContainer().style_by_name (style_name, odf_types::style_family::Text, false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type (odf_types::style_family::Text);
baseStyle = odf_context_.styleContainer().style_by_name (base_style_name_, base_style_family_, false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (style) instances.push_back(style);
if (para_style) instances.push_back(para_style);
if (text_style) instances.push_back(text_style);
if (style)get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
if (text_style) get_styles_context().start_process_style(text_style);
else if (para_style) get_styles_context().start_process_style(para_style);
else get_styles_context().start_process_style(baseStyle);
propertiesOut.apply_from(calc_text_properties_content(instances));
}
@ -323,33 +328,33 @@ void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_p
}
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style_name,odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type)
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style_name, odf_reader::paragraph_format_properties & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* style = NULL;
odf_reader::style_instance * defaultStyle = NULL;
odf_reader::style_instance * baseStyle = NULL;
odf_reader::style_instance* style = NULL;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* baseStyle = NULL;
if (local_styles_ptr_)
{
style = local_styles_ptr_->style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
baseStyle = local_styles_ptr_->style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
style = local_styles_ptr_->style_by_name (style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type (odf_types::style_family::Paragraph);
baseStyle = local_styles_ptr_->style_by_name (base_style_name_, base_style_family_, false/*process_headers_footers_*/);
}
else
{
style = odf_context_.styleContainer().style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
baseStyle= odf_context_.styleContainer().style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
style = odf_context_.styleContainer().style_by_name (style_name, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type (odf_types::style_family::Paragraph);
baseStyle = odf_context_.styleContainer().style_by_name (base_style_name_, base_style_family_,false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (style) instances.push_back(style);
if (style)get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
if (style) get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
@ -360,9 +365,9 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
int level = list_style_stack_.size()-1;
odf_reader::paragraph_format_properties paragraph_properties_;
odf_reader::paragraph_format_properties paragraph_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_,odf_types::style_family::Paragraph);
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_);
ApplyListProperties (paragraph_properties_, level);//выравнивания листа накатим на свойства параграфа
paragraph_properties_.pptx_convert(pptx_context_);
@ -403,16 +408,9 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
if (paragraph_style_name_.empty() && span_style_name_.empty() && !(!hyperlink_hId.empty()) && base_style_name_.empty())
return;
odf_reader::text_format_properties_content text_properties_paragraph_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf_types::style_family::Paragraph);
odf_reader::text_format_properties_content text_properties_span_;
ApplyTextProperties(span_style_name_, text_properties_span_,odf_types::style_family::Text);
odf_reader::text_format_properties_content text_properties_;
text_properties_.apply_from(text_properties_paragraph_);
text_properties_.apply_from(text_properties_span_);
ApplyTextProperties(span_style_name_, paragraph_style_name_, text_properties_);
get_styles_context().start();
@ -633,7 +631,7 @@ void pptx_text_context::Impl::start_list_item(bool restart)
if (restart && !list_style_stack_.empty())
{
const std::wstring curStyleName = current_list_style();
const std::wstring newStyleName = curStyleName + boost::lexical_cast<std::wstring>(new_list_style_number_++);
const std::wstring newStyleName = curStyleName + std::to_wstring(new_list_style_number_++);
list_style_renames_[curStyleName] = newStyleName;
odf_reader::list_style_container & lists = odf_context_.listStyleContainer();

View File

@ -143,9 +143,9 @@ public:
std::wstring style = std::wstring(L"position:absolute;");
style += std::wstring(L"margin-left:") + boost::lexical_cast<std::wstring>(c.left_) + std::wstring(L"pt;");
style += std::wstring(L"margin-left:") + boost::lexical_cast<std::wstring>(c.left_) + std::wstring(L"pt;");
style += std::wstring(L"margin-top:") + boost::lexical_cast<std::wstring>(c.top_) + std::wstring(L"pt;");
style += std::wstring(L"width:") + boost::lexical_cast<std::wstring>(c.width_) + std::wstring(L"pt;");
style += std::wstring(L"width:") + boost::lexical_cast<std::wstring>(c.width_) + std::wstring(L"pt;");
style += std::wstring(L"height:") + boost::lexical_cast<std::wstring>(c.height_) + std::wstring(L"pt;");
if (c.visibly_ == false)style += std::wstring(L"visibility:hidden;");
@ -227,14 +227,14 @@ public:
if (c.author_ == author_list_[i])
{
find=true;
c.author_ = boost::lexical_cast<std::wstring>(i);
c.author_ = std::to_wstring(i);
break;
}
}
if (!find)
{
author_list_.push_back(c.author_);
c.author_ = boost::lexical_cast<std::wstring>(author_list_.size()-1);
c.author_ = std::to_wstring(author_list_.size()-1);
}
xlsx_comment_.push_back(c);
}

View File

@ -54,21 +54,21 @@ public:
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments)
{
const std::wstring file_id = boost::lexical_cast<std::wstring>(next_file_id_++);
const std::wstring file_id = std::to_wstring(next_file_id_++);
const std::wstring fileName = std::wstring(L"comments") + file_id + L".xml";
const std::wstring vml_fileName = std::wstring(L"vmlDrawing") + file_id + L".vml";
comments_.push_back(comment_elm(fileName,vml_fileName, content, vml_content, comments));
const std::wstring id = boost::lexical_cast<std::wstring>(next_comments_id_++);
const std::wstring id = std::to_wstring(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(fileName, rId);
}
std::pair<std::wstring, std::wstring> get_vml_drawing_xml()
{
const std::wstring id = boost::lexical_cast<std::wstring>(next_comments_id_++);
const std::wstring id = std::to_wstring(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(comments_.back().vml_filename, rId);
}

View File

@ -113,7 +113,7 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
CP_XML_NODE(L"xdr:cNvPicPr")
@ -158,7 +158,7 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
CP_XML_ATTR(L"name", val.name);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
CP_XML_NODE(L"xdr:cNvSpPr")//non visual properies (собственно тока 1 там)
{

View File

@ -68,7 +68,7 @@ public:
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings)
{
const std::wstring id = boost::lexical_cast<std::wstring>(next_drawing_id_++);
const std::wstring id = std::to_wstring(next_drawing_id_++);
const std::wstring fileName = std::wstring(L"drawing") + id + L".xml";
drawings_.push_back(drawing_elm(fileName, content, drawings));
const std::wstring rId = std::wstring(L"rId") + id;//rDrId
@ -173,6 +173,7 @@ void xlsx_drawing_context::clear()
impl_->object_description_.additional_.clear();
impl_->object_description_.hlinks_.clear();
impl_->object_description_.action_.clear();
impl_->object_description_.additional_.clear();
impl_->use_image_replacement_ = false;
@ -207,7 +208,7 @@ void xlsx_drawing_context::end_group()
group_rect.cy -= group_rect.y;
group_rect.cx -= group_rect.x;
for (int i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
for (size_t i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
{
_rect & r = impl_->groups_.back()->child_objects_[i].svg_rect_.get();
@ -399,16 +400,17 @@ void xlsx_drawing_context::set_fill(_oox_fill & fill)
impl_->object_description_.fill_= fill;
}
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & href,bool object)
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & href)
{
++hlinks_size_;
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
std::wstring hId = L"hId" + std::to_wstring(hlinks_size_);
std::wstring href_correct = xml::utils::replace_text_to_xml(href);
XmlUtils::replace_all( href_correct, L" .", L".");//1 (130).odt
_hlink_desc desc = {hId, href_correct, object}; //корректность написания ссылки важна для ms office и не важна для open office ->
//todooo
//корректность написания ссылки важна для ms office и не важна для open office ->
//todooo
_hlink_desc desc = {hId, href_correct};
impl_->object_description_.hlinks_.push_back(desc);
return hId;
@ -464,6 +466,7 @@ void xlsx_drawing_context::process_common_properties(drawing_object_description
drawing.additional = obj.additional_;
drawing.hlinks = obj.hlinks_;
drawing.action = obj.action_;
}
void xlsx_drawing_context::process_position_properties(drawing_object_description & obj, xlsx_table_metrics & table_metrics,xlsx_table_position & from,xlsx_table_position & to)
{
@ -615,7 +618,7 @@ void xlsx_drawing_context::process_objects(xlsx_table_metrics & table_metrics)
}
void xlsx_drawing_context::process_objects(std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_)
{
for (int i = 0 ; i < objects.size(); i++)
for (size_t i = 0 ; i < objects.size(); i++)
{
drawing_object_description & obj = objects[i];
@ -662,11 +665,33 @@ void xlsx_drawing_context::serialize(std::wostream & strm)
impl_->serialize(strm);
}
xlsx_drawings_ptr xlsx_drawing_context::get_drawings()
{
return impl_->get_drawings();
}
void xlsx_drawing_context::start_action(std::wstring action)
{
impl_->object_description_.action_.enabled = true;
}
void xlsx_drawing_context::set_link(std::wstring link, RelsType typeRels)
{//hyprelinks only
++hlinks_size_;
std::wstring hId = L"hId" + std::to_wstring(hlinks_size_);
link = xml::utils::replace_text_to_xml(link);
if (typeRels == typeHyperlink)
XmlUtils::replace_all( link, L" .", L"."); //1 (130).odt
impl_->object_description_.action_.hId = hId;
impl_->object_description_.action_.hRef = link;
impl_->object_description_.action_.typeRels = typeRels;
}
void xlsx_drawing_context::end_action()
{
}
}
}

View File

@ -111,7 +111,7 @@ public:
std::vector<odf_reader::_property> & get_properties();
std::wstring add_hyperlink(std::wstring const & ref, bool object);
std::wstring add_hyperlink(std::wstring const & ref);
void set_use_image_replacement();
@ -125,6 +125,10 @@ public:
void process_objects(xlsx_table_metrics & table_metrics);
void start_action(std::wstring action);
void set_link(std::wstring link, RelsType typeRels = typeHyperlink);
void end_action();
private:
class Impl;
_CP_PTR(Impl) impl_;

View File

@ -50,10 +50,12 @@ public:
add (isInternal, rid, ref, type, sheet_rel);
for (int i = 0 ; i < d.hlinks.size(); i++)
for (size_t i = 0; i < d.hlinks.size(); i++)
{
xlsx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
}
if (!d.action.hId.empty())
xlsx_drawing_rels_.push_back(_rel(false, d.action.hId, d.action.hRef, d.action.typeRels));
}
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel) //не объект
{

View File

@ -82,7 +82,7 @@ public:
record r;
r.ref = ref;
r.display = display;
r.id = std::wstring(L"hId") + boost::lexical_cast<std::wstring>(records_.size()+1);
r.id = std::wstring(L"hId") + std::to_wstring(records_.size()+1);
int pos_target = target.find(L"#");
if (pos_target == 0)//ссыль на страницу или метку в текущем документе
@ -91,7 +91,7 @@ public:
int pos =target.find(L".");
if (pos < 0)
{
target = target + std::wstring(L".A1");
target = L"\"" + target + std::wstring(L"\".A1");
}
r.location = converter_.convert_ref(std::wstring(target.begin() + 1, target.end()));
r.type = L"Internal" ;

View File

@ -55,6 +55,7 @@ public:
std::wstringstream autofilter_;
std::wstringstream conditionalFormatting_;
std::wstringstream ole_objects_;
std::wstringstream page_props_;
rels hyperlinks_rels_;
rels ole_objects_rels_;
@ -134,6 +135,11 @@ std::wostream & xlsx_xml_worksheet::ole_objects()
{
return impl_->ole_objects_;
}
std::wostream & xlsx_xml_worksheet::page_properties()
{
return impl_->page_props_;
}
//---------------------------------------------------------------------------------------
rels & xlsx_xml_worksheet::hyperlinks_rels()
{
@ -196,9 +202,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_NODE(L"oleObjects")
{
CP_XML_STREAM() << impl_->ole_objects_.str();
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
if (!impl_->page_props_.str().empty())
{
CP_XML_STREAM() << impl_->page_props_.str();
}
//CP_XML_NODE(L"headerFooter){}
//CP_XML_NODE(L"rowBreaks){}

View File

@ -63,6 +63,7 @@ public:
std::wostream & conditionalFormatting();
std::wostream & sort();
std::wostream & ole_objects();
std::wostream & page_properties();
rels & hyperlinks_rels();
rels & ole_objects_rels();

View File

@ -128,7 +128,7 @@ void sheets_files::write(const std::wstring & RootPath)
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"sheet") + boost::lexical_cast<std::wstring>(count) + L".xml";
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();
@ -136,7 +136,7 @@ void sheets_files::write(const std::wstring & RootPath)
if (rels_)
{
const std::wstring id = std::wstring(L"sId") + boost::lexical_cast<std::wstring>(count);
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);
@ -286,7 +286,7 @@ void xl_charts_files::write(const std::wstring & RootPath)
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"chart") + boost::lexical_cast<std::wstring>(count) + L".xml";
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";

View File

@ -75,7 +75,7 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
if (!byRow)
CP_XML_ATTR(L"columnSort", true);
for (int i = 0 ; i < bySort.size(); i++)
for (size_t i = 0 ; i < bySort.size(); i++)
{
bool in_range = true;
std::wstring ref1, ref2;
@ -341,11 +341,26 @@ double charsToSize(unsigned int charsCount, double maxDigitSize)
return 1.0 * int((maxDigitSize * charsCount + 5.0) / maxDigitSize * 256.0) / 256.0;
}
void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
void xlsx_table_state::serialize_page_properties (std::wostream & strm)
{
_CP_OPT(std::wstring) masterPageName = context_->root()->odf_context().styleContainer().master_page_name_by_name(table_style_);
if (!masterPageName) return;
odf_reader::style_master_page* master_style_ = context_->root()->odf_context().pageLayoutContainer().master_page_by_name(*masterPageName);
if (!master_style_) return;
if (!master_style_->attlist_.style_page_layout_name_) return;
odf_reader::page_layout_instance * page_layout = context_->root()->odf_context().pageLayoutContainer().page_layout_by_name(*master_style_->attlist_.style_page_layout_name_);
if (!page_layout) return;
page_layout->xlsx_serialize(strm, *context_);
}
void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
CP_XML_WRITER(_Wostream)
CP_XML_WRITER(strm)
{
odf_reader::style_table_properties * table_prop = NULL;
odf_reader::style_instance * tableStyle = odfContext.styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
@ -406,8 +421,8 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
int col = -1, row = -1;
try
{
col = boost::lexical_cast<int>(s_col);
row = boost::lexical_cast<int>(s_row);
if (!s_col.empty()) col = boost::lexical_cast<int>(s_col);
if (!s_row.empty()) row = boost::lexical_cast<int>(s_row);
}
catch(...){}
@ -435,9 +450,9 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
{
const odf_reader::style_table_row_properties * prop = rowDefStyle->content()->get_style_table_row_properties();
if ( (prop) && (prop->style_table_row_properties_attlist_.style_row_height_))
if ( (prop) && (prop->attlist_.style_row_height_))
{
default_height = prop->style_table_row_properties_attlist_.style_row_height_->get_value_unit(odf_types::length::pt);
default_height = prop->attlist_.style_row_height_->get_value_unit(odf_types::length::pt);
}
std::wstringstream ht_s;
ht_s.precision(1);
@ -451,21 +466,21 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
}
}
void xlsx_table_state::serialize_merge_cells(std::wostream & _Wostream)
void xlsx_table_state::serialize_merge_cells(std::wostream & strm)
{
return xlsx_merge_cells_.xlsx_serialize(_Wostream);
return xlsx_merge_cells_.xlsx_serialize(strm);
}
void xlsx_table_state::serialize_ole_objects(std::wostream & _Wostream)
void xlsx_table_state::serialize_ole_objects(std::wostream & strm)
{
return xlsx_drawing_context_.get_drawings()->serialize_objects(_Wostream);
return xlsx_drawing_context_.get_drawings()->serialize_objects(strm);
}
void xlsx_table_state::serialize_hyperlinks(std::wostream & _Wostream)
void xlsx_table_state::serialize_hyperlinks(std::wostream & strm)
{
return xlsx_hyperlinks_.xlsx_serialize(_Wostream);
return xlsx_hyperlinks_.xlsx_serialize(strm);
}
void xlsx_table_state::serialize_conditionalFormatting(std::wostream & _Wostream)
void xlsx_table_state::serialize_conditionalFormatting(std::wostream & strm)
{
return xlsx_conditionalFormatting_context_.serialize(_Wostream);
return xlsx_conditionalFormatting_context_.serialize(strm);
}
void xlsx_table_state::dump_rels_hyperlinks(rels & Rels)
{

View File

@ -128,7 +128,8 @@ public:
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);

View File

@ -317,6 +317,10 @@ void xlsx_table_context::serialize_table_format(std::wostream & _Wostream)
{
return state()->serialize_table_format(_Wostream);
}
void xlsx_table_context::serialize_page_properties(std::wostream & _Wostream)
{
return state()->serialize_page_properties(_Wostream);
}
void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
{
return state()->serialize_hyperlinks(_Wostream);

View File

@ -90,6 +90,7 @@ public:
void serialize_conditionalFormatting(std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();

View File

@ -84,10 +84,10 @@ public:
void serialize_shared_strings(std::wostream & strm);
void ApplyTextProperties (std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type);
void ApplyTextProperties (std::wstring style, std::wstring para_style, odf_reader::text_format_properties_content & propertiesOut);
void ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut);
void set_local_styles_container(odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
void set_local_styles_container (odf_reader::styles_container* local_styles_);//это если стили объектов содержатся в другом документе
bool is_drawing_context(){return in_draw;}
@ -136,7 +136,8 @@ void xlsx_text_context::Impl::serialize_shared_strings(std::wostream & strm)
xlsx_text_context::Impl::Impl(odf_reader::styles_container & styles): paragraphs_cout_(0),styles_(styles),
in_comment(false),in_draw(false),in_paragraph(false),in_span(false),in_cell_content(false)
{
text_properties_cell_ = NULL;
local_styles_ptr_ = NULL;
text_properties_cell_ = NULL;
}
void xlsx_text_context::Impl::add_text(const std::wstring & text)
@ -236,48 +237,54 @@ void xlsx_text_context::Impl::end_hyperlink(std::wstring hId)
hyperlink_hId = hId;
}
void xlsx_text_context::Impl::ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type)
void xlsx_text_context::Impl::ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* paraStyle = NULL;
if (local_styles_ptr_)
{
odf_reader::style_instance * defaultStyle = local_styles_ptr_->style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = local_styles_ptr_->style_default_by_type(odf_types::style_family::Paragraph);
paraStyle = local_styles_ptr_->style_by_name(style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
}
else
{
odf_reader::style_instance * defaultStyle = styles_.style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = styles_.style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = styles_.style_default_by_type(odf_types::style_family::Paragraph);
paraStyle = styles_.style_by_name(style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (paraStyle) instances.push_back(paraStyle);
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type)
void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style, std::wstring para_style, odf_reader::text_format_properties_content & propertiesOut)
{
std::vector<const odf_reader::style_instance *> instances;
odf_reader::style_instance* defaultStyle = NULL;
odf_reader::style_instance* textStyle = NULL;
odf_reader::style_instance* paraStyle = NULL;
if (local_styles_ptr_)
{
odf_reader::style_instance * defaultStyle = local_styles_ptr_->style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = local_styles_ptr_->style_default_by_type(odf_types::style_family::Text);
paraStyle = local_styles_ptr_->style_by_name(para_style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
textStyle = local_styles_ptr_->style_by_name(style, odf_types::style_family::Text, false/*process_headers_footers_*/);
}
else
{
odf_reader::style_instance * defaultStyle = styles_.style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
odf_reader::style_instance* styleInst = styles_.style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
defaultStyle = styles_.style_default_by_type(odf_types::style_family::Text);
paraStyle = styles_.style_by_name(para_style, odf_types::style_family::Paragraph, false/*process_headers_footers_*/);
textStyle = styles_.style_by_name(style, odf_types::style_family::Text, false/*process_headers_footers_*/);
}
if (defaultStyle) instances.push_back(defaultStyle);
if (paraStyle) instances.push_back(paraStyle);
if (textStyle) instances.push_back(textStyle);
propertiesOut.apply_from(calc_text_properties_content(instances));
}
@ -290,10 +297,10 @@ void xlsx_text_context::Impl::write_pPr (std::wostream & strm)
{
if (paragraph_style_name_.empty())return;
odf_reader::paragraph_format_properties paragraph_format_properties_;
odf_reader::paragraph_format_properties paragraph_format_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_format_properties_ , odf_types::style_family::Paragraph);
paragraph_format_properties_.xlsx_convert(strm, in_draw);
ApplyParagraphProperties (paragraph_style_name_, paragraph_format_properties_);
paragraph_format_properties_.xlsx_convert (strm, in_draw);
}
void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
@ -302,92 +309,66 @@ void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
&& !(!hyperlink_hId.empty() && in_draw)
&& !(text_properties_cell_ && in_cell_content))return;
odf_reader::text_format_properties_content text_properties_paragraph_;
odf_reader::text_format_properties_content text_properties_span_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_ , odf_types::style_family::Paragraph);
ApplyTextProperties (span_style_name_, text_properties_span_ , odf_types::style_family::Text);
odf_reader::text_format_properties_content text_properties_;
if (in_cell_content && text_properties_cell_)
{
text_properties_.apply_from(*text_properties_cell_);
}
text_properties_.apply_from(text_properties_paragraph_);
text_properties_.apply_from(text_properties_span_);
}
_CP_OPT(double) dValFontSize;
if (text_properties_.fo_font_size_)
dValFontSize=text_properties_.fo_font_size_->get_length().get_value();
_CP_OPT(std::wstring) sValFontFamily;
if (text_properties_.fo_font_family_)
ApplyTextProperties (span_style_name_, paragraph_style_name_, text_properties_);
if (in_draw)
{
std::wstring val =text_properties_.fo_font_family_.get();
//'Arial' глючит
removeCharsFromString(val, _T("'"));
sValFontFamily=text_properties_.fo_font_family_.get();
odf_reader::fonts_container fonts;
text_properties_.drawing_serialize(strm, L"a:rPr", fonts);
}
//else if (text_properties_.style_font_name_) - тут может быть отсылка к font_face)decl !!!!
// sValFontFamily=text_properties_.style_font_name_.get();
_CP_OPT(std::wstring) sValFontColor;
if (text_properties_.fo_color_)
sValFontColor=text_properties_.fo_color_->get_hex_value();
_CP_OPT(int) iValFontWeight;
if (text_properties_.fo_font_weight_)
iValFontWeight=text_properties_.fo_font_weight_->get_type();
_CP_OPT(int) iValFontStyle;
if(text_properties_.fo_font_style_)
iValFontStyle=text_properties_.fo_font_style_->get_type();
CP_XML_WRITER(strm)
{
if (in_draw)
{
//oox_serialize_style_text(strm,text_properties_);
//oox_serialize_style_text(strm,odf_reader::text_format_properties_content & properties);
CP_XML_NODE(L"a:rPr")
{
//стр 3197
if (dValFontSize) {CP_XML_ATTR(L"sz", (int)(dValFontSize.get()*100));}
if ((iValFontStyle) && (iValFontStyle.get() >0)) {CP_XML_ATTR(L"i", "1");} //"true");} Exercícios de Aprendizagem.ods
if ((iValFontWeight) && (iValFontWeight.get() >0)) {CP_XML_ATTR(L"b", "1");} //"true");} Exercícios de Aprendizagem.ods
if (sValFontColor)
{
CP_XML_NODE(L"a:solidFill") {CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val", sValFontColor.get());}}
}
if (sValFontFamily)
{
CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface", sValFontFamily.get());}
}
if (hyperlink_hId.length()>0)
{
CP_XML_NODE(L"a:hlinkClick ")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", hyperlink_hId);
}
}
}
}
else
else
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"rPr")
{
if (sValFontFamily) {CP_XML_NODE(L"rFont") {CP_XML_ATTR(L"val", sValFontFamily.get());}}
if (dValFontSize) {CP_XML_NODE(L"sz") {CP_XML_ATTR(L"val", (int)(dValFontSize.get()));}}
if (sValFontColor) {CP_XML_NODE(L"color") {CP_XML_ATTR(L"rgb", sValFontColor.get());}}
if ((iValFontStyle) &&
(iValFontStyle.get() >0)) {CP_XML_NODE(L"i") {CP_XML_ATTR(L"val", "true");}}
if ((iValFontWeight) &&
(iValFontWeight.get() >0)) {CP_XML_NODE(L"b") {CP_XML_ATTR(L"val", "true");}}
if (text_properties_.fo_font_family_)
{
CP_XML_NODE(L"rFont")
{
CP_XML_ATTR(L"val", text_properties_.fo_font_family_.get());
}
}
if (text_properties_.fo_font_size_)
{
CP_XML_NODE(L"sz")
{
CP_XML_ATTR(L"val", (int)text_properties_.fo_font_size_->get_length().get_value());
}
}
if (text_properties_.fo_color_)
{
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"rgb", text_properties_.fo_color_->get_hex_value());
}
}
if (text_properties_.fo_font_style_)
{
CP_XML_NODE(L"i")
{
if (text_properties_.fo_font_style_->get_type() > 0)
CP_XML_ATTR(L"val", "true");
else
CP_XML_ATTR(L"val", "false");
}
}
if (text_properties_.fo_font_weight_)
{
CP_XML_NODE(L"b")
{
if (text_properties_.fo_font_weight_->get_type() > 0)
CP_XML_ATTR(L"val", "true");
else
CP_XML_ATTR(L"val", "false");
}
}
}
}
}

View File

@ -54,10 +54,9 @@ class xlsx_conversion_context;
class xlsx_text_context: boost::noncopyable
{
public:
//xlsx_text_context();
xlsx_text_context(odf_reader::styles_container & styles_);
~xlsx_text_context();
public:
xlsx_text_context (odf_reader::styles_container & styles_);
~xlsx_text_context ();
void set_local_styles_container (odf_reader::styles_container *local_styles_);
void set_cell_text_properties (odf_reader::text_format_properties_content *text_properties);

View File

@ -66,7 +66,7 @@ std::wstring getColAddress(size_t col)
std::wstring getRowAddress(size_t row)
{
return boost::lexical_cast<std::wstring>(row + 1);
return std::to_wstring(row + 1);
}
std::wstring getCellAddress(size_t col, size_t row)

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