Compare commits

..

133 Commits

Author SHA1 Message Date
4df09fd25a Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 16:27:27 +03:00
8bae2e3255 . 2018-10-19 14:25:35 +03:00
6180fedb0b Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 13:05:15 +03:00
35113a76ca . 2018-10-19 12:10:06 +03:00
5895bc9641 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 10:51:20 +03:00
a5a6686501 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-19 10:50:49 +03:00
f776bb6c4e OdfFormatWriter - fix after testing 2018-10-19 10:36:02 +03:00
4c930e716b Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-17 15:38:13 +03:00
595ecae254 x2t - binary - native convert locked canvas - bix bug #28246 2018-10-17 13:29:55 +03:00
8d3e50f8c0 x2t - version up 2018-10-16 19:11:14 +03:00
2439106397 Fix crash on empty dash pen 2018-10-16 17:52:22 +03:00
8953b74579 Fix bug 39214 (text selection in pdf/xps) 2018-10-16 17:17:13 +03:00
bd7978e474 Correct test 2018-10-16 15:52:28 +03:00
95238af0f5 Merge branch 'hotfix/v5.2.3' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.3 2018-10-15 14:02:06 +03:00
e83daf6c91 RtfFormatReader - fix bug #39315 2018-10-15 14:01:27 +03:00
a4cade5a58 Test for work with standart docs 2018-10-15 13:59:52 +03:00
4fb284ebee x2t - fix bug #39307 2018-10-15 13:12:27 +03:00
900ed115c7 Test for work with standart docs 2018-10-12 19:44:43 +03:00
d34b850c52 [ios][pe] events 2018-10-12 19:15:18 +03:00
cc31becec1 [x2t] Fix bug 39305
Fix String.ToString2 after f7a13e04d8
2018-10-12 16:39:01 +03:00
24332cca42 [ios][x2t] fixed build 2018-10-12 12:39:04 +03:00
9b5f052c97 OdfFormatWriter - fix after testing 2018-10-11 17:57:45 +03:00
2017a8c692 OdfFormat - fix after testing 2018-10-10 19:29:31 +03:00
55e7777abb [zlib] Remove zlib-1.2.3 2018-10-10 18:46:27 +03:00
b7c8bc2769 [zlib] Update zlib to 1.2.11
Fix opening of xlsx created by NPOI(bad-zip.xlsx)
2018-10-10 18:42:45 +03:00
13900daf08 [zlib] Repeat local changes from zlib-1.2.3 2018-10-10 18:39:00 +03:00
2feb1ac8e8 Add zlib-1.2.11 2018-10-10 17:52:04 +03:00
558c669fb6 Disable truetype fonts convertasion in html viewer 2018-10-10 15:58:26 +03:00
6268e8c3f3 PptxFormat - fix after testing 2018-10-10 11:27:39 +03:00
d872f4220c Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-09 18:14:42 +03:00
3c24392e16 PptxFormat - fix after testing 2018-10-09 18:13:57 +03:00
e859821647 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-09 17:02:46 +03:00
5c1a2f11f9 XlsFormatReader - fix users file (external defined names) 2018-10-09 14:53:04 +03:00
f7a13e04d8 DocxFormat - fix read binary file - bug #39248 2018-10-09 14:02:15 +03:00
18cbd41c84 Add GetImage method to IImageCache 2018-10-08 18:16:06 +03:00
c6e47a7bcf DocxFormat - fix bug #39216 2018-10-08 13:08:17 +03:00
62d6581c43 DocFormatReader - fix bug #39236 2018-10-08 11:32:31 +03:00
2d0e5aefa0 Merge pull request #117 from ONLYOFFICE/feature/aspose-math
Feature/aspose math
2018-10-05 17:04:41 +03:00
78a5546d0a PptxFormat - fix binary convert mathType version over 3.0 2018-10-05 12:49:01 +03:00
8985395ef1 [x2t] Move from mm to twips in Editor.bin 2018-10-04 17:58:29 +03:00
f55a5418e9 x2t - fix pptx section list 2018-10-04 17:39:32 +03:00
9410862444 [x2t] Fix bin->docx default style falg 2018-10-04 15:08:14 +03:00
f4d72572c0 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-04 13:04:52 +03:00
f078605031 x2t - select method encrypt files 2018-10-04 13:01:49 +03:00
9105894416 . 2018-10-04 11:32:05 +03:00
1102f7f9b0 OdfFormat - not strong encryption 2018-10-03 20:13:49 +03:00
9aad3d1adb x2t - ooxml - not strong encryption 2018-10-03 20:01:57 +03:00
bc319bddbf Gost algorithms 2018-10-03 19:18:01 +03:00
8d664c2a4f . 2018-10-03 17:22:33 +03:00
cbfa907451 graphics - metafile - fix convert to rastr on linux without set fonts 2018-10-03 15:02:29 +03:00
0712bcfd5c OdfFormatwriter - convert bookmarks 2018-10-02 19:16:14 +03:00
474873531d OdfFormatReader - fix bug #39192 2018-10-02 14:47:38 +03:00
8625e93ac5 [x2t] Rename READ2_DEF -> READ2_DEF_SPREADSHEET 2018-10-01 18:14:04 +03:00
fb79df8c6c . 2018-10-01 11:40:48 +03:00
071ad3f86e . 2018-09-30 17:21:48 +03:00
65bcdb3bea . 2018-09-30 17:08:42 +03:00
f9f26e84fd . 2018-09-30 14:35:49 +03:00
a3888a8186 . 2018-09-28 17:19:20 +03:00
1493e4a949 [ios][x2t] fixed build 2018-09-28 16:36:12 +03:00
85bf4b8fac Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 15:57:47 +03:00
94ec819e68 x2t clear compiling warnings 2018-09-28 15:56:59 +03:00
cb7c7cb4d5 . 2018-09-28 14:55:50 +03:00
b1b911b538 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 14:51:13 +03:00
d94595f755 OdfFormat - refactoring convert word-arts from/to ooxml; convert form controls in spreadsheets 2018-09-28 14:50:09 +03:00
2192bff46b Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 14:39:43 +03:00
c7eb16fa64 x2t - clear compiling warnings 2018-09-28 14:30:27 +03:00
d9922e4782 x2t - binary file - add converting effects for drawings 2018-09-28 14:29:33 +03:00
6ee7d79cc4 RtfFormatReader - fix bug #39172 2018-09-28 14:25:18 +03:00
332348ef5b release/v5.2.0 2018-09-27 19:07:44 +03:00
e4e6acd1bc [android][x2t] added doctrenderer file stub 2018-09-27 15:03:47 +03:00
7418b2327a Merge remote-tracking branch 'origin/develop' into develop 2018-09-27 14:10:28 +03:00
18d610e3e0 [android][x2t] added example of converter 2018-09-27 14:09:12 +03:00
4e81420eed [ios][x2t] fixed build 2018-09-26 16:18:50 +03:00
e26f836da7 Merge commit '69d2b12f5315e96442fc5a0620d4f4c2070c4e77' into develop 2018-09-24 18:34:51 +03:00
69d2b12f53 . 2018-09-24 17:48:02 +03:00
f2260748c8 . 2018-09-24 17:48:02 +03:00
b59f84b262 . 2018-09-24 17:48:02 +03:00
3e5fed8482 x2t - fix return codes 2018-09-24 17:48:02 +03:00
538e477818 Revert "[test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32"
This reverts commit 05694d13f3.
2018-09-24 13:19:18 +03:00
b212e878c6 Merge pull request #114 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-24 01:13:01 +03:00
05694d13f3 [test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32 2018-09-24 01:04:14 +03:00
1dd72c99a2 Remove define GetCharWidth 2018-09-21 16:43:39 +02:00
4b73e58693 [bug] Fix missing function name 2018-09-21 17:36:32 +03:00
bee4f57dd3 [bug] Fix opening encrypted odf files 2018-09-21 17:36:32 +03:00
dd40e3e53c Merge pull request #111 from ONLYOFFICE/feature/ComboFonts
Fix bug with squares in combobox fonts (& empty rects)
2018-09-21 14:54:43 +03:00
d657ece017 Fix bug with squares in combobox fonts (& empty rects) 2018-09-21 14:36:14 +03:00
b21b1b8aaf [bug] Fix missing function name 2018-09-21 13:02:23 +03:00
09fb980060 [bug] Fix opening encrypted odf files 2018-09-21 12:01:01 +03:00
142f9f57a3 OdfFormatReader&Writer - refactoring converting wordarts from/to ooxml 2018-09-20 18:59:51 +03:00
1955dc98df [x2t] Set default value for math nodes with val attribute and COnOff type 2018-09-20 17:38:30 +03:00
28346c4571 Fix bug with squares in combobox fonts (& empty rects) 2018-09-20 14:53:10 +03:00
9810087ee1 Merge pull request #108 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-20 14:38:32 +03:00
2b8e1456c2 . 2018-09-20 11:41:42 +03:00
274c000ce7 fix PdfReader 2018-09-20 11:35:30 +03:00
9e6dd1fbb1 fix OdfReader 2018-09-20 11:35:30 +03:00
158692f824 [x2t] Fix opening docx with track changes and math created by aspose 2018-09-19 16:53:05 +03:00
49723e648a . 2018-09-19 11:29:43 +03:00
b0a2104b21 Merge commit 'de51052f6ae59ac36665fb3f85804081a888c7c5' into develop 2018-09-18 20:03:33 +03:00
e4986f4202 . 2018-09-18 19:35:06 +03:00
de51052f6a [bug] Fix file corruption after pasting picture with error 2018-09-18 18:47:12 +03:00
bd1dc5a7b6 . 2018-09-17 17:28:46 +03:00
1ccbe323f4 . 2018-09-14 19:21:12 +03:00
2c8efcb183 Merge pull request #106 from ONLYOFFICE/feature/provideARCtoKernel
send use ARC parameter to downloader
2018-09-14 18:46:40 +03:00
9c2a717870 send use ARC parameter to downloader 2018-09-14 17:03:12 +03:00
3811169415 Merge commit '185dc3064f731e4adb04040e116dc53110c6d866' into develop 2018-09-14 11:36:36 +03:00
2871769479 . 2018-09-14 11:34:07 +03:00
185dc3064f OdfFormat - fix comment in empty cell-row, fix default background color 2018-09-13 19:51:31 +03:00
c6f8a1cde8 [bug] Fix bug 38876 2018-09-13 16:47:50 +03:00
acdce1edb9 . 2018-09-12 17:53:40 +03:00
67a40a5fc4 Constructor of __ox_drawing doesn't receive parameters 2018-09-12 15:41:37 +03:00
67cd654785 OdfFormatReader - convert form controls in spreadsheets 2018-09-11 14:59:10 +03:00
3816162555 Merge commit '3fb166f99a211e85474c121009019d06710722f8' into develop 2018-09-10 18:43:15 +03:00
3fb166f99a OdfFormatWriter - fix repeated rows 2018-09-10 18:15:35 +03:00
d8121d1a12 [ios][x2t] fixed array check 2018-09-06 19:11:47 +03:00
a76bf57051 fix bug #38817 2018-09-06 13:46:47 +03:00
97b92cf75c . 2018-09-05 18:39:32 +03:00
506de8e9e1 fix bug #38678 2018-09-05 18:38:55 +03:00
fb34d57ee6 DocFormatReader - fix footnotes for doc1995; optimization convert 2018-09-05 14:45:24 +03:00
da2d997838 . 2018-09-03 19:50:02 +03:00
76d68fa70f Fix bug #38544
Fix the problem with calculating transformation matrix for the EMF. Add support of EMR_STRETCHBLT field.
2018-09-03 18:07:10 +03:00
677e3e49e0 . 2018-08-31 17:38:17 +03:00
02c84d107b Merge commit 'b59908e4c25b265641e77b2167826f236b3b9d64' into develop 2018-08-31 17:27:06 +03:00
b59908e4c2 OdfFormatWriter - add same preset ooxml shapes 2018-08-31 16:13:07 +03:00
04e6b642f4 OdfFormatWriter - fix bug #38720 2018-08-31 14:12:49 +03:00
49cd76d0f3 Ooxml encrypt files - add support compatibility with Office 2003-2007(+ add rc4 method to encrtypt); add des method in agile encryption 2018-08-30 17:47:17 +03:00
c9ddd5b7b5 [bug] Fix tmp file name if nedd download src file 2018-08-30 16:37:15 +03:00
53a75261e3 . 2018-08-29 19:05:30 +03:00
26f32dd511 [ios][pe] chart events 2018-08-29 18:25:08 +03:00
e1e788b768 [x2t] Add Compat settings to Editor.bin 2018-08-29 17:30:18 +03:00
a74c927e7e DocFormatReader - fix after testing 2018-08-28 15:13:41 +03:00
c94e1e3223 V8 windows xp support 2018-08-27 16:40:56 +03:00
4afe985955 Fix building libicue on all glibc > 2.26 systems 2018-08-24 12:35:45 +03:00
94548131a1 v5.1.5 2018-07-17 17:08:49 +03:00
819 changed files with 66523 additions and 33323 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -59,22 +59,27 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute(L"xmlns:v", OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute(L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute(L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
//m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
//m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
//m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
m_pXmlWriter->WriteAttribute(L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex");
m_pXmlWriter->WriteAttribute(L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex");
m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:w15", L"http://schemas.microsoft.com/office/word/2012/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex");
m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 w15 w16se wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{

View File

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

View File

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

View File

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

View File

@ -79,7 +79,7 @@ namespace DocFileFormat
drawing.dgglbl = (DrawingType)oStearmReader.ReadByte();
drawing.container = static_cast<DrawingContainer*>(RecordFactory::ReadRecord (&oStearmReader, 0));
for (unsigned int i = 0; i < drawing.container->Children.size(); ++i)
for (size_t i = 0; i < drawing.container->Children.size(); ++i)
{
Record* groupChild = drawing.container->Children[i];
if (groupChild)
@ -97,8 +97,8 @@ namespace DocFileFormat
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
if (shape)
{
shape->Index = i;
if (shape->isBackground())
shape->m_nIndex = (int)i;
if (shape->m_bBackground)
{
m_pBackgroud = shape;
}
@ -140,7 +140,7 @@ namespace DocFileFormat
GroupContainer* group = iter->container->FirstChildWithType<GroupContainer>();
if (group)
{
for (unsigned int i = 1; i < group->Children.size(); ++i)
for (size_t i = 1; i < group->Children.size(); ++i)
{
Record* groupChild = group->Children[i];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -422,12 +422,11 @@ namespace DocFileFormat
//numbering
case sprmOldPAnld:
{
NumberingDescriptor desc( iter->Arguments, iter->argumentsSize );
NumberingDescriptorPtr desc = NumberingDescriptor::create( iter->Arguments, iter->argumentsSize );
if (m_document->listTable)
{
m_document->listTable->appendNumbering( desc );
short numId = static_cast<short>(m_document->listTable->listNumbering.size());
unsigned short numId = m_document->listTable->appendNumbering( desc );
appendValueElement( &numPr, L"numId", numId, true );
}
}break;
@ -460,7 +459,8 @@ namespace DocFileFormat
//Todo разобраться с закоментированным кодом
if (NULL != m_document->listTable && false == m_document->listTable->listData.empty())
{
appendValueElement( &numPr, L"numId", FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), true );
unsigned short numId = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueElement( &numPr, L"numId", numId, true );
}
//check if there is a ilvl reference, if not, check the count of LVLs.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -324,24 +324,28 @@ namespace DocFileFormat
}break;
//BORDERS
case borderBottomColor:
if (!pict->brcBottom)
{
RGBColor bottomColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor", L"#" + bottomColor.SixDigitHexCode);
}
break;
case borderLeftColor:
if (!pict->brcLeft)
{
RGBColor leftColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderleftcolor", L"#" + leftColor.SixDigitHexCode);
}
break;
case borderRightColor:
if (!pict->brcRight)
{
RGBColor rightColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:borderrightcolor", L"#" + rightColor.SixDigitHexCode);
}
break;
case borderTopColor:
if (!pict->brcTop)
{
RGBColor topColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( L"o:bordertopcolor", L"#" + topColor.SixDigitHexCode);
@ -423,8 +427,9 @@ namespace DocFileFormat
{
appendStyleProperty(&strStyle, L"visibility", L"hidden");
}
}
break;
}break;
default:
break;
}
}
@ -463,12 +468,9 @@ namespace DocFileFormat
{
appendValueAttribute(m_imageData, L"r:id", L"rId" + FormatUtils::IntToWideString(m_nImageId));
appendValueAttribute(m_imageData, L"o:title", L"" );
m_pXmlWriter->WriteString(m_imageData->GetXMLString());
}
else
{
appendValueAttribute(m_imageData, L"r:id", L"");
}
m_pXmlWriter->WriteString(m_imageData->GetXMLString());
{//borders
writePictureBorder( L"bordertop", pict->brcTop );

View File

@ -168,6 +168,8 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"wrapcoords", wrapCoords);
}
break;
default:
break;
}
}
@ -250,7 +252,7 @@ namespace DocFileFormat
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())));
}
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)));
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->m_nIndex)));
if (pShape->is<LineType>())
{
@ -1682,6 +1684,8 @@ namespace DocFileFormat
{
appendStyleProperty(oStyle, L"mso-wrap-distance-top", (FormatUtils::DoubleToWideString(EmuValue((int)iter->op).ToPoints()) + std::wstring(L"pt")));
}break;
default:
break;
}
}
@ -1819,12 +1823,12 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"none";
case 1: return L"block";
case 2: return L"classic";
case 3: return L"diamond";
case 4: return L"oval";
case 5: return L"open";
default: return L"none";
}
}
@ -1832,9 +1836,9 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"short";
case 1: return L"medium";
case 2: return L"long";
default: return L"short";
}
}
@ -1842,9 +1846,9 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"narrow";
case 1: return L"medium";
case 2: return L"wide";
default: return L"narrow";
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -66,7 +66,7 @@ namespace Writers
NSDirectory::CreateDirectories(sCustomXmlRelsDir);
m_pDrawingConverter->SetDstContentRels();
long lId;
unsigned int lId;
m_pDrawingConverter->WriteRels(OOX::FileTypes::CustomXmlProps.RelationType(), sCustomXMLPropsFilename, L"", &lId);
m_pDrawingConverter->SaveDstContentRels(sCustomXmlRelsDir + FILE_SEPARATOR_STR + sCustomXmlFilename + L".rels");

View File

@ -42,15 +42,15 @@ class SectPr
{
public:
std::wstring sHeaderFooterReference;
double W;
double H;
long W;
long H;
BYTE cOrientation;
double Left;
double Top;
double Right;
double Bottom;
double Header;
double Footer;
long Left;
long Top;
long Right;
long Bottom;
long Header;
long Footer;
bool TitlePg;
bool EvenAndOddHeaders;
BYTE SectionType;
@ -61,6 +61,13 @@ public:
std::wstring footnotePr;
std::wstring endnotePr;
bool bW;
bool bH;
bool bOrientation;
bool bLeft;
bool bTop;
bool bRight;
bool bBottom;
bool bHeader;
bool bFooter;
bool bTitlePg;
@ -69,18 +76,16 @@ public:
bool bPageNumStart;
SectPr()
{
W = Page_Width;
H = Page_Height;
cOrientation = orientation_Portrait;
Left = 30;
Top = 20;
Right = 15;
Bottom = 20;
Header = 12.5;
Footer = 12.5;
sHeaderFooterReference = _T("");
cols = _T("<w:cols w:space=\"708\"/>");
bW = false;
bH = false;
bOrientation = false;
bLeft = false;
bTop = false;
bRight = false;
bBottom = false;
bHeader = false;
bFooter = false;
bTitlePg = false;
@ -91,14 +96,6 @@ public:
std::wstring Write()
{
std::wstring sRes = _T("");
long nWidth = SerializeCommon::Round(W * g_dKoef_mm_to_twips);
long nHeight = SerializeCommon::Round(H * g_dKoef_mm_to_twips);
long nMLeft = SerializeCommon::Round(Left * g_dKoef_mm_to_twips);
long nMTop = SerializeCommon::Round(Top * g_dKoef_mm_to_twips);
long nMRight = SerializeCommon::Round(Right * g_dKoef_mm_to_twips);
long nMBottom = SerializeCommon::Round(Bottom * g_dKoef_mm_to_twips);
long nMHeader = SerializeCommon::Round(Header * g_dKoef_mm_to_twips);
long nMFooter = SerializeCommon::Round(Footer * g_dKoef_mm_to_twips);
if(!sHeaderFooterReference.empty())
sRes += sHeaderFooterReference;
@ -120,19 +117,41 @@ public:
}
sRes += L"<w:type w:val=\"" + sType + L"\"/>";
}
sRes += L"<w:pgSz w:w=\"" + std::to_wstring(nWidth) + L"\" w:h=\"" + std::to_wstring(nHeight) + L"\"";
if(orientation_Portrait != cOrientation)
sRes += L" w:orient=\"landscape\"";
sRes += L"/>";
if((bW && bH) || bOrientation)
{
sRes += L"<w:pgSz";
if(bW && bH)
{
sRes += L" w:w=\"" + std::to_wstring(W) + L"\" w:h=\"" + std::to_wstring(H) + L"\"";
}
if(bOrientation)
{
if(orientation_Portrait != cOrientation)
sRes += L" w:orient=\"landscape\"";
else
sRes += L" w:orient=\"portrait\"";
}
sRes += L"<w:pgMar w:top=\"" + std::to_wstring(nMTop) + L"\" w:right=\"" + std::to_wstring(nMRight) +
L"\" w:bottom=\"" + std::to_wstring(nMBottom) + L"\" w:left=\"" + std::to_wstring(nMLeft) + L"\" w:gutter=\"0\"";
sRes += L"/>";
}
if(bHeader)
sRes += L" w:header=\"" + std::to_wstring(nMHeader) + L"\"";
if(bFooter)
sRes += L" w:footer=\"" + std::to_wstring(nMFooter) + L"\"";
sRes += L"/>";
if(bLeft || bTop || bRight || bBottom || bHeader || bFooter)
{
sRes += L"<w:pgMar";
if(bTop)
sRes += L" w:top=\"" + std::to_wstring(Top) + L"\"";
if(bRight)
sRes += L" w:right=\"" + std::to_wstring(Right) + L"\"";
if(bBottom)
sRes += L" w:bottom=\"" + std::to_wstring(Bottom) + L"\"";
if(bLeft)
sRes += L" w:left=\"" + std::to_wstring(Left) + L"\"";
if(bHeader)
sRes += L" w:header=\"" + std::to_wstring(Header) + L"\"";
if(bFooter)
sRes += L" w:footer=\"" + std::to_wstring(Footer) + L"\"";
sRes += L" w:gutter=\"0\"/>";
}
if(!pgBorders.empty())
sRes += pgBorders;
@ -245,6 +264,7 @@ class Spacing
public:
bool bLineRule;
bool bLine;
bool bLineTwips;
bool bAfter;
bool bBefore;
bool bAfterAuto;
@ -252,14 +272,16 @@ public:
BYTE LineRule;
double Line;
double After;
double Before;
long LineTwips;
long After;
long Before;
bool AfterAuto;
bool BeforeAuto;
Spacing()
{
bLineRule = false;
bLine = false;
bLineTwips = false;
bAfter = false;
bBefore = false;
bAfterAuto = false;
@ -401,7 +423,7 @@ class Tab
{
public:
BYTE Val;
double Pos;
long Pos;
BYTE Leader;
bool bLeader;
Tab()
@ -435,11 +457,11 @@ public:
docRGB HighLight;
std::wstring Shd;
std::wstring RStyle;
double Spacing;
long Spacing;
bool DStrikeout;
bool Caps;
bool SmallCaps;
double Position;
long Position;
BYTE FontHint;
bool BoldCs;
bool ItalicCs;
@ -680,13 +702,11 @@ public:
}
if(bSpacing)
{
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * Spacing);
pCStringWriter->WriteString(L"<w:spacing w:val=\"" + std::to_wstring(nSpacing) + L"\"/>");
pCStringWriter->WriteString(L"<w:spacing w:val=\"" + std::to_wstring(Spacing) + L"\"/>");
}
if(bPosition)
{
long nPosition = SerializeCommon::Round( g_dKoef_mm_to_hps * Position);
std::wstring sPosition = L"<w:position w:val=\"" + std::to_wstring(nPosition) + L"\"/>";
std::wstring sPosition = L"<w:position w:val=\"" + std::to_wstring(Position) + L"\"/>";
pCStringWriter->WriteString(sPosition);
}
if(bFontSize)
@ -1039,6 +1059,26 @@ public:
};
class PaddingsToWrite
{
public:
long Left;
long Top;
long Right;
long Bottom;
bool bLeft;
bool bTop;
bool bRight;
bool bBottom;
public: PaddingsToWrite()
{
bLeft = false;
bTop = false;
bRight = false;
bBottom = false;
}
};
class PaddingsToWriteMM
{
public:
double Left;
double Top;
@ -1049,7 +1089,7 @@ public:
bool bTop;
bool bRight;
bool bBottom;
public: PaddingsToWrite()
public: PaddingsToWriteMM()
{
bLeft = false;
bTop = false;
@ -1066,7 +1106,7 @@ public:
double Y;
double Width;
double Height;
PaddingsToWrite Paddings;
PaddingsToWriteMM Paddings;
int m_nDocPr;
bool bMediaId;
@ -1205,8 +1245,8 @@ class docBorder
{
public:
docRGB Color;
double Space;
double Size;
long Space;
long Size;
BYTE Value;
CThemeColor ThemeColor;
@ -1239,13 +1279,11 @@ public:
}
if(bSize)
{
long nSize = SerializeCommon::Round(g_dKoef_mm_to_eightpoint * Size);
pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(nSize) + L"\"");
pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(Size) + L"\"");
}
if(bSpace)
{
long nSpace = SerializeCommon::Round(g_dKoef_mm_to_pt * Space);
pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(nSpace) + L"\"");
pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(Space) + L"\"");
}
if(bThemeColor && ThemeColor.IsNoEmpty())
{
@ -2112,8 +2150,8 @@ public:
class CDrawingPropertyWrapPoint
{
public:
double X;
double Y;
__int64 X;
__int64 Y;
bool bX;
bool bY;
@ -2153,36 +2191,36 @@ class CDrawingProperty
public:
bool bObject;
std::wstring sObjectProgram;
long nObjectId;
unsigned int nObjectId;
BYTE nObjectType;
long DataPos;
long DataLength;
BYTE Type;
bool BehindDoc;
double DistL;
double DistT;
double DistR;
double DistB;
__int64 DistL;
__int64 DistT;
__int64 DistR;
__int64 DistB;
bool LayoutInCell;
unsigned long RelativeHeight;
bool BSimplePos;
double EffectExtentL;
double EffectExtentT;
double EffectExtentR;
double EffectExtentB;
double Width;
double Height;
__int64 EffectExtentL;
__int64 EffectExtentT;
__int64 EffectExtentR;
__int64 EffectExtentB;
__int64 Width;
__int64 Height;
BYTE PositionHRelativeFrom;
BYTE PositionHAlign;
double PositionHPosOffset;
double PositionHPctOffset;
__int64 PositionHPosOffset;
double PositionHPctOffset;
BYTE PositionVRelativeFrom;
BYTE PositionVAlign;
double PositionVPosOffset;
__int64 PositionVPosOffset;
double PositionVPctOffset;
double SimplePosX;
double SimplePosY;
__int64 SimplePosX;
__int64 SimplePosY;
std::wstring sChartRels;
std::wstring sSizeRelH;
std::wstring sSizeRelV;
@ -2272,24 +2310,17 @@ public:
{
if(bWidth && bHeight)
{
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
if(false == bChart)
sXml += L"<wp:inline xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight) + L"\"/>";
distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height) + L"\"/>";
else
sXml += L"<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">\
<wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight) + L"\"/>";
<wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height) + L"\"/>";
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(emuEffectExtentL) + L"\" t=\"" + std::to_wstring(emuEffectExtentT) +
L"\" r=\"" + std::to_wstring(emuEffectExtentR) + L"\" b=\"" + std::to_wstring(emuEffectExtentB) + L"\"/>";
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(EffectExtentL) + L"\" t=\"" + std::to_wstring(EffectExtentT) +
L"\" r=\"" + std::to_wstring(EffectExtentR) + L"\" b=\"" + std::to_wstring(EffectExtentB) + L"\"/>";
}
if(!sDocPr.empty())
@ -2331,13 +2362,13 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
__int64 emuDistB = 0;
if(bDistL)
emuDistL = (__int64)(g_dKoef_mm_to_emu * DistL);
emuDistL = DistL;
if(bDistT)
emuDistT = (__int64)(g_dKoef_mm_to_emu * DistT);
emuDistT = DistT;
if(bDistR)
emuDistR = (__int64)(g_dKoef_mm_to_emu * DistR);
emuDistR = DistR;
if(bDistB)
emuDistB = (__int64)(g_dKoef_mm_to_emu * DistB);
emuDistB = DistB;
int nSimplePos = 0;
if(bBSimplePos && BSimplePos)
nSimplePos = 1;
@ -2366,10 +2397,10 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
__int64 emuX = 0;
if(bSimplePosX)
emuX = (__int64)(g_dKoef_mm_to_emu * SimplePosX);
emuX = SimplePosX;
__int64 emuY = 0;
if(bSimplePosY)
emuY = (__int64)(g_dKoef_mm_to_emu * SimplePosY);
emuY = SimplePosY;
sXml += L"<wp:simplePos x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
if(bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset))
@ -2400,8 +2431,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
else if(bPositionHPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionHPosOffset);
sContent = L"<wp:posOffset>" + std::to_wstring(emuPosOffset) + L"</wp:posOffset>";
sContent = L"<wp:posOffset>" + std::to_wstring(PositionHPosOffset) + L"</wp:posOffset>";
}
else if(bPositionHPctOffset)
{
@ -2438,8 +2468,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
else if(bPositionVPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionVPosOffset);
sContent = L"<wp:posOffset>" + std::to_wstring(emuPosOffset) + L"</wp:posOffset>";
sContent = L"<wp:posOffset>" + std::to_wstring(PositionVPosOffset) + L"</wp:posOffset>";
}
else if(bPositionVPctOffset)
{
@ -2448,20 +2477,13 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
sXml += L"<wp:positionV relativeFrom=\"" + sRelativeFrom + L"\">" + sContent + L"</wp:positionV>";
}
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
sXml += L"<wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight)+ L"\"/>";
sXml += L"<wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height)+ L"\"/>";
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(emuEffectExtentL) +
L"\" t=\"" + std::to_wstring(emuEffectExtentT) + L"\" r=\"" + std::to_wstring(emuEffectExtentR) +
L"\" b=\"" + std::to_wstring(emuEffectExtentB) + L"\"/>";
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(EffectExtentL) +
L"\" t=\"" + std::to_wstring(EffectExtentT) + L"\" r=\"" + std::to_wstring(EffectExtentR) +
L"\" b=\"" + std::to_wstring(EffectExtentB) + L"\"/>";
}
if(bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType)
{
@ -2492,9 +2514,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
if(DrawingPropertyWrap.bStart && DrawingPropertyWrap.Start.bX && DrawingPropertyWrap.Start.bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.Y);
sXml += L"<wp:start x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
sXml += L"<wp:start x=\"" + std::to_wstring(DrawingPropertyWrap.Start.X) + L"\" y=\"" + std::to_wstring(DrawingPropertyWrap.Start.Y) + L"\"/>";
}
for(size_t i = 0; i < DrawingPropertyWrap.Points.size(); ++i)
@ -2502,9 +2522,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i];
if(pWrapPoint->bX && pWrapPoint->bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->Y);
sXml += L"<wp:lineTo x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
sXml += L"<wp:lineTo x=\"" + std::to_wstring(pWrapPoint->X) + L"\" y=\"" + std::to_wstring(pWrapPoint->Y) + L"\"/>";
}
}
sXml += L"</wp:wrapPolygon>";

View File

@ -100,10 +100,9 @@ public:
RELEASEOBJECT(m_oRPr)
}
};
#define READ1_DEF(stLen, res, fReadFunction, arg) {\
long read1defCurPos = 0;\
while(read1defCurPos < stLen)\
while(read1defCurPos < (long)stLen)\
{\
BYTE read1defType = m_oBufferedStream.GetUChar();\
long read1defLength = m_oBufferedStream.GetLong();\
@ -120,7 +119,7 @@ public:
}
#define READ2_DEF(stLen, res, fReadFunction, arg) {\
long read2defCurPos = 0;\
while(read2defCurPos < stLen)\
while(read2defCurPos < (long)stLen)\
{\
BYTE read2defType = m_oBufferedStream.GetUChar();\
long read2defLenType = m_oBufferedStream.GetUChar();\
@ -456,7 +455,13 @@ public:
case c_oSerProp_rPrType::Spacing:
{
orPr->bSpacing = true;
orPr->Spacing = m_oBufferedStream.GetDouble();
orPr->Spacing = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
break;
case c_oSerProp_rPrType::SpacingTwips:
{
orPr->bSpacing = true;
orPr->Spacing = m_oBufferedStream.GetLong();
}
break;
case c_oSerProp_rPrType::DStrikeout:
@ -480,7 +485,13 @@ public:
case c_oSerProp_rPrType::Position:
{
orPr->bPosition = true;
orPr->Position = m_oBufferedStream.GetDouble();
orPr->Position = SerializeCommon::Round( g_dKoef_mm_to_hps * m_oBufferedStream.GetDouble());
}
break;
case c_oSerProp_rPrType::PositionHps:
{
orPr->bPosition = true;
orPr->Position = m_oBufferedStream.GetLong();
}
break;
case c_oSerProp_rPrType::FontHint:
@ -724,12 +735,12 @@ public:
{
Spacing oSpacing;
READ2_DEF(length, res, this->ReadSpacing, &oSpacing);
if(oSpacing.bLine || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
if(oSpacing.bLine || oSpacing.bLineTwips || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
{
pCStringWriter->WriteString(std::wstring(L"<w:spacing"));
BYTE bLineRule = linerule_Auto;
//проверяется bLine, а не bLineRule чтобы всегда писать LineRule, если есть w:line
if(oSpacing.bLine)
if(oSpacing.bLine || oSpacing.bLineTwips)
{
if(oSpacing.bLineRule)
bLineRule = oSpacing.LineRule;
@ -757,10 +768,13 @@ public:
}
pCStringWriter->WriteString(sLine);
}
else if(oSpacing.bLineTwips)
{
pCStringWriter->WriteString(L" w:line=\"" + std::to_wstring(oSpacing.LineTwips) + L"\"");
}
if(oSpacing.bAfter)
{
long After = SerializeCommon::Round( g_dKoef_mm_to_twips * oSpacing.After);
std::wstring sAfter = L" w:after=\"" + std::to_wstring(After) + L"\"";
std::wstring sAfter = L" w:after=\"" + std::to_wstring(oSpacing.After) + L"\"";
pCStringWriter->WriteString(sAfter);
}
if(oSpacing.bAfterAuto)
@ -772,8 +786,7 @@ public:
}
if(oSpacing.bBefore)
{
long Before = SerializeCommon::Round( g_dKoef_mm_to_twips * oSpacing.Before);
std::wstring sBefore = L" w:before=\"" + std::to_wstring(Before) + L"\"";
std::wstring sBefore = L" w:before=\"" + std::to_wstring(oSpacing.Before) + L"\"";
pCStringWriter->WriteString(sBefore);
}
if(oSpacing.bBeforeAuto)
@ -817,7 +830,6 @@ public:
for(size_t i = 0; i < nLen; ++i)
{
Tab& oTab = oTabs.m_aTabs[i];
long nTab = SerializeCommon::Round( g_dKoef_mm_to_twips * oTab.Pos);
std::wstring sVal;
switch(oTab.Val)
{
@ -826,7 +838,7 @@ public:
case g_tabtype_clear: sVal = L"clear"; break;
default: sVal = L"left"; break;
}
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"");
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(oTab.Pos) + L"\"");
if (oTab.bLeader)
{
std::wstring sLeader;
@ -938,6 +950,11 @@ public:
pCStringWriter->WriteString(L" w:left=\"" + std::to_wstring(nIndLeft) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_LeftTwips:
{
pCStringWriter->WriteString(L" w:left=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_Right:
{
double dIndRight = m_oBufferedStream.GetDouble();
@ -946,18 +963,34 @@ public:
pCStringWriter->WriteString(L" w:right=\"" + std::to_wstring(nIndRight) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_RightTwips:
{
pCStringWriter->WriteString(L" w:right=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_FirstLine:
{
double dIndFirstLine = m_oBufferedStream.GetDouble();
long nIndFirstLine = SerializeCommon::Round(dIndFirstLine * g_dKoef_mm_to_twips);
std::wstring sIndFirstLine;
if(nIndFirstLine > 0)
if(nIndFirstLine >= 0)
sIndFirstLine = L" w:firstLine =\"" + std::to_wstring(nIndFirstLine) + L"\"";
else
sIndFirstLine = L" w:hanging=\"" + std::to_wstring(-nIndFirstLine) + L"\"";
pCStringWriter->WriteString(sIndFirstLine);
break;
}
case c_oSerProp_pPrType::Ind_FirstLineTwips:
{
long nIndFirstLine = m_oBufferedStream.GetLong();
std::wstring sIndFirstLine;
if(nIndFirstLine >= 0)
sIndFirstLine = L" w:firstLine =\"" + std::to_wstring(nIndFirstLine) + L"\"";
else
sIndFirstLine = L" w:hanging=\"" + std::to_wstring(-nIndFirstLine) + L"\"";
pCStringWriter->WriteString(sIndFirstLine);
break;
}
default:
res = c_oSerConstants::ReadUnknown;
break;
@ -974,17 +1007,29 @@ public:
pSpacing->bLine = true;
pSpacing->Line = m_oBufferedStream.GetDouble();
break;
case c_oSerProp_pPrType::Spacing_LineTwips:
pSpacing->bLineTwips = true;
pSpacing->LineTwips = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_LineRule:
pSpacing->bLineRule = true;
pSpacing->LineRule = m_oBufferedStream.GetUChar();
break;
case c_oSerProp_pPrType::Spacing_Before:
pSpacing->bBefore = true;
pSpacing->Before = m_oBufferedStream.GetDouble();
pSpacing->Before = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
break;
case c_oSerProp_pPrType::Spacing_BeforeTwips:
pSpacing->bBefore = true;
pSpacing->Before = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_After:
pSpacing->bAfter = true;
pSpacing->After = m_oBufferedStream.GetDouble();
pSpacing->After = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
break;
case c_oSerProp_pPrType::Spacing_AfterTwips:
pSpacing->bAfter = true;
pSpacing->After = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_BeforeAuto:
pSpacing->bBeforeAuto = true;
@ -1021,7 +1066,9 @@ public:
if(c_oSerProp_pPrType::Tab_Item_Val == type)
poTabItem->Val = m_oBufferedStream.GetUChar();
else if(c_oSerProp_pPrType::Tab_Item_Pos == type)
poTabItem->Pos = m_oBufferedStream.GetDouble();
poTabItem->Pos = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
else if(c_oSerProp_pPrType::Tab_Item_PosTwips == type)
poTabItem->Pos = m_oBufferedStream.GetLong();
else if(c_oSerProp_pPrType::Tab_Item_Leader == type)
{
poTabItem->bLeader = true;
@ -1114,12 +1161,22 @@ public:
else if( c_oSerBorderType::Space == type )
{
odocBorder->bSpace = true;
odocBorder->Space = m_oBufferedStream.GetDouble();
odocBorder->Space = SerializeCommon::Round(g_dKoef_mm_to_pt * m_oBufferedStream.GetDouble());
}
else if( c_oSerBorderType::SpacePoint == type )
{
odocBorder->bSpace = true;
odocBorder->Space = m_oBufferedStream.GetLong();
}
else if( c_oSerBorderType::Size == type )
{
odocBorder->bSize = true;
odocBorder->Size = m_oBufferedStream.GetDouble();
odocBorder->Size = SerializeCommon::Round(g_dKoef_mm_to_eightpoint * m_oBufferedStream.GetDouble());
}
else if( c_oSerBorderType::Size8Point == type )
{
odocBorder->bSize = true;
odocBorder->Size = m_oBufferedStream.GetLong();
}
else if( c_oSerBorderType::Value == type )
{
@ -1375,15 +1432,28 @@ public:
int res = c_oSerConstants::ReadOk;
if( c_oSer_pgSzType::Orientation == type )
{
pSectPr->bOrientation = true;
pSectPr->cOrientation = m_oBufferedStream.GetUChar();
}
else if( c_oSer_pgSzType::W == type )
{
pSectPr->W = m_oBufferedStream.GetDouble();
pSectPr->bW = true;
pSectPr->W = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgSzType::WTwips == type )
{
pSectPr->bW = true;
pSectPr->W = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgSzType::H == type )
{
pSectPr->H = m_oBufferedStream.GetDouble();
pSectPr->bH = true;
pSectPr->H = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgSzType::HTwips == type )
{
pSectPr->bH = true;
pSectPr->H = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -1395,29 +1465,63 @@ public:
int res = c_oSerConstants::ReadOk;
if( c_oSer_pgMarType::Left == type )
{
pSectPr->Left = m_oBufferedStream.GetDouble();
pSectPr->bLeft = true;
pSectPr->Left = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::LeftTwips == type )
{
pSectPr->bLeft = true;
pSectPr->Left = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Top == type )
{
pSectPr->Top = m_oBufferedStream.GetDouble();
pSectPr->bTop = true;
pSectPr->Top = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::TopTwips == type )
{
pSectPr->bTop = true;
pSectPr->Top = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Right == type )
{
pSectPr->Right = m_oBufferedStream.GetDouble();
pSectPr->bRight = true;
pSectPr->Right = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::RightTwips == type )
{
pSectPr->bRight = true;
pSectPr->Right = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Bottom == type )
{
pSectPr->Bottom = m_oBufferedStream.GetDouble();
pSectPr->bBottom = true;
pSectPr->Bottom = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::BottomTwips == type )
{
pSectPr->bBottom = true;
pSectPr->Bottom = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Header == type )
{
pSectPr->bHeader = true;
pSectPr->Header = m_oBufferedStream.GetDouble();
pSectPr->Header = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::HeaderTwips == type )
{
pSectPr->bHeader = true;
pSectPr->Header = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Footer == type )
{
pSectPr->bFooter = true;
pSectPr->Footer = m_oBufferedStream.GetDouble();
pSectPr->Footer = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::FooterTwips == type )
{
pSectPr->bFooter = true;
pSectPr->Footer = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -1717,6 +1821,10 @@ public:
long nInd = SerializeCommon::Round( g_dKoef_mm_to_twips * dInd);
pWiterTblPr->TableInd = L"<w:tblInd w:w=\"" + std::to_wstring(nInd) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableIndTwips == type )
{
pWiterTblPr->TableInd = L"<w:tblInd w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableW == type )
{
docW odocW;
@ -1816,6 +1924,10 @@ public:
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * dSpacing);
pWiterTblPr->TableCellSpacing = L"<w:tblCellSpacing w:w=\"" + std::to_wstring(nSpacing) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableCellSpacingTwips == type )
{
pWiterTblPr->TableCellSpacing = L"<w:tblCellSpacing w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::tblCaption == type )
{
pWiterTblPr->Caption = m_oBufferedStream.GetString3(length);
@ -1960,6 +2072,10 @@ public:
pCStringWriter->WriteString(L" w:tblpX=\"" + std::to_wstring(nX) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpXTwips == type )
{
pCStringWriter->WriteString(L" w:tblpX=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpXSpec == type )
{
std::wstring sXml;
@ -1993,6 +2109,10 @@ public:
pCStringWriter->WriteString(L" w:tblpY=\"" + std::to_wstring(nY) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpYTwips == type )
{
pCStringWriter->WriteString(L" w:tblpY=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpYSpec == type )
{
std::wstring sXml;
@ -2056,7 +2176,7 @@ public:
if(true == orowPrAfterBefore.bGridAfter && orowPrAfterBefore.nGridAfter > 0 && false == orowPrAfterBefore.oAfterWidth.bW)
{
//ищем по tblGrid
if(orowPrAfterBefore.nGridAfter < m_aCurTblGrid.size())
if(orowPrAfterBefore.nGridAfter < (long)m_aCurTblGrid.size())
{
double nSumW = 0;
for(int i = 0; i < orowPrAfterBefore.nGridAfter; i++)
@ -2088,6 +2208,10 @@ public:
pCStringWriter->WriteString(L"<w:tblCellSpacing w:w=\"" + std::to_wstring(nSpacing) + L"\" w:type=\"dxa\"/>");
}
else if( c_oSerProp_rowPrType::TableCellSpacingTwips == type )
{
pCStringWriter->WriteString(L"<w:tblCellSpacing w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>");
}
else if( c_oSerProp_rowPrType::Height == type )
{
RowHeight val;
@ -2181,6 +2305,10 @@ public:
double dHeight = m_oBufferedStream.GetDouble();
pHeight->nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
}
else if( c_oSerProp_rowPrType::Height_ValueTwips == type )
{
pHeight->nHeight = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -2359,6 +2487,10 @@ public:
pCStringWriter->WriteString(L" w:leftFromText=\"" + std::to_wstring(nLeft) + L"\"");
}
else if (c_oSerPaddingType::leftTwips == type)
{
pCStringWriter->WriteString(L" w:leftFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::top == type)
{
double dTop = m_oBufferedStream.GetDouble();
@ -2366,6 +2498,10 @@ public:
pCStringWriter->WriteString(L" w:topFromText=\"" + std::to_wstring(nTop) + L"\"");
}
else if (c_oSerPaddingType::topTwips == type)
{
pCStringWriter->WriteString(L" w:topFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::right == type)
{
double dRight = m_oBufferedStream.GetDouble();
@ -2373,6 +2509,10 @@ public:
pCStringWriter->WriteString(L" w:rightFromText=\"" + std::to_wstring(nRight) + L"\"");
}
else if (c_oSerPaddingType::rightTwips == type)
{
pCStringWriter->WriteString(L" w:rightFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::bottom == type)
{
double dBottom = m_oBufferedStream.GetDouble();
@ -2380,6 +2520,10 @@ public:
pCStringWriter->WriteString(L" w:bottomFromText=\"" + std::to_wstring(nBottom) + L"\"");
}
else if (c_oSerPaddingType::bottomTwips == type)
{
pCStringWriter->WriteString(L" w:bottomFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -2598,7 +2742,7 @@ public:
if ( c_oSerNumTypes::Lvl == type )
{
docLvl* odocLvl = new docLvl();
odocLvl->ILvl = odocANum->Lvls.size();
odocLvl->ILvl = (long)odocANum->Lvls.size();
READ2_DEF(length, res, this->ReadLevel, odocLvl);
odocANum->Lvls.push_back(odocLvl);
}
@ -2832,7 +2976,8 @@ public:
}
else if(c_oSer_sts::Style_Default == type)
{
odocStyle->bDefault = (0 != m_oBufferedStream.GetUChar());
odocStyle->bDefault = true;
odocStyle->Default = m_oBufferedStream.GetBool();
}
else if(c_oSer_sts::Style_BasedOn == type)
{
@ -3295,10 +3440,12 @@ public:
{
double dDefTabStop = m_oBufferedStream.GetDouble();
long nDefTabStop = SerializeCommon::Round(dDefTabStop * g_dKoef_mm_to_twips);
std::wstring sXml;
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"" + std::to_wstring(nDefTabStop) + L"\"/>");
}
else if ( c_oSer_SettingsType::DefaultTabStopTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else if ( c_oSer_SettingsType::MathPr == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<m:mathPr>"));
@ -3583,6 +3730,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:interSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:interSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3615,6 +3766,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:intraSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:intraSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3628,6 +3783,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:lMargin m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:lMargin m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3679,6 +3838,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:postSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:postSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3692,6 +3855,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:preSp m:val=\"" + std::to_wstring(lVal)+ L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:preSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3705,6 +3872,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:rMargin m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:rMargin m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3735,6 +3906,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:wrapIndent m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:wrapIndent m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3893,7 +4068,7 @@ public:
oFile.WriteFile(pData, length);
oFile.CloseFile();
long lId;
unsigned int lId = 0;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::JsaProject.RelationType(), sJsaProject.GetPath(), L"", &lId);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(sJsaProject.GetExtention(false));
}
@ -3970,6 +4145,12 @@ public:
READ1_DEF(length, res, this->ReadMathArg, poResult);
m_oDocumentWriter.m_oContent.WriteString(std::wstring(_T("</m:oMath>")));
}
else if ( c_oSerParType::MRun == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:r>")));
READ1_DEF(length, res, this->ReadMathMRun, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:r>")));
}
else if ( c_oSerParType::Hyperlink == type )
{
CHyperlink oHyperlink;
@ -4520,7 +4701,7 @@ public:
READ1_DEF(length, res, this->ReadParagraphContent, NULL);
if (!pHyperlink->sLink.empty())
{
long rId;
unsigned int rId;
std::wstring sHref = XmlUtils::EncodeXmlString(pHyperlink->sLink);
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")), sHref, std::wstring(_T("External")), &rId);
pHyperlink->rId = L"rId" + std::to_wstring(rId);
@ -4592,6 +4773,12 @@ public:
READ1_DEF(length, res, this->ReadMathDelimiter, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:d>")));
}
else if ( c_oSer_OMathContentType::Del == type )
{
TrackRevision oTrackRevision;
READ1_DEF(length, res, this->ReadDelIns, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:del"));
}
else if ( c_oSer_OMathContentType::EqArr == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:eqArr>")));
@ -4616,6 +4803,12 @@ public:
READ1_DEF(length, res, this->ReadMathGroupChr, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:groupChr>")));
}
else if ( c_oSer_OMathContentType::Ins == type )
{
TrackRevision oTrackRevision;
READ1_DEF(length, res, this->ReadDelIns, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:ins"));
}
else if ( c_oSer_OMathContentType::LimLow == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:limLow>")));
@ -6871,7 +7064,7 @@ public:
std::wstring sNewImgRel = _T("media/") + sNewImgName;
sNewImgRel = XmlUtils::EncodeXmlString(sNewImgRel);
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")), sNewImgRel, std::wstring(), &rId);
odocImg.srId = L"rId" + std::to_wstring(rId);
//odocImg.srId = m_oMediaWriter.m_poDocumentRelsWriter->AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"), sNewImgRel, false);
@ -7132,6 +7325,10 @@ public:
pCStringWriter->WriteString(L"<w:gridCol w:w=\"" + std::to_wstring(ngridCol)+ L"\"/>");
}
else if( c_oSerDocTableType::tblGrid_ItemTwips == type )
{
pCStringWriter->WriteString(L"<w:gridCol w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong())+ L"\"/>");
}
else if( c_oSerDocTableType::tblGridChange == type )
{
TrackRevision oTrackRevision;
@ -7412,7 +7609,7 @@ public:
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
{
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
unsigned int rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
@ -7439,7 +7636,7 @@ public:
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels";
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath());
long rIdChart;
unsigned int rIdChart;
std::wstring bstrChartRelType = OOX::FileTypes::Chart.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartRelType, sRelsName, std::wstring(), &rIdChart);
@ -7472,22 +7669,42 @@ public:
else if ( c_oSerImageType2::DistL == type )
{
pDrawingProperty->bDistL = true;
pDrawingProperty->DistL = m_oBufferedStream.GetDouble();
pDrawingProperty->DistL = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistLEmu == type )
{
pDrawingProperty->bDistL = true;
pDrawingProperty->DistL = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistT == type )
{
pDrawingProperty->bDistT = true;
pDrawingProperty->DistT = m_oBufferedStream.GetDouble();
pDrawingProperty->DistT = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistTEmu == type )
{
pDrawingProperty->bDistT = true;
pDrawingProperty->DistT = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistR == type )
{
pDrawingProperty->bDistR = true;
pDrawingProperty->DistR = m_oBufferedStream.GetDouble();
pDrawingProperty->DistR = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistREmu == type )
{
pDrawingProperty->bDistR = true;
pDrawingProperty->DistR = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistB == type )
{
pDrawingProperty->bDistB = true;
pDrawingProperty->DistB = m_oBufferedStream.GetDouble();
pDrawingProperty->DistB = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistBEmu == type )
{
pDrawingProperty->bDistB = true;
pDrawingProperty->DistB = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::LayoutInCell == type )
{
@ -7727,22 +7944,42 @@ public:
if ( c_oSerEffectExtent::Left == type )
{
pDrawingProperty->bEffectExtentL = true;
pDrawingProperty->EffectExtentL = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentL = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::LeftEmu == type )
{
pDrawingProperty->bEffectExtentL = true;
pDrawingProperty->EffectExtentL = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Top == type )
{
pDrawingProperty->bEffectExtentT = true;
pDrawingProperty->EffectExtentT = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentT = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::TopEmu == type )
{
pDrawingProperty->bEffectExtentT = true;
pDrawingProperty->EffectExtentT = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Right == type )
{
pDrawingProperty->bEffectExtentR = true;
pDrawingProperty->EffectExtentR = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentR = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::RightEmu == type )
{
pDrawingProperty->bEffectExtentR = true;
pDrawingProperty->EffectExtentR = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Bottom == type )
{
pDrawingProperty->bEffectExtentB = true;
pDrawingProperty->EffectExtentB = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentB = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::BottomEmu == type )
{
pDrawingProperty->bEffectExtentB = true;
pDrawingProperty->EffectExtentB = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7755,12 +7992,22 @@ public:
if ( c_oSerExtent::Cx == type )
{
pDrawingProperty->bWidth = true;
pDrawingProperty->Width = m_oBufferedStream.GetDouble();
pDrawingProperty->Width = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerExtent::CxEmu == type )
{
pDrawingProperty->bWidth = true;
pDrawingProperty->Width = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerExtent::Cy == type )
{
pDrawingProperty->bHeight = true;
pDrawingProperty->Height = m_oBufferedStream.GetDouble();
pDrawingProperty->Height = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerExtent::CyEmu == type )
{
pDrawingProperty->bHeight = true;
pDrawingProperty->Height = (__int64)m_oBufferedStream.GetULong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7783,7 +8030,12 @@ public:
else if ( c_oSerPosHV::PosOffset == type )
{
pDrawingProperty->bPositionHPosOffset = true;
pDrawingProperty->PositionHPosOffset = m_oBufferedStream.GetDouble();
pDrawingProperty->PositionHPosOffset = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPosHV::PosOffsetEmu == type )
{
pDrawingProperty->bPositionHPosOffset = true;
pDrawingProperty->PositionHPosOffset = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPosHV::PctOffset == type )
{
@ -7811,7 +8063,12 @@ public:
else if ( c_oSerPosHV::PosOffset == type )
{
pDrawingProperty->bPositionVPosOffset = true;
pDrawingProperty->PositionVPosOffset = m_oBufferedStream.GetDouble();
pDrawingProperty->PositionVPosOffset = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPosHV::PosOffsetEmu == type )
{
pDrawingProperty->bPositionVPosOffset = true;
pDrawingProperty->PositionVPosOffset = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPosHV::PctOffset == type )
{
@ -7829,12 +8086,22 @@ public:
if ( c_oSerSimplePos::X == type )
{
pDrawingProperty->bSimplePosX = true;
pDrawingProperty->SimplePosX = m_oBufferedStream.GetDouble();
pDrawingProperty->SimplePosX = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerSimplePos::XEmu == type )
{
pDrawingProperty->bSimplePosX = true;
pDrawingProperty->SimplePosX = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerSimplePos::Y == type )
{
pDrawingProperty->bSimplePosY = true;
pDrawingProperty->SimplePosY = m_oBufferedStream.GetDouble();
pDrawingProperty->SimplePosY = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerSimplePos::YEmu == type )
{
pDrawingProperty->bSimplePosY = true;
pDrawingProperty->SimplePosY = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7930,12 +8197,22 @@ public:
if ( c_oSerPoint2D::X == type )
{
pWrapPoint->bX = true;
pWrapPoint->X = m_oBufferedStream.GetDouble();
pWrapPoint->X = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPoint2D::XEmu == type )
{
pWrapPoint->bX = true;
pWrapPoint->X = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPoint2D::Y == type )
{
pWrapPoint->bY = true;
pWrapPoint->Y = m_oBufferedStream.GetDouble();
pWrapPoint->Y = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPoint2D::YEmu == type )
{
pWrapPoint->bY = true;
pWrapPoint->Y = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -8546,7 +8823,7 @@ public:
m_oBufferedStream.Seek(nDocumentOffset);
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
long stamdartRId;
unsigned int stamdartRId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml", L"", &stamdartRId);
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", L"settings.xml", L"", &stamdartRId);
@ -8574,19 +8851,19 @@ public:
if(false == m_oFileWriter.m_oNumberingWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", L"numbering.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", L"/word", L"numbering.xml");
}
if(false == m_oFileWriter.m_oFootnotesWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", L"footnotes.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", L"/word", L"footnotes.xml");
}
if(false == m_oFileWriter.m_oEndnotesWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", L"endnotes.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml", L"/word", L"endnotes.xml");
}
@ -8595,7 +8872,7 @@ public:
Writers::HdrFtrItem* pHeader = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders[i];
if(false == pHeader->IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", pHeader->m_sFilename, std::wstring(), &rId);
pHeader->rId = L"rId" + std::to_wstring( rId );
@ -8607,7 +8884,7 @@ public:
Writers::HdrFtrItem* pFooter = m_oFileWriter.m_oHeaderFooterWriter.m_aFooters[i];
if(false == pFooter->IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", pFooter->m_sFilename, std::wstring(), &rId);
pFooter->rId = L"rId" + std::to_wstring( rId );
@ -8617,7 +8894,7 @@ public:
if(!oSettingsCustom.IsEmpty()){
std::wstring sFilename = m_oFileWriter.m_oCustomXmlWriter.WriteCustomXml(oSettingsCustom.GetSchemaUrl(), oSettingsCustom.ToXml());
std::wstring sRelsPath = L"../" + OOX::FileTypes::CustomXml.DefaultDirectory().GetPath() + L"/" + sFilename;
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::CustomXml.RelationType(), sRelsPath, L"", &rId);
}
@ -8638,19 +8915,19 @@ public:
if(false == oCommentsWriter.m_sComment.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", L"comments.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml", L"/word", L"comments.xml");
}
if(false == oCommentsWriter.m_sCommentExt.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", L"/word", L"commentsExtended.xml");
}
if(false == oCommentsWriter.m_sPeople.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/people", L"people.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml", L"/word", L"people.xml");
}

View File

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

View File

@ -36,17 +36,6 @@ namespace BinDocxRW
{
const double eps = 0.001;
const int Page_Width = 210;
const int Page_Height = 297;
const int X_Left_Margin = 30; // 3 cm
const int X_Right_Margin = 15; // 1.5 cm
const int Y_Bottom_Margin = 20; // 2 cm
const int Y_Top_Margin = 20; // 2 cm
const double Y_Default_Header = 12.5; // 1.25 cm расстояние от верха страницы до верха верхнего колонтитула
const double Y_Default_Footer = 12.5; // 1.25 cm расстояние от низа страницы до низа нижнего колонтитула
const int shd_Clear = 0;
const int shd_Nil = 1;
@ -311,7 +300,9 @@ extern int g_nCurFormatVersion;
RowBandSize = 15,
ColBandSize = 16,
tblCaption = 17,
tblDescription = 18
tblDescription = 18,
TableIndTwips = 19,
TableCellSpacingTwips = 20
};}
namespace c_oSer_tblpPrType{enum c_oSer_tblpPrType
{
@ -328,7 +319,9 @@ extern int g_nCurFormatVersion;
VertAnchor = 3,
TblpY = 4,
TblpYSpec = 5,
Paddings = 6
Paddings = 6,
TblpXTwips = 7,
TblpYTwips = 8
};}
namespace c_oSerProp_pPrType{enum c_oSerProp_pPrType
{
@ -365,7 +358,14 @@ extern int g_nCurFormatVersion;
numPr_Ins = 32,
pPrChange = 33,
outlineLvl = 34,
Tab_Item_Leader = 35
Tab_Item_Leader = 35,
Ind_LeftTwips = 36,
Ind_RightTwips = 37,
Ind_FirstLineTwips = 38,
Spacing_LineTwips = 39,
Spacing_BeforeTwips = 40,
Spacing_AfterTwips = 41,
Tab_Item_PosTwips = 42
};}
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
{
@ -406,7 +406,9 @@ extern int g_nCurFormatVersion;
Ins = 34,
rPrChange = 35,
MoveFrom = 36,
MoveTo = 37
MoveTo = 37,
SpacingTwips = 38,
PositionHps = 39
};}
namespace c_oSerProp_rowPrType{enum c_oSerProp_rowPrType
{
@ -427,7 +429,9 @@ extern int g_nCurFormatVersion;
TableHeader = 14,
Del = 15,
Ins = 16,
trPrChange = 17
trPrChange = 17,
TableCellSpacingTwips = 18,
Height_ValueTwips = 19
};}
namespace c_oSerProp_cellPrType{enum c_oSerProp_cellPrType
{
@ -499,8 +503,8 @@ extern int g_nCurFormatVersion;
MoveToRangeEnd = 21,
JsaProject = 22,
BookmarkStart = 23,
BookmarkEnd = 24
BookmarkEnd = 24,
MRun = 25
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -517,7 +521,8 @@ extern int g_nCurFormatVersion;
tblGridChange = 9,
Sdt = 10,
BookmarkStart = 11,
BookmarkEnd = 12
BookmarkEnd = 12,
tblGrid_ItemTwips = 13
};}
namespace c_oSerRunType{enum c_oSerRunType
{
@ -607,26 +612,37 @@ extern int g_nCurFormatVersion;
SizeRelV = 28,
Embedded = 29,
GraphicFramePr = 30,
DocPr = 31
DocPr = 31,
DistBEmu = 32,
DistLEmu = 33,
DistREmu = 34,
DistTEmu = 35
};}
namespace c_oSerEffectExtent{enum c_oSerEffectExtent
{
Left = 0,
Top = 1,
Right = 2,
Bottom = 3
Bottom = 3,
LeftEmu = 4,
TopEmu = 5,
RightEmu = 6,
BottomEmu = 7
};}
namespace c_oSerExtent{enum c_oSerExtent
{
Cx = 0,
Cy = 1
Cy = 1,
CxEmu = 2,
CyEmu = 3
};}
namespace c_oSerPosHV{enum c_oSerPosHV
{
RelativeFrom = 0,
Align = 1,
PosOffset = 2,
PctOffset = 3
PctOffset = 3,
PosOffsetEmu = 4
};}
namespace c_oSerSizeRelHV{enum c_oSerSizeRelHV
{
@ -636,7 +652,9 @@ extern int g_nCurFormatVersion;
namespace c_oSerSimplePos{enum c_oSerSimplePos
{
X = 0,
Y = 1
Y = 1,
XEmu = 2,
YEmu = 3
};}
namespace c_oSerWrapSquare{enum c_oSerWrapSquare
{
@ -645,20 +663,28 @@ extern int g_nCurFormatVersion;
DistR = 2,
DistB = 3,
WrapText = 4,
EffectExtent = 5
EffectExtent = 5,
DistLEmu = 6,
DistTEmu = 7,
DistREmu = 8,
DistBEmu = 9
};}
namespace c_oSerWrapThroughTight{enum c_oSerWrapThroughTight
{
DistL = 0,
DistR = 1,
WrapText = 2,
WrapPolygon = 3
WrapPolygon = 3,
DistLEmu = 4,
DistREmu = 5
};}
namespace c_oSerWrapTopBottom{enum c_oSerWrapTopBottom
{
DistT = 0,
DistB = 1,
EffectExtent = 2
EffectExtent = 2,
DistTEmu = 3,
DistBEmu = 4
};}
namespace c_oSerWrapPolygon{enum c_oSerWrapPolygon
{
@ -670,7 +696,9 @@ extern int g_nCurFormatVersion;
namespace c_oSerPoint2D{enum c_oSerPoint2D
{
X = 0,
Y = 1
Y = 1,
XEmu = 2,
YEmu = 3
};}
namespace c_oSerBorderType{enum c_oSerBorderType
{
@ -678,7 +706,9 @@ extern int g_nCurFormatVersion;
Space = 1,
Size = 2,
Value = 3,
ColorTheme = 4
ColorTheme = 4,
SpacePoint = 5,
Size8Point = 6
};}
namespace c_oSerShdType{enum c_oSerShdType
{
@ -691,7 +721,11 @@ extern int g_nCurFormatVersion;
left = 0,
top = 1,
right = 2,
bottom = 3
bottom = 3,
leftTwips = 4,
topTwips = 5,
rightTwips = 6,
bottomTwips = 7
};}
namespace c_oSerMarginsType{enum c_oSerMarginsType
{
@ -725,7 +759,9 @@ extern int g_nCurFormatVersion;
{
W = 0,
H = 1,
Orientation = 2
Orientation = 2,
WTwips = 3,
HTwips = 4
};}
namespace c_oSer_pgMarType{enum c_oSer_pgMarType
{
@ -734,7 +770,13 @@ extern int g_nCurFormatVersion;
Right = 2,
Bottom = 3,
Header = 4,
Footer = 5
Footer = 5,
LeftTwips = 6,
TopTwips = 7,
RightTwips = 8,
BottomTwips = 9,
HeaderTwips = 10,
FooterTwips = 11
};}
namespace c_oSer_ColorType{enum c_oSer_ColorType
{
@ -764,7 +806,9 @@ extern int g_nCurFormatVersion;
FootnotePr = 4,
EndnotePr = 5,
SdtGlobalColor = 6,
SdtGlobalShowHighlight = 7
SdtGlobalShowHighlight = 7,
Compat = 8,
DefaultTabStopTwips = 9
};}
namespace c_oSer_MathPrType{enum c_oSer_SettingsType
{
@ -859,7 +903,8 @@ extern int g_nCurFormatVersion;
namespace c_oSer_OMathBottomNodesValType{enum c_oSer_OMathBottomNodesValType
{
Val = 0,
AlnAt = 1
AlnAt = 1,
ValTwips = 2
};}
namespace c_oSer_OMathContentType{enum c_oSer_OMathContentType
{
@ -1150,6 +1195,13 @@ extern int g_nCurFormatVersion;
ColFirst = 3,
ColLast = 4
};}
namespace c_oSerCompat{enum c_oSerCompat
{
CompatSetting = 0,
CompatName = 1,
CompatUri = 2,
CompatValue = 3
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

View File

@ -148,15 +148,15 @@ namespace BinDocxRW
WriteThemeColor(c_oSerBorderType::ColorTheme, border.m_oColor, border.m_oThemeColor, border.m_oThemeTint, border.m_oThemeShade);
if(border.m_oSpace.IsInit())
{
m_oStream.WriteBYTE(c_oSerBorderType::Space);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(border.m_oSpace->ToMM());
m_oStream.WriteBYTE(c_oSerBorderType::SpacePoint);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(border.m_oSpace->GetValue());
}
if(border.m_oSz.IsInit())
{
m_oStream.WriteBYTE(c_oSerBorderType::Size);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(border.m_oSz->ToMM());
m_oStream.WriteBYTE(c_oSerBorderType::Size8Point);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(border.m_oSz->GetValue());
}
//Val
m_oStream.WriteBYTE(c_oSerBorderType::Value);
@ -330,70 +330,36 @@ namespace BinDocxRW
WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade);
}
void WriteDistance(const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistL,
const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistT,
const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistR,
const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistB)
{
//left
if(false != m_oDistL.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::left);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistL.get().ToMM());
}
//top
if(false != m_oDistT.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::top);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistT.get().ToMM());
}
//Right
if(false != m_oDistR.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::right);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistR.get().ToMM());
}
//bottom
if(false != m_oDistB.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::bottom);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistB.get().ToMM());
}
}
void WritePaddings(const nullable<SimpleTypes::CTwipsMeasure>& left, const nullable<SimpleTypes::CTwipsMeasure>& top,
const nullable<SimpleTypes::CTwipsMeasure>& right, const nullable<SimpleTypes::CTwipsMeasure>& bottom)
{
//left
if(left.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::left);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(left.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::leftTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(left->ToTwips());
}
//top
if(top.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::top);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(top.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::topTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(top->ToTwips());
}
//Right
if(right.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::right);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(right.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::rightTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(right->ToTwips());
}
//bottom
if(bottom.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::bottom);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(bottom.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::bottomTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(bottom->ToTwips());
}
}
void WriteFont(std::wstring& sFontName, BYTE bType, DocWrapper::FontProcessor& m_oFontProcessor)
@ -701,9 +667,9 @@ namespace BinDocxRW
//Spacing
if(false != rPr->m_oSpacing.IsInit() && false != rPr->m_oSpacing->m_oVal.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::Spacing);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(rPr->m_oSpacing->m_oVal->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::SpacingTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(rPr->m_oSpacing->m_oVal->ToTwips());
}
//DStrikeout
if(false != rPr->m_oDStrike.IsInit())
@ -729,9 +695,9 @@ namespace BinDocxRW
//Position
if(false != rPr->m_oPosition.IsInit() && false != rPr->m_oPosition->m_oVal.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::Position);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(rPr->m_oPosition->m_oVal->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::PositionHps);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(rPr->m_oPosition->m_oVal->ToHps());
}
//BoldCs
if(rPr->m_oBoldCs.IsInit())
@ -1066,29 +1032,29 @@ namespace BinDocxRW
//Left
if(false != Ind.m_oStart.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_Left);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Ind.m_oStart.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_LeftTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Ind.m_oStart.get().ToTwips());
}
//Right
if(false != Ind.m_oEnd.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_Right);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Ind.m_oEnd.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_RightTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Ind.m_oEnd.get().ToTwips());
}
//FirstLine
if(false != Ind.m_oFirstLine.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLine);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Ind.m_oFirstLine.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLineTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Ind.m_oFirstLine.get().ToTwips());
}
else if(false != Ind.m_oHanging.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLine);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble( -1 * Ind.m_oHanging.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLineTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG( -1 * Ind.m_oHanging.get().ToTwips());
}
}
void WriteSpacing(const ComplexTypes::Word::CSpacing& Spacing)
@ -1101,24 +1067,9 @@ namespace BinDocxRW
//Line
if(false != Spacing.m_oLine.IsInit())
{
const SimpleTypes::CSignedTwipsMeasure& oLine = Spacing.m_oLine.get();
double dLineMm = oLine.ToMm();
if(dLineMm < 0)
{
dLineMm = -dLineMm;
eLineSpacingRule = SimpleTypes::linespacingruleExact;
}
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_Line);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
if(SimpleTypes::linespacingruleAuto == eLineSpacingRule)
{
SimpleTypes::CSignedTwipsMeasure oTmp;oTmp.FromPoints(12);//240 twips
m_oBcw.m_oStream.WriteDouble(dLineMm / oTmp.ToMm());
}
else
{
m_oBcw.m_oStream.WriteDouble(dLineMm);
}
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_LineTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Spacing.m_oLine->ToTwips());
//Write LineRule
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_LineRule);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
@ -1138,9 +1089,9 @@ namespace BinDocxRW
}
if(false != Spacing.m_oBefore.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_Before);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Spacing.m_oBefore.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_BeforeTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Spacing.m_oBefore.get().ToTwips());
}
//After
if(Spacing.m_oAfterAutospacing.IsInit())
@ -1151,9 +1102,9 @@ namespace BinDocxRW
}
if(false != Spacing.m_oAfter.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_After);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Spacing.m_oAfter.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_AfterTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Spacing.m_oAfter.get().ToTwips());
}
}
void WriteTabs(const OOX::Logic::CTabs& Tab, const nullable<ComplexTypes::Word::CInd>& oInd)
@ -1197,9 +1148,9 @@ namespace BinDocxRW
//pos
if(false != TabItem.m_oPos.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Tab_Item_Pos);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(TabItem.m_oPos.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Tab_Item_PosTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(TabItem.m_oPos.get().ToTwips());
}
if(false != TabItem.m_oLeader.IsInit())
{
@ -1425,93 +1376,78 @@ namespace BinDocxRW
}
void WritePageSize(OOX::Logic::CSectionProperty* pSectPr)
{
double W = Page_Width;
double H = Page_Height;
BYTE Orientation = orientation_Portrait;
if(NULL != pSectPr && pSectPr->m_oPgSz.IsInit())
{
const ComplexTypes::Word::CPageSz& pSz = pSectPr->m_oPgSz.get();
if(pSz.m_oW.IsInit())
W = pSz.m_oW.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::WTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pSz.m_oW->ToTwips());
}
if(pSz.m_oH.IsInit())
H = pSz.m_oH.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::HTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pSz.m_oH->ToTwips());
}
if(pSz.m_oOrient.IsInit())
{
BYTE Orientation = orientation_Portrait;
switch(pSz.m_oOrient.get().GetValue())
{
case SimpleTypes::pageorientPortrait: Orientation = orientation_Portrait;break;
case SimpleTypes::pageorientLandscape: Orientation = orientation_Landscape;break;
default: break;
}
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::Orientation);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE(Orientation);
}
}
//W
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::W);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(W);
//H
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::H);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(H);
//Orientation
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::Orientation);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE(Orientation);
}
void WritePageMargin(OOX::Logic::CSectionProperty* pSectPr)
{
double H = Page_Height;
double L = X_Left_Margin;
double T = Y_Top_Margin;
double R = X_Right_Margin;
double B = Y_Bottom_Margin;
double Header = Y_Default_Header;
double Footer = Y_Default_Footer;
if(NULL != pSectPr && pSectPr->m_oPgSz.IsInit() && pSectPr->m_oPgMar.IsInit())
{
const ComplexTypes::Word::CPageSz& pSz = pSectPr->m_oPgSz.get();
if(pSz.m_oH.IsInit())
H = pSz.m_oH.get().ToMm();
const ComplexTypes::Word::CPageMar& pMar = pSectPr->m_oPgMar.get();
if(pMar.m_oLeft.IsInit())
L = pMar.m_oLeft.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::LeftTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oLeft->ToTwips());
}
if(pMar.m_oTop.IsInit())
T = pMar.m_oTop.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::TopTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oTop->ToTwips());
}
if(pMar.m_oRight.IsInit())
R = pMar.m_oRight.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::RightTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oRight->ToTwips());
}
if(pMar.m_oBottom.IsInit())
B = pMar.m_oBottom.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::BottomTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oBottom->ToTwips());
}
if(pMar.m_oHeader.IsInit())
Header = pMar.m_oHeader.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::HeaderTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oHeader->ToTwips());
}
if(pMar.m_oFooter.IsInit())
Footer = pMar.m_oFooter.get().ToMm();
}
//Left
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Left);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(L);
//Top
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Top);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(T);
//Right
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Right);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(R);
//Bottom
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Bottom);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(B);
//Header
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Header);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Header);
//Footer
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Footer);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Footer);
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::FooterTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oFooter->ToTwips());
}
}
}
void WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr, std::vector<ComplexTypes::Word::CHdrFtrRef*>& aRefs, bool bHdr)
{
@ -1816,11 +1752,8 @@ namespace BinDocxRW
if(tblPr.m_oTblInd->m_oW.IsInit() && false == tblPr.m_oTblInd->m_oW->IsPercent() &&
tblPr.m_oTblInd->m_oType.IsInit() && SimpleTypes::tblwidthDxa == tblPr.m_oTblInd->m_oType->GetValue())
{
SimpleTypes::CPoint oPoint;
oPoint.FromTwips(tblPr.m_oTblInd->m_oW->GetValue());
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableInd);
m_oBcw.m_oStream.WriteDouble(oPoint.ToMm());
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableIndTwips);
m_oBcw.m_oStream.WriteLONG(tblPr.m_oTblInd->m_oW->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
}
@ -1886,11 +1819,8 @@ namespace BinDocxRW
if(cs.m_oW.IsInit() && false == cs.m_oW->IsPercent() &&
cs.m_oType.IsInit() && SimpleTypes::tblwidthDxa == cs.m_oType->GetValue())
{
SimpleTypes::CPoint oPoint;
oPoint.FromTwips(cs.m_oW->GetValue());
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableCellSpacing);
m_oBcw.m_oStream.WriteDouble(oPoint.ToMm() * 2);//Умножаем на 2 из-за разного понимания cellSpacing
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableCellSpacingTwips);
m_oBcw.m_oStream.WriteLONG(cs.m_oW->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
}
@ -1948,9 +1878,9 @@ namespace BinDocxRW
}
if(pr.m_oTblpX.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpX);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pr.m_oTblpX->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpXTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pr.m_oTblpX->ToTwips());
}
if(pr.m_oTblpXSpec.IsInit())
{
@ -1966,9 +1896,9 @@ namespace BinDocxRW
}
if(pr.m_oTblpY.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpY);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pr.m_oTblpY->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpYTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pr.m_oTblpY->ToTwips());
}
if(pr.m_oTblpYSpec.IsInit())
{
@ -2035,12 +1965,9 @@ namespace BinDocxRW
if(cs.m_oW.IsInit() && false == cs.m_oW->IsPercent() &&
cs.m_oType.IsInit() && SimpleTypes::tblwidthDxa == cs.m_oType->GetValue())
{
SimpleTypes::CPoint oPoint;
oPoint.FromTwips(cs.m_oW->GetValue());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::TableCellSpacing);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPoint.ToMm() * 2);//Умножаем на 2 из-за разного понимания cellSpacing
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::TableCellSpacingTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(cs.m_oW->GetValue());
}
}
//Height
@ -2133,9 +2060,9 @@ namespace BinDocxRW
//Value
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::Height_Value);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(rowHeight.m_oVal->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::Height_ValueTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(rowHeight.m_oVal->ToTwips());
}
}
void WriteW(int nType, const ComplexTypes::Word::CTblWidth& tableW, bool bWrite2 = false)
@ -3505,6 +3432,14 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_m_r:
{
OOX::Logic::CMRun* pMRun = static_cast<OOX::Logic::CMRun*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MRun);
WriteMathRunContent(pMRun);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
default:
break;
}
@ -4114,6 +4049,14 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_del:
{
OOX::Logic::CDel* pDel = static_cast<OOX::Logic::CDel*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::Del);
WriteDel(*pDel);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_m_eqArr:
{
OOX::Logic::CEqArr* pEqArr = static_cast<OOX::Logic::CEqArr*>(item);
@ -4166,6 +4109,14 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_ins:
{
OOX::Logic::CIns* pIns = static_cast<OOX::Logic::CIns*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::Ins);
WriteIns(*pIns);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_m_limLow:
{
OOX::Logic::CLimLow* pLimLow = static_cast<OOX::Logic::CLimLow*>(item);
@ -6117,27 +6068,28 @@ namespace BinDocxRW
}
if(pAnchor.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistL->GetValue());
}
if(pAnchor.m_oDistT.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistT);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistT->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistTEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistT->GetValue());
}
if(pAnchor.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistR->GetValue());
}
if(pAnchor.m_oDistB.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistB);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistB->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistBEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistB->GetValue());
}
if(pAnchor.m_oHidden.IsInit())
{
@ -6356,34 +6308,39 @@ namespace BinDocxRW
}
void WriteEffectExtent(const OOX::Drawing::CEffectExtent& oEffectExtent)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Left);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oL.ToMm());
int nCurPos = 0;
//document is corrupted if the value is greater INT32
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::LeftEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oL.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Top);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oT.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::TopEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oT.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Right);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oR.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::RightEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oR.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Bottom);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oB.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::BottomEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oB.ToEmu());
}
void WriteExtent(const ComplexTypes::Drawing::CPositiveSize2D& oExtent)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::Cx);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oExtent.m_oCx.ToMM());
int nCurPos = 0;
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::CxEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oExtent.m_oCx.GetValue());
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::Cy);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oExtent.m_oCy.ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::CyEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oExtent.m_oCy.GetValue());
}
void WritePositionH(const OOX::Drawing::CPosH& oPosH)
{
int nCurPos = 0;
if(oPosH.m_oRelativeFrom.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::RelativeFrom);
@ -6398,9 +6355,10 @@ namespace BinDocxRW
}
if(oPosH.m_oPosOffset.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffset);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPosH.m_oPosOffset->ToMM());
//document is corrupted if the value is greater INT32
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffsetEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPosH.m_oPosOffset->GetValue());
}
if(oPosH.m_oPctOffset.IsInit())
{
@ -6411,6 +6369,7 @@ namespace BinDocxRW
}
void WritePositionV(const OOX::Drawing::CPosV& oPosV)
{
int nCurPos = 0;
if(oPosV.m_oRelativeFrom.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::RelativeFrom);
@ -6425,9 +6384,9 @@ namespace BinDocxRW
}
if(oPosV.m_oPosOffset.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffset);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPosV.m_oPosOffset->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffsetEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPosV.m_oPosOffset->GetValue());
}
if(oPosV.m_oPctOffset.IsInit())
{
@ -6468,40 +6427,43 @@ namespace BinDocxRW
}
void WriteSimplePos(const ComplexTypes::Drawing::CPoint2D& oSimplePos)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::X);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oSimplePos.m_oX.ToMm());
int nCurPos = 0;
//document is corrupted if the value is greater INT32
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::XEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oSimplePos.m_oX.GetValue());
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::Y);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oSimplePos.m_oY.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::YEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oSimplePos.m_oY.GetValue());
}
void WriteWrapSquare(const OOX::Drawing::CWrapSquare& oWrapSquare)
{
int nCurPos = 0;
if(oWrapSquare.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistL->GetValue());
}
if(oWrapSquare.m_oDistT.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistT);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistT->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistTEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistT->GetValue());
}
if(oWrapSquare.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistR->GetValue());
}
if(oWrapSquare.m_oDistB.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistB);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistB->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistBEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistB->GetValue());
}
if(oWrapSquare.m_oWrapText.IsInit())
{
@ -6524,15 +6486,16 @@ namespace BinDocxRW
int nCurPos = 0;
if(oWrapThrough.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapThrough.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapThrough.m_oDistL->GetValue());
}
if(oWrapThrough.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapThrough.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapThrough.m_oDistR->GetValue());
}
if(oWrapThrough.m_oWrapText.IsInit())
{
@ -6555,15 +6518,16 @@ namespace BinDocxRW
int nCurPos = 0;
if(oWrapTight.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTight.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTight.m_oDistL->GetValue());
}
if(oWrapTight.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTight.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTight.m_oDistR->GetValue());
}
if(oWrapTight.m_oWrapText.IsInit())
{
@ -6586,23 +6550,23 @@ namespace BinDocxRW
int nCurPos = 0;
if(oWrapTopBottom.m_oDistT.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistT);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTopBottom.m_oDistT->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistTEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTopBottom.m_oDistT->GetValue());
}
if(oWrapTopBottom.m_oDistB.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistB);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTopBottom.m_oDistB->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistBEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTopBottom.m_oDistB->GetValue());
}
if(oWrapTopBottom.m_oEffectExtent.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::EffectExtent);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
WriteEffectExtent(oWrapTopBottom.m_oEffectExtent.get());
WriteEffectExtent(oWrapTopBottom.m_oEffectExtent.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
@ -6619,9 +6583,8 @@ namespace BinDocxRW
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapPolygon::Start);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
WritePoint2D(oWrapPath.m_oStart.get());
WritePoint2D(oWrapPath.m_oStart.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oWrapPath.m_arrLineTo.size() > 0)
@ -6648,14 +6611,15 @@ namespace BinDocxRW
}
void WritePoint2D(const ComplexTypes::Drawing::CPoint2D& oPoint2D)
{
//document is corrupted if the value is greater INT32
int nCurPos = 0;
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::X);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPoint2D.m_oX.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::XEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPoint2D.m_oX.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::Y);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPoint2D.m_oY.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::YEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPoint2D.m_oY.ToEmu());
}
void WriteDocTable(OOX::Logic::CTbl* tbl)
{
@ -6856,9 +6820,9 @@ namespace BinDocxRW
const ComplexTypes::Word::CTblGridCol& item = *grid.m_arrGridCol[i];
if(item.m_oW.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerDocTableType::tblGrid_Item);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(item.m_oW->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerDocTableType::tblGrid_ItemTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(item.m_oW->ToTwips());
}
}
if(grid.m_oTblGridChange.IsInit())
@ -7533,8 +7497,8 @@ namespace BinDocxRW
}
if(oSettings.m_oDefaultTabStop.IsInit() && oSettings.m_oDefaultTabStop->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::DefaultTabStop);
m_oBcw.m_oStream.WriteDouble(oSettings.m_oDefaultTabStop->m_oVal->ToMm());
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::DefaultTabStopTwips);
m_oBcw.m_oStream.WriteLONG(oSettings.m_oDefaultTabStop->m_oVal->ToTwips());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oSettings.m_oMathPr.IsInit())
@ -7563,6 +7527,12 @@ namespace BinDocxRW
NULL, &oSettings.m_oEndnotePr->m_oPos, &oSettings.m_oEndnotePr->m_arrEndnote);
m_oBcw.WriteItemEnd(nCurPos);
}
if(oSettings.m_oCompat.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::Compat);
WriteCompat(oSettings.m_oCompat.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oSettingsCustom.m_oSdtGlobalColor.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::SdtGlobalColor);
@ -7645,9 +7615,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::InterSp);
if (pInterSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pInterSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pInterSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7671,9 +7641,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::IntraSp);
if (pIntraSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pIntraSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pIntraSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7684,9 +7654,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::LMargin);
if (pLMargin->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pLMargin->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pLMargin->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7723,9 +7693,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::PostSp);
if (pPostSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pPostSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pPostSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7736,9 +7706,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::PreSp);
if (pPreSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pPreSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pPreSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7749,9 +7719,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::RMargin);
if (pRMargin->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pRMargin->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pRMargin->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7775,9 +7745,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::WrapIndent);
if (pWrapIndent->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pWrapIndent->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pWrapIndent->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7892,6 +7862,38 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBYTE(re_index[pFind->second.GetBYTECode()]);
}
};
void WriteCompat(const OOX::Settings::CCompat& oCompat)
{
int nCurPos = 0;
for(size_t i = 0; i < oCompat.m_arrCompatSettings.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSerCompat::CompatSetting);
WriteCompatSetting(*oCompat.m_arrCompatSettings[i]);
m_oBcw.WriteItemEnd(nCurPos);
}
}
void WriteCompatSetting(const OOX::Settings::CCompatSetting& oCompatSetting)
{
int nCurPos = 0;
if(oCompatSetting.m_sName.IsInit())
{
nCurPos = m_oBcw.WriteItemStart (c_oSerCompat::CompatName);
m_oBcw.m_oStream.WriteStringW3(oCompatSetting.m_sName.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oCompatSetting.m_sUri.IsInit())
{
nCurPos = m_oBcw.WriteItemStart (c_oSerCompat::CompatUri);
m_oBcw.m_oStream.WriteStringW3(oCompatSetting.m_sUri.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oCompatSetting.m_sVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart (c_oSerCompat::CompatValue);
m_oBcw.m_oStream.WriteStringW3(oCompatSetting.m_sVal.get());
m_oBcw.WriteItemEnd(nCurPos);
}
}
};
class BinaryNotesTableWriter
{

View File

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

View File

@ -196,7 +196,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
bool bValidFormat = false;
std::wstring sSignature(g_sFormatSignature);
int nSigLength = (int)sSignature.length();
if(nBase64DataSize > nSigLength)
if((int)nBase64DataSize > nSigLength)
{
std::string sCurSig((char*)pBase64Data, nSigLength);
if(sSignature == std::wstring(sCurSig.begin(), sCurSig.end()))

View File

@ -85,7 +85,7 @@ namespace BinXlsxRW{
sMediaPath = pathMediaDir.GetPath();
sEmbedPath = pathEmbedDir.GetPath();
}
int CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
_UINT32 CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
{
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
@ -100,7 +100,7 @@ namespace BinXlsxRW{
BinXlsxRW::BinaryFileReader oBinaryFileReader;
return oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
}
int CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
_UINT32 CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
{
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
@ -136,7 +136,7 @@ namespace BinXlsxRW{
oOfficeDrawingConverter.SetFontPicker(pFontPicker);
BinXlsxRW::BinaryFileWriter oBinaryFileWriter(fp);
int result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
_UINT32 result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
RELEASEOBJECT(pFontPicker);
return result;
@ -186,7 +186,7 @@ namespace BinXlsxRW{
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
unsigned int rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);

View File

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

View File

@ -55,10 +55,6 @@
8A404FD5208A01CE00F2D5CF /* FileDownloader_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */; };
8AB24BFD213004E400E80DDD /* CustormXmlWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */; };
8AB24BFE213004E400E80DDD /* CustormXmlWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */; };
8AC6D2052130146000D9C0F1 /* xmlutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AC6D2042130146000D9C0F1 /* xmlutils.h */; };
8AC6D2092130146800D9C0F1 /* xmllight_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AC6D2062130146800D9C0F1 /* xmllight_private.h */; };
8AC6D20A2130146800D9C0F1 /* xmldom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AC6D2072130146800D9C0F1 /* xmldom.cpp */; };
8AC6D20B2130146800D9C0F1 /* xmllight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AC6D2082130146800D9C0F1 /* xmllight.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -111,10 +107,6 @@
8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader_private.h; path = ../../../Common/FileDownloader/FileDownloader_private.h; sourceTree = "<group>"; };
8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustormXmlWriter.cpp; sourceTree = "<group>"; };
8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustormXmlWriter.h; sourceTree = "<group>"; };
8AC6D2042130146000D9C0F1 /* xmlutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xmlutils.h; path = ../../../DesktopEditor/xml/include/xmlutils.h; sourceTree = "<group>"; };
8AC6D2062130146800D9C0F1 /* xmllight_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xmllight_private.h; path = ../../../DesktopEditor/xml/src/xmllight_private.h; sourceTree = "<group>"; };
8AC6D2072130146800D9C0F1 /* xmldom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = xmldom.cpp; path = ../../../DesktopEditor/xml/src/xmldom.cpp; sourceTree = "<group>"; };
8AC6D2082130146800D9C0F1 /* xmllight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = xmllight.cpp; path = ../../../DesktopEditor/xml/src/xmllight.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -147,7 +139,6 @@
17E17EDE1AC453F800BEA2EA /* ASCOfficeDocxFile2Lib */ = {
isa = PBXGroup;
children = (
8AC6D2032130145600D9C0F1 /* XmlUtils */,
17E17F4D1AC454E200BEA2EA /* Common */,
17E17F1A1AC4549B00BEA2EA /* XlsxSerializerCom */,
17E17F0D1AC4546100BEA2EA /* DocWrapper */,
@ -267,17 +258,6 @@
name = BinWriter;
sourceTree = "<group>";
};
8AC6D2032130145600D9C0F1 /* XmlUtils */ = {
isa = PBXGroup;
children = (
8AC6D2072130146800D9C0F1 /* xmldom.cpp */,
8AC6D2062130146800D9C0F1 /* xmllight_private.h */,
8AC6D2082130146800D9C0F1 /* xmllight.cpp */,
8AC6D2042130146000D9C0F1 /* xmlutils.h */,
);
name = XmlUtils;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@ -302,9 +282,7 @@
17C1FEAD1ACC42C4006B99B3 /* ChartWriter.h in Headers */,
17C1FEAE1ACC42C4006B99B3 /* DocumentRelsWriter.h in Headers */,
17C1FEAF1ACC42C4006B99B3 /* CommentsWriter.h in Headers */,
8AC6D2052130146000D9C0F1 /* xmlutils.h in Headers */,
69F181AF1C77274E00B2952B /* FileDownloader.h in Headers */,
8AC6D2092130146800D9C0F1 /* xmllight_private.h in Headers */,
17C1FEB01ACC42C4006B99B3 /* BinaryCommonReader.h in Headers */,
17C1FEB11ACC42C4006B99B3 /* Common.h in Headers */,
8A404FD5208A01CE00F2D5CF /* FileDownloader_private.h in Headers */,
@ -381,14 +359,12 @@
17C1FE981ACC42C4006B99B3 /* CSVReader.cpp in Sources */,
17C1FE991ACC42C4006B99B3 /* DocxSerializer.cpp in Sources */,
17C1FE9A1ACC42C4006B99B3 /* CommonWriter.cpp in Sources */,
8AC6D20B2130146800D9C0F1 /* xmllight.cpp in Sources */,
17C1FE9B1ACC42C4006B99B3 /* CSVWriter.cpp in Sources */,
69414A301CB51666003E771B /* ChartWriter.cpp in Sources */,
6967917E1D9E8AEE002CA4BA /* BinWriters.cpp in Sources */,
69BBDF251F0B8AAC00EB1BF7 /* FileDownloader_mac.mm in Sources */,
17C1FE9C1ACC42C4006B99B3 /* XlsxSerializer.cpp in Sources */,
690FE0851E9BBD68004B26D0 /* Readers.cpp in Sources */,
8AC6D20A2130146800D9C0F1 /* xmldom.cpp in Sources */,
17C1FE9D1ACC42C4006B99B3 /* FontProcessor.cpp in Sources */,
8A404FD3208A01AF00F2D5CF /* FileDownloader.cpp in Sources */,
);
@ -407,18 +383,11 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
NODOCX,
_USE_XMLLITE_READER_,
USE_LITE_READER,
USE_ATL_CSTRING,
USE_AVSOFFICESTUDIO_XMLUTILS,
SOLUTION_ASCOFFICEDOCXFILE2,
_USE_LIBXML2_READER_,
LIBXML_READER_ENABLED,
DONT_WRITE_EMBEDDED_FONTS,
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
@ -446,18 +415,11 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
NODOCX,
_USE_XMLLITE_READER_,
USE_LITE_READER,
USE_ATL_CSTRING,
USE_AVSOFFICESTUDIO_XMLUTILS,
SOLUTION_ASCOFFICEDOCXFILE2,
_USE_LIBXML2_READER_,
LIBXML_READER_ENABLED,
DONT_WRITE_EMBEDDED_FONTS,
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;

View File

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

View File

@ -408,7 +408,7 @@ std::wstring oox2odf_converter::Impl::replace_arguments(boost::wsmatch const &
{
std::wstring out;
int sz = what.size();
size_t sz = what.size();
if (what[1].matched)
{
@ -465,6 +465,10 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
//SUBTOTAL(109,Expense31[Amount])
XmlUtils::replace_all( res, L"[", L"KVADRATIN");
XmlUtils::replace_all( res, L"]", L"KVADRATOUT");
if (res1 == res)
{
XmlUtils::replace_all( res1, L"KAVYCHKA", L"\""); //IMCONJUGATE_emb.xlsx
@ -568,7 +572,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
boost::algorithm::split(distance_inp,expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (int i = 0; i < distance_inp.size(); i++)
for (size_t i = 0; i < distance_inp.size(); i++)
{
std::wstring sheet;
std::vector<std::wstring> range;
@ -576,7 +580,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
boost::algorithm::split(range, distance_inp[i], boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
for (int j = 0 ; j < range.size(); j++)
for (size_t j = 0 ; j < range.size(); j++)
{
int pos = range[j].find('!');
if (0 <= pos)
@ -588,7 +592,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring cells_out;
for (int c = 0; c < cells.size(); c++)
for (size_t c = 0; c < cells.size(); c++)
{
if (!sheet.empty())
cells_out += sheet + L".";
@ -607,7 +611,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring result;
for (int i = 0 ; i < distance_out.size(); i++)
for (size_t i = 0 ; i < distance_out.size(); i++)
{
result += distance_out[i];
result += L" ";
@ -743,7 +747,7 @@ int oox2odf_converter::get_count_value_points(std::wstring expr)
XmlUtils::replace_all( expr, L")", L"");
boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (long i=0; i < splitted.size(); i++)
for (size_t i=0; i < splitted.size(); i++)
{
int res = splitted[i].find(L"!");
if (res > 0) splitted[i] = splitted[i].substr(res+1, splitted[i].size()-res);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -128,63 +128,14 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
void text_forms_context::start_element (int type)
{
current_state_.clear();
current_state_.type = type;
}
void text_forms_context::set_id (const std::wstring& id)
{
current_state_.id = id;
}
void text_forms_context::set_name (const std::wstring& name)
{
current_state_.name = name;
}
void text_forms_context::set_label (const std::wstring& label)
{
current_state_.label = label;
}
void text_forms_context::set_uuid (const std::wstring& uuid)
{
current_state_.uuid = uuid;
}
void text_forms_context::set_value (const std::wstring &value)
{
current_state_.value = value;
}
void text_forms_context::set_element(odf_reader::form_element *elm)
{
current_state_.element = elm;
}
void text_forms_context::end_element ()
{
mapElements_.insert( std::make_pair(current_state_.id, current_state_));
current_state_.clear();
}
text_forms_context::_state& text_forms_context::get_state_element (std::wstring id)
{
std::map<std::wstring, _state>::iterator it = mapElements_.find(id);
if (it != mapElements_.end())
{
return it->second;
}
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
in_table_content_ (false),
@ -195,7 +146,6 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
new_list_style_number_ (0),
current_margin_left_ (0),
is_rtl_ (false),
is_paragraph_keep_ (false),
is_delete_text_ (false),
delayed_converting_ (false),
process_headers_footers_ (false),
@ -247,14 +197,14 @@ std::wstring styles_map::name(const std::wstring & Name, odf_types::style_family
}
void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
{
if (!in_run_)
if (!state_.in_run_)
{
in_run_ = true;
state_.in_run_ = true;
output_stream() << L"<w:r>";
if (!text_properties_stack_.empty() || parenStyleId.length() > 0)
if (!state_.text_properties_stack_.empty() || parenStyleId.length() > 0)
{
if (!text_properties_stack_.empty())
if (!state_.text_properties_stack_.empty())
{
odf_reader::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start();
@ -272,36 +222,36 @@ void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
void docx_conversion_context::start_paragraph(bool is_header)
{
if (in_paragraph_)
if (state_.in_paragraph_)
finish_paragraph();
output_stream() << L"<w:p>";
in_header_ = is_header;
in_paragraph_ = true;
is_rtl_ = false;
state_.in_paragraph_ = true;
start_changes();
}
void docx_conversion_context::finish_paragraph()
{
if (in_paragraph_)
if (state_.in_paragraph_)
{
end_changes();
output_stream() << L"</w:p>";
}
in_paragraph_ = false;
in_header_ = false;
is_paragraph_keep_ = false;
in_header_ = false;
state_.is_paragraph_keep_ = false;
state_.in_paragraph_ = false;
}
void docx_conversion_context::finish_run()
{
if (false == in_run_) return;
if (false == state_.in_run_) return;
if (get_comments_context().state() == 4)
{
@ -309,7 +259,7 @@ void docx_conversion_context::finish_run()
get_comments_context().state(0);
}
output_stream() << L"</w:r>";
in_run_ = false;
state_.in_run_ = false;
if (get_comments_context().state() == 2)
{
@ -631,6 +581,27 @@ oox_chart_context & docx_conversion_context::current_chart()
throw std::runtime_error("internal error");
}
}
void docx_conversion_context::reset_context_state()
{
keep_state_.push_back(state_);
state_.in_paragraph_ = false;
state_.in_run_ = false;
state_.is_paragraph_keep_ = false;
state_.drawing_text_props_.clear();
state_.text_properties_stack_.clear();
get_styles_context().text_style_ext().clear();
}
void docx_conversion_context::back_context_state()
{
state_ = keep_state_.back();
keep_state_.pop_back();
get_styles_context().text_style_ext().clear();
}
void docx_conversion_context::add_new_run(std::wstring parentStyleId)
{
finish_run();
@ -1046,13 +1017,36 @@ void docx_conversion_context::process_styles()
_Wostream << L"<w:pPrDefault>";
if ( odf_reader::style_content * content = defaultParStyle->content())
{
if (content->get_style_paragraph_properties())
{
if(content->get_style_paragraph_properties()->content_.fo_background_color_)
{
odf_types::background_color color = *content->get_style_paragraph_properties()->content_.fo_background_color_;
if ((color.get_type() != odf_types::background_color::Transparent &&
color.get_color() == odf_types::color(L"ffffff")) ||
(color.get_type() == odf_types::background_color::Transparent))
{
content->get_style_paragraph_properties()->content_.fo_background_color_ = boost::none;
}
}
}
get_styles_context().start_process_style(defaultParStyle);
content->docx_convert(*this);
get_styles_context().end_process_style();
}
_Wostream << L"</w:pPrDefault>";
}
if (odf_reader::style_instance * defaultParStyle = styles.style_default_by_type(odf_types::style_family::Text))
{
_Wostream << L"<w:rPrDefault>";
if ( odf_reader::style_content * content = defaultParStyle->content())
{
get_styles_context().start_process_style(defaultParStyle);
content->docx_convert(*this);
get_styles_context().end_process_style();
}
_Wostream << L"</w:rPrDefault>";
}
_Wostream << L"</w:docDefaults>";
for (size_t i = 0; i < arStyles.size(); i++)
@ -1100,7 +1094,7 @@ void docx_conversion_context::process_styles()
if (odf_reader::style_content * content = arStyles[i]->content())
{
get_tabs_context().clear();
odf_reader::calc_tab_stops(arStyles[i].get(), get_tabs_context());
calc_tab_stops(arStyles[i].get(), get_tabs_context());
get_styles_context().start_process_style(arStyles[i].get());
content->docx_convert(*this, true);
@ -1352,22 +1346,22 @@ bool docx_conversion_context::in_automatic_style()
void docx_conversion_context::push_text_properties(const odf_reader::style_text_properties * TextProperties)
{
text_properties_stack_.push_back(TextProperties);
state_.text_properties_stack_.push_back(TextProperties);
}
void docx_conversion_context::pop_text_properties()
{
text_properties_stack_.pop_back();
state_.text_properties_stack_.pop_back();
}
odf_reader::style_text_properties_ptr docx_conversion_context::current_text_properties()
{
odf_reader::style_text_properties_ptr cur = boost::make_shared<odf_reader::style_text_properties>();
for (size_t i = 0; i < text_properties_stack_.size(); i++)
for (size_t i = 0; i < state_.text_properties_stack_.size(); i++)
{
if (text_properties_stack_[i])
cur->content().apply_from( text_properties_stack_[i]->content() );
if (state_.text_properties_stack_[i])
cur->content().apply_from( state_.text_properties_stack_[i]->content() );
}
return cur;
}
@ -1575,7 +1569,7 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
start_automatic_style(id);
odf_reader::calc_tab_stops(styleInst, get_tabs_context());
calc_tab_stops(styleInst, get_tabs_context());
//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
odf_reader::paragraph_format_properties properties = odf_reader::calc_paragraph_properties_content(styleInst);
@ -1767,6 +1761,11 @@ void docx_conversion_context::serialize_list_properties(std::wostream & strm)
}
}
void docx_conversion_context::set_drawing_text_props (const std::wstring &props)
{
get_styles_context().text_style_ext() = props;
}
void docx_conversion_context::add_delayed_element(odf_reader::office_element * Elm)
{
delayed_elements_.push_back(Elm);
@ -1942,7 +1941,7 @@ void docx_conversion_context::start_text_changes (const std::wstring &id)
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state_add));
if (in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
if (state_.in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
{
map_changes_iterator it = map_current_changes_.find(id);
text_tracked_context::_state &state = it->second;
@ -2114,7 +2113,7 @@ void docx_conversion_context::end_text_changes (const std::wstring &id)
if (state.active)
{
if (in_paragraph_)
if (state_.in_paragraph_)
finish_run();
if (state.type == 1) output_stream() << L"</w:ins>";

View File

@ -572,47 +572,6 @@ private:
std::map<std::wstring, _state> mapChanges_;
};
class text_forms_context
{
public:
struct _state
{
std::wstring id;
std::wstring name;
int type = 0; //enum?
std::wstring label;
std::wstring uuid;
std::wstring value;
odf_reader::form_element* element = NULL;
void clear()
{
type = 0;
id.clear();
name.clear();
label.clear();
value.clear();
uuid.clear();
element = NULL;
}
};
text_forms_context(){}
void start_element (int type);
void set_id (const std::wstring& id);
void set_name (const std::wstring& name);
void set_label (const std::wstring& label);
void set_uuid (const std::wstring& uuid);
void set_value (const std::wstring& value);
void set_element(odf_reader::form_element *elm);
void end_element ();
_state& get_state_element (std::wstring id);
private:
_state current_state_;
std::map<std::wstring, _state> mapElements_;
};
class table_content_context
{
public:
@ -797,9 +756,7 @@ public:
void add_element_to_run (std::wstring parenStyleId = _T(""));
void finish_run ();
void add_new_run (std::wstring parentStyleId = _T(""));
bool get_run_state () { return in_run_; }
void set_run_state (bool Val) { in_run_ = Val; }
void add_new_run (std::wstring parentStyleId = _T(""));
void start_paragraph (bool is_header = false);
void finish_paragraph ();
@ -807,10 +764,18 @@ public:
bool is_alphabetical_index () { return false == mapAlphabeticals.empty();}
bool is_table_content () { return in_table_content_; }
bool is_paragraph_header () { return in_header_; }
bool get_paragraph_state () { return in_paragraph_; }
void set_paragraph_state (bool val) { in_paragraph_ = val; }
bool get_paragraph_keep () { return is_paragraph_keep_;}
void set_paragraph_keep (bool val) { is_paragraph_keep_ = val; }
void reset_context_state();
void back_context_state();
bool get_run_state () { return state_.in_run_; }
void set_run_state (bool Val) { state_.in_run_ = Val; }
bool get_paragraph_state () { return state_.in_paragraph_; }
void set_paragraph_state (bool val) { state_.in_paragraph_ = val; }
bool get_paragraph_keep () { return state_.is_paragraph_keep_;}
void set_paragraph_keep (bool val) { state_.is_paragraph_keep_ = val; }
bool get_delete_text_state () { return is_delete_text_; }
void set_delete_text_state (bool Val) { is_delete_text_ = Val; }
@ -930,11 +895,13 @@ public:
section_context & get_section_context() { return section_context_; }
notes_context & get_notes_context() { return notes_context_; }
text_tracked_context& get_text_tracked_context(){ return text_tracked_context_; }
text_forms_context & get_forms_context() { return text_forms_context_; }
forms_context & get_forms_context() { return forms_context_; }
tabs_context & get_tabs_context() { return tabs_context_;}
table_content_context & get_table_content_context() { return table_content_context_;}
void set_drawing_text_props (const std::wstring &props);
void docx_convert_delayed ();
void add_delayed_element (odf_reader::office_element * Elm);
@ -975,10 +942,10 @@ public:
void add_alphabetical_index_text (odf_reader::office_element_ptr & elem);
void set_process_headers_footers(bool Val) { process_headers_footers_ = Val; }
headers_footers & get_headers_footers() { return headers_footers_; }
headers_footers & get_headers_footers() { return headers_footers_; }
header_footer_context & get_header_footer_context() { return header_footer_context_; }
drop_cap_context & get_drop_cap_context(){return drop_cap_context_;}
drop_cap_context & get_drop_cap_context() {return drop_cap_context_;}
styles_map styles_map_;
bool process_headers_footers_;
@ -990,6 +957,19 @@ public:
void add_jsaProject(const std::string &content);
private:
struct _context_state
{
bool in_paragraph_ = false;
bool in_run_ = false;
bool is_paragraph_keep_ = false;
std::wstring drawing_text_props_;
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
}state_;
std::vector<_context_state> keep_state_;
std::wstringstream document_xml_;
std::wstringstream styles_xml_;
std::wstringstream fontTable_xml_;
@ -1012,7 +992,7 @@ private:
header_footer_context header_footer_context_;
notes_context notes_context_;
text_tracked_context text_tracked_context_;
text_forms_context text_forms_context_;
forms_context forms_context_;
tabs_context tabs_context_;
table_content_context table_content_context_;
@ -1045,12 +1025,10 @@ private:
bool in_automatic_style_;
bool in_drawing_content_;
bool in_table_content_;
bool in_paragraph_;
bool in_run_;
bool in_header_;
bool is_delete_text_;
bool is_rtl_; // right-to-left
bool is_paragraph_keep_;
std::wstring current_alphabetic_index_;
int current_margin_left_;
@ -1059,7 +1037,6 @@ private:
std::vector<odf_reader::office_element*> delayed_elements_;
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций

View File

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

View File

@ -243,7 +243,7 @@ void customXml_files::write(const std::wstring & RootPath)
const std::wstring fileNameItem = std::wstring(L"item") + std::to_wstring(i+1) + L".xml";
const std::wstring fileNameProps = std::wstring(L"itemProps") + std::to_wstring(i+1) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/customXml/") + fileNameProps,
L"application/vnd.openxmlformats-officedocument.customXmlProperties+xml");
@ -280,7 +280,7 @@ void docx_charts_files::write(const std::wstring & RootPath)
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(count) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/word/charts/") + fileName, kWSConType);
package::simple_element(fileName, charts_[i]->str()).write(path);

View File

@ -98,7 +98,7 @@ double docx_table_state::get_current_cell_width()
{
//return columns_width_[current_table_column_];
double res = 0;
for (int i = 0; i < columns_spanned_num_ + 1; i++)
for (unsigned int i = 0; i < columns_spanned_num_ + 1; i++)
{
res += columns_width_[current_table_column_ + i];
}

View File

@ -101,6 +101,10 @@ std::wstring static get_default_file_name(RelsType type)
return L"video";
case typeAudio:
return L"audio";
case typeControl:
return L"control";
case typeControlProps:
return L"controlProps";
default:
return L"";
}
@ -180,6 +184,10 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
sub_path = L"embeddings/";
}
else if ( type == typeControlProps)
{
sub_path = L"ctrlProps/";
}
else
{
isMediaInternal = is_internal(href, odf_packet_);
@ -198,6 +206,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
else if ( type == typeSlide) number = count_slide + 1;
else if ( type == typeMsObject ||
type == typeOleObject) number = count_object + 1;
else if ( type == typeControl) number = count_control + 1;
else
number = items_.size() + 1;
@ -277,7 +286,19 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
isInternal = isMediaInternal;
return id;
}
std::wstring mediaitems::add_control_props(std::wstring & oox_target)
{
const bool isMediaInternal = true;
count_control++;
std::wstring rId = std::wstring(L"ctrlId") + std::to_wstring(count_control);
oox_target = std::wstring(L"ctrlProp") + std::to_wstring(count_control) + L".xml";
items_.push_back( item(L"", typeControlProps, oox_target, isMediaInternal, rId) );
return rId;
}
void mediaitems::dump_rels(rels & Rels)
{
for (size_t i = 0; i < items_.size(); i++)

View File

@ -52,6 +52,8 @@ public:
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
}
struct item
@ -82,10 +84,14 @@ public:
size_t count_shape;
size_t count_tables;
size_t count_object;
size_t count_activeX;
size_t count_control;
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);
std::wstring add_control_props (std::wstring & oox_target);
void dump_rels(rels & Rels);
items_array & items() { return items_; }
@ -102,6 +108,9 @@ public:
case typeAudio: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio";
case typeVideo: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video";
case typeSlide: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
case typeExternalLink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath";
case typeActiveX: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control";
case typeControlProps: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp";
default:
return L"";
}

View File

@ -171,7 +171,7 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
if (content_.dimension_ == L"y")
CP_XML_ATTR(L"val",L"l");// "b" | "l" | "r" | "t"// == bottom left right top
}
//oox_serialize_ln(_Wostream,content_.graphic_properties_);
//oox_serialize_ln(_Wostream, content_.graphic_properties_);
odf_reader::GetProperty(content_.properties_, L"num_format", strVal);
odf_reader::GetProperty(content_.properties_, L"link-data-style-to-source", boolVal);

View File

@ -318,7 +318,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
}
}
else if (values_[i].strRef_.present > 0 && !bLocalTable_)
else if (values_[i].strRef_.present && !bLocalTable_)
{
CP_XML_NODE(L"c:strRef")
{

View File

@ -42,7 +42,56 @@
#include "../odf/style_paragraph_properties.h"
namespace cpdoccore {
namespace oox
{
void forms_context::start_element (int type)
{
current_state_.clear();
current_state_.type = type;
}
void forms_context::set_id (const std::wstring& id)
{
current_state_.id = id;
}
void forms_context::set_name (const std::wstring& name)
{
current_state_.name = name;
}
void forms_context::set_label (const std::wstring& label)
{
current_state_.label = label;
}
void forms_context::set_uuid (const std::wstring& uuid)
{
current_state_.uuid = uuid;
}
void forms_context::set_value (const std::wstring &value)
{
current_state_.value = value;
}
void forms_context::set_element(odf_reader::form_element *elm)
{
current_state_.element = elm;
}
void forms_context::end_element ()
{
mapElements_.insert( std::make_pair(current_state_.id, current_state_));
current_state_.clear();
}
forms_context::_state& forms_context::get_state_element (std::wstring id)
{
std::map<std::wstring, _state>::iterator it = mapElements_.find(id);
if (it != mapElements_.end())
{
return it->second;
}
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
void tabs_context::reset()
{
for (size_t i = 0; i < tabs.size(); i++)
@ -149,7 +198,9 @@ std::wstringstream & styles_context::list_style()
void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId, std::wstring & strChange)
{
if (!text_style_.str().empty())
const std::wstring & text_style_str = text_style_.str();
if (!text_style_str.empty() || !text_style_ext_.empty())
{
CP_XML_WRITER(strm)
{
@ -159,14 +210,17 @@ void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstrin
{
CP_XML_STREAM() << L"<w:rStyle w:val=\"" << parenStyleId << L"\" />";
}
const std::wstring & test_str = text_style_.str();
CP_XML_STREAM() << test_str;
CP_XML_STREAM() << text_style_str;
if (!strChange.empty())//rPrChange
{
CP_XML_STREAM() << strChange;
strChange.clear();
}
if (!text_style_ext_.empty())
{
CP_XML_STREAM() << text_style_ext_;
}
}
}
}
@ -190,8 +244,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
}
}
}
namespace oox
{
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :
base_font_size_(12), fonts_container_(fonts), is_need_e_(false)
{

View File

@ -56,9 +56,55 @@ namespace odf_reader
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
class office_element;
class form_element;
typedef boost::shared_ptr<office_element> office_element_ptr;
};
namespace oox {
class forms_context
{
public:
struct _state
{
std::wstring id;
std::wstring name;
int type = 0; //enum?
std::wstring label;
std::wstring uuid;
std::wstring value;
odf_reader::form_element* element = NULL;
std::wstring ctrlPropId;
void clear()
{
type = 0;
id.clear();
name.clear();
label.clear();
value.clear();
uuid.clear();
ctrlPropId.clear();
element = NULL;
}
};
forms_context(){}
void start_element (int type);
void set_id (const std::wstring& id);
void set_name (const std::wstring& name);
void set_label (const std::wstring& label);
void set_uuid (const std::wstring& uuid);
void set_value (const std::wstring& value);
void set_element(odf_reader::form_element *elm);
void end_element ();
_state& get_state_element (std::wstring id);
private:
_state current_state_;
std::map<std::wstring, _state> mapElements_;
};
class tabs_context : boost::noncopyable
{
public:
@ -95,6 +141,7 @@ public:
std::wstring & extern_node(){return extern_node_;}
std::wstring & hlinkClick(){return hlinkClick_;}
std::wstring & text_style_ext(){return text_style_ext_;}
const odf_reader::style_instance * get_current_processed_style() const { return current_processed_style_; }
@ -106,6 +153,7 @@ private:
std::wstring extern_node_;
std::wstring hlinkClick_;
std::wstring text_style_ext_;
std::wstringstream list_style_;
std::wstringstream text_style_;
@ -115,7 +163,6 @@ private:
};
namespace oox {
class math_context : boost::noncopyable
{

View File

@ -124,8 +124,14 @@ static const std::wstring _ooxDashStyle[]=
L"sysDashDotDot"
};
void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop, bool always_draw)
void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop, bool always_draw, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
std::wstring ns_node = L"a:ln";
if (ns == L"w14")
ns_node = L"w14:textOutline";
_CP_OPT(std::wstring) strStrokeColor;
_CP_OPT(int) iStroke;
_CP_OPT(double) dStrokeWidth;
@ -143,30 +149,30 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:ln")
CP_XML_NODE(ns_node)
{
std::wstring color, dash_style, fill = L"a:solidFill" ;
std::wstring color, dash_style, fill = ns + L":solidFill" ;
if (strStrokeColor) color = *strStrokeColor;
if (iStroke)
{
if (iStroke.get() == 0 || bWordArt) fill = L"a:noFill";
if (iStroke.get() == 0 || bWordArt) fill = ns + L":noFill";
else dash_style = _ooxDashStyle[iStroke.get()];
}
if ((dStrokeWidth) && (*dStrokeWidth >= 0) && fill != L"a:noFill")
if ((dStrokeWidth) && (*dStrokeWidth >= 0) && fill != ns + L":noFill")
{
int val = dStrokeWidth.get() * 12700; //in emu (1 pt = 12700)
if (val < 10) val = 12700;
CP_XML_ATTR(L"w", val);
CP_XML_ATTR2(ns_att + L"w", val);
if (color.length()<1)color = L"729FCF";
}
CP_XML_NODE(fill)
{
if (fill != L"a:noFill")
if (fill != ns + L":noFill")
{
if ( color.empty() )
{
@ -174,47 +180,49 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
else color = L"FFFFFF";
}
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val",color);
CP_XML_ATTR2(ns_att + L"val",color);
if (dStrokeOpacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", (int)(*dStrokeOpacity * 1000));
CP_XML_ATTR2(ns_att + L"val", (int)(*dStrokeOpacity * 1000));
}
}
}
}
}
if (fill != L"a:noFill")
if (fill != ns + L":noFill")
{
_CP_OPT(std::wstring) strVal;
if (dash_style.length() > 0 && dash_style != L"solid")
{
CP_XML_NODE(L"a:prstDash"){CP_XML_ATTR(L"val", dash_style);}
CP_XML_NODE(ns + L":prstDash"){CP_XML_ATTR2(ns_att + L"val", dash_style);}
}
odf_reader::GetProperty(prop,L"marker-start", strVal);
if (strVal)
{
CP_XML_NODE(L"a:headEnd"){CP_XML_ATTR(L"type", strVal.get());}
CP_XML_NODE(ns + L":headEnd"){CP_XML_ATTR2(ns_att + L"type", strVal.get());}
}
odf_reader::GetProperty(prop,L"marker-end",strVal);
if (strVal)
{
CP_XML_NODE(L"a:tailEnd"){CP_XML_ATTR(L"type",strVal.get());}
CP_XML_NODE(ns + L":tailEnd"){CP_XML_ATTR2(ns_att + L"type",strVal.get());}
}
}
}
}
}
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset)
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:avLst")
CP_XML_NODE(ns + L":avLst")
{
_CP_OPT(std::wstring) strModifiers;
odf_reader::GetProperty(prop, L"oox-draw-modifiers", strModifiers);
@ -268,20 +276,20 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
{
if (values[i].empty()) continue;
CP_XML_NODE(L"a:gd")
CP_XML_NODE(ns + L":gd")
{
if (names.size() > i)
{
CP_XML_ATTR(L"name", names[i]);
CP_XML_ATTR2(ns_att + L"name", names[i]);
}
else
{
if (values.size() > 1)
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i + 1));
CP_XML_ATTR2(ns_att + L"name", L"adj" + std::to_wstring(i + 1));
else
CP_XML_ATTR(L"name", L"adj");
CP_XML_ATTR2(ns_att + L"name", L"adj");
}
CP_XML_ATTR(L"fmla", L"val " + values[i]);
CP_XML_ATTR2(ns_att + L"fmla", L"val " + values[i]);
}
}
}

View File

@ -118,8 +118,8 @@ namespace oox {
};
typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset);
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false, const std::wstring &ns = L"a");
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset, const std::wstring &ns = L"a");
void oox_serialize_action (std::wostream & strm, const _action_desc & val);
}

View File

@ -53,55 +53,59 @@ namespace oox {
//////////////////////////////////////////////////////////////////////////////////////////////////////
void oox_serialize_none_fill(std::wostream & strm)
void oox_serialize_none_fill(std::wostream & strm, const std::wstring &ns)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:noFill");
CP_XML_NODE(ns + L":noFill");
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity)
void oox_serialize_srgb(std::wostream & strm, const std::wstring &color,_CP_OPT(double) opacity, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val", color);
CP_XML_ATTR2(ns_att + L"val", color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", std::to_wstring((int)(*opacity)*1000));// + L"%");
CP_XML_ATTR2(ns_att + L"val", std::to_wstring((int)(*opacity)*1000));// + L"%");
}
}
}
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity)
void oox_serialize_srgb(std::wostream & strm, const std::wstring &color, _CP_OPT(odf_types::percent) opacity, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val",color);
CP_XML_ATTR2(ns_att + L"val",color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", std::to_wstring((int)opacity->get_value()*1000));// + L"%");
CP_XML_ATTR2(ns_att + L"val", std::to_wstring((int)opacity->get_value() * 1000));// + L"%");
}
}
}
}
}
void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.solid)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:solidFill")
CP_XML_NODE(ns + L":solidFill")
{
oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity);
oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity, ns);
}
}
@ -151,20 +155,25 @@ void vml_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
}
}
}
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.bitmap) return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(std::wstring(val.bitmap->name_space + L":blipFill"))
{
//if (val.bitmap->rotate) CP_XML_ATTR(L"a:rotWithShape",*(val.bitmap->rotate));
//else CP_XML_ATTR(L"a:rotWithShape",1);
//if (val.bitmap->rotate) CP_XML_ATTR(ns + L":rotWithShape",*(val.bitmap->rotate));
//else CP_XML_ATTR(ns + L":rotWithShape",1);
if (val.bitmap->dpi) CP_XML_ATTR(L"a:dpi", *val.bitmap->dpi);
if (val.bitmap->dpi)
{
CP_XML_ATTR2(ns + L":dpi", *val.bitmap->dpi);
}
CP_XML_NODE(L"a:blip")
CP_XML_NODE(ns + L":blip")
{
if (val.bitmap->isInternal)
{
@ -176,38 +185,38 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
if (val.opacity)
{
CP_XML_NODE(L"a:alphaModFix")
CP_XML_NODE(ns + L":alphaModFix")
{
CP_XML_ATTR(L"amt",(int)(*val.opacity * 1000));
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.opacity * 1000));
}
}
}
if (val.bitmap->bCrop)
{
CP_XML_NODE(L"a:srcRect")
CP_XML_NODE(ns + L":srcRect")
{
CP_XML_ATTR(L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
CP_XML_ATTR2(ns_att + L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR2(ns_att + L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR2(ns_att + L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR2(ns_att + L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
}
}
if (val.bitmap->bTile)
{
CP_XML_NODE(L"a:tile")
CP_XML_NODE(ns + L":tile")
{
//tx="0" ty="0" sx="100000" sy="100000"
CP_XML_ATTR(L"flip", "none");
CP_XML_ATTR(L"algn", L"ctr");
CP_XML_ATTR2(ns_att + L"flip", "none");
CP_XML_ATTR2(ns_att + L"algn", L"ctr");
}
}
else if (val.bitmap->bStretch)
{
CP_XML_NODE(L"a:stretch")
CP_XML_NODE(ns + L":stretch")
{
if (!val.bitmap->bCrop)
{
CP_XML_NODE(L"a:fillRect");
CP_XML_NODE(ns + L":fillRect");
}
}
}
@ -269,25 +278,27 @@ void vml_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
}
}
}
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.gradient) return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:gradFill")
CP_XML_NODE(ns + L":gradFill")
{
if (val.gradient->colors.size()>0)
{
CP_XML_NODE(L"a:gsLst")
CP_XML_NODE(ns + L":gsLst")
{
for (int i = 0; i < val.gradient->colors.size(); i++)
for (size_t i = 0; i < val.gradient->colors.size(); i++)
{
oox_gradient_fill::_color_position & col = val.gradient->colors[i];
CP_XML_NODE(L"a:gs")
CP_XML_NODE(ns + L":gs")
{
CP_XML_ATTR(L"pos", (int)(col.pos * 1000));//%
oox_serialize_srgb(CP_XML_STREAM(), col.color_ref, col.opacity);
CP_XML_ATTR2(ns_att + L"pos", (int)(col.pos * 1000));//%
oox_serialize_srgb(CP_XML_STREAM(), col.color_ref, col.opacity, ns);
}
}
}
@ -298,25 +309,25 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
switch(val.gradient->style)
{
case 0:
CP_XML_NODE(L"a:lin")
CP_XML_NODE(ns + L":lin")
{
CP_XML_ATTR(L"ang",(int)angle);//gr in rad
CP_XML_ATTR2(ns_att + L"ang",(int)angle);//gr in rad
}break;
case 1:
case 2:
case 3:
CP_XML_NODE(L"a:path")
CP_XML_NODE(ns + L":path")
{
if (val.gradient->style == 1) CP_XML_ATTR(L"path", L"rect");
if (val.gradient->style == 2) CP_XML_ATTR(L"path", L"circle");
if (val.gradient->style == 3) CP_XML_ATTR(L"path", L"shape");
if (val.gradient->style == 1) CP_XML_ATTR2(ns_att + L"path", L"rect");
if (val.gradient->style == 2) CP_XML_ATTR2(ns_att + L"path", L"circle");
if (val.gradient->style == 3) CP_XML_ATTR2(ns_att + L"path", L"shape");
CP_XML_NODE(L"a:fillToRect")
CP_XML_NODE(ns + L":fillToRect")
{
CP_XML_ATTR(L"l", (int)(val.gradient->rect[0] * 1000));
CP_XML_ATTR(L"t", (int)(val.gradient->rect[1] * 1000));
CP_XML_ATTR(L"r", (int)(val.gradient->rect[2] * 1000));
CP_XML_ATTR(L"b", (int)(val.gradient->rect[3] * 1000));
CP_XML_ATTR2(ns_att + L"l", (int)(val.gradient->rect[0] * 1000));
CP_XML_ATTR2(ns_att + L"t", (int)(val.gradient->rect[1] * 1000));
CP_XML_ATTR2(ns_att + L"r", (int)(val.gradient->rect[2] * 1000));
CP_XML_ATTR2(ns_att + L"b", (int)(val.gradient->rect[3] * 1000));
}
}break;
}
@ -324,22 +335,24 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
//tileRect (Tile Rectangle) §20.1.8.59
}
}
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.hatch)return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pattFill")
CP_XML_NODE(ns + L":pattFill")
{
CP_XML_ATTR(L"prst",val.hatch->preset);
CP_XML_NODE(L"a:fgClr")//опять для ms важно что этот цвет перед back
CP_XML_ATTR2(ns_att + L"prst", val.hatch->preset);
CP_XML_NODE(ns + L":fgClr")//опять для ms важно что этот цвет перед back
{
oox_serialize_srgb(CP_XML_STREAM(), val.hatch->color_ref, val.opacity);
}
if (val.hatch->color_back_ref)
{
CP_XML_NODE(L"a:bgClr")
CP_XML_NODE(ns + L":bgClr")
{
oox_serialize_srgb(CP_XML_STREAM(), *val.hatch->color_back_ref ,val.opacity);
}
@ -379,23 +392,23 @@ void vml_serialize_background (std::wostream & strm, const _oox_fill & val, cons
}
}
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val)
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
switch (val.type)
{
case 0:
oox_serialize_none_fill(strm);
oox_serialize_none_fill(strm, ns);
break;
case 1:
oox_serialize_solid_fill(strm, val);
oox_serialize_solid_fill(strm, val, ns);
break;
case 2:
oox_serialize_bitmap_fill(strm, val);
oox_serialize_bitmap_fill(strm, val, ns);
break;
case 3:
oox_serialize_gradient_fill(strm, val);
oox_serialize_gradient_fill(strm, val, ns);
break;
case 4: oox_serialize_hatch_fill(strm, val);
case 4: oox_serialize_hatch_fill(strm, val, ns);
break;
}
}

View File

@ -143,10 +143,12 @@ namespace oox {
}
};
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);
void oox_serialize_bitmap_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);
void oox_serialize_srgb (std::wostream & strm, const std::wstring &color, _CP_OPT(double) opacity, const std::wstring &ns = L"a");
void oox_serialize_srgb (std::wostream & strm, const std::wstring &color, _CP_OPT(odf_types::percent) opacity, const std::wstring &ns = L"a");
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
}
}

View File

@ -123,7 +123,7 @@ void content_types_file::write(const std::wstring & RootPath)
elm.write(RootPath);
}
content_type_content * content_types_file::content()
content_type * content_types_file::content()
{
return &content_type_content_;
}
@ -132,7 +132,7 @@ bool content_types_file::add_or_find_default(const std::wstring & extension)
{
std::vector<default_content_type> & defaults = content_type_content_.get_default();
for (int i = 0 ; i < defaults.size(); i++)
for (size_t i = 0 ; i < defaults.size(); i++)
{
if (defaults[i].extension() == extension)
return true;
@ -279,11 +279,11 @@ _CP_PTR(customXml_content) customXml_content::create(const std::wstring &item, c
return boost::make_shared<customXml_content>(item, props);
}
//-----------------------------------------------------------------------------------------------
element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content)
simple_element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content)
{
return boost::make_shared<simple_element>(FileName, Content);
}
element_ptr simple_element::create(const std::wstring & FileName, const std::string & Content)
simple_element_ptr simple_element::create(const std::wstring & FileName, const std::string & Content)
{
return boost::make_shared<simple_element>(FileName, Content);
}

View File

@ -86,23 +86,27 @@ public:
bool add_or_find_default (const std::wstring & extension);
bool add_or_find_override(const std::wstring & fileName);
void set_media (mediaitems & _Mediaitems);
content_type_content * content ();
content_type * content ();
private:
content_type_content content_type_content_;
content_type content_type_content_;
std::wstring filename_;
};
class simple_element;
typedef boost::shared_ptr<simple_element> simple_element_ptr;
class simple_element : public element
{
public:
simple_element(const std::wstring & FileName, const std::wstring & Content);
static element_ptr create(const std::wstring & FileName, const std::wstring & Content);
static simple_element_ptr create(const std::wstring & FileName, const std::wstring & Content);
simple_element(const std::wstring & FileName, const std::string & Content);
static element_ptr create(const std::wstring & FileName, const std::string & Content);
static simple_element_ptr create(const std::wstring & FileName, const std::string & Content);
virtual void write(const std::wstring & RootPath);
std::wstring get_filename() {return file_name_;}
private:
std::wstring file_name_;
@ -111,7 +115,6 @@ private:
bool bXml;
};
//------------------------------------------------------------------------
class rels_file;
typedef boost::shared_ptr<rels_file> rels_file_ptr;

View File

@ -56,7 +56,10 @@ enum RelsType
typeSlide,
typeVideo,
typeAudio,
typeControl
typeExternalLink,
typeActiveX,
typeControl,
typeControlProps
};
struct _rel

View File

@ -39,7 +39,7 @@ namespace oox {
void oox_chart::set_cache_only (bool val)
{
for (int i = 0 ; i < series_.size(); i++)
for (size_t i = 0 ; i < series_.size(); i++)
{
series_[i]->set_cache_only(val);
}

View File

@ -274,7 +274,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{
@ -311,7 +311,7 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{
@ -352,7 +352,7 @@ void pptx_serialize_object(std::wostream & strm, _pptx_drawing & val)
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{

View File

@ -55,7 +55,7 @@ public:
pptx_drawings_.push_back(d);
bool present = false;
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
for (size_t i = 0; i < pptx_drawing_rels_.size(); i++)
{
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
present = true;
@ -83,7 +83,7 @@ public:
{
bool present = false;
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
for (size_t i = 0; i < pptx_drawing_rels_.size(); i++)
{
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
present = true;
@ -96,7 +96,7 @@ public:
}
void serialize(std::wostream & strm)
{
for (int i = 0; i < pptx_drawings_.size(); i++)
for (size_t i = 0; i < pptx_drawings_.size(); i++)
{
pptx_drawings_[i].serialize(strm);
}
@ -109,7 +109,7 @@ public:
void dump_rels(rels & Rels)
{
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
for (size_t i = 0; i < pptx_drawing_rels_.size(); i++)
{
if (pptx_drawing_rels_[i].type == typeUnknown ||
pptx_drawing_rels_[i].type == typeTable ||

View File

@ -352,7 +352,7 @@ std::pair<int,int> pptx_xml_authors_comments::add_or_find(std::wstring author)
int last_id=0;
bool find = false;
for (long i=0;i<list_.size();i++)
for (size_t i=0;i<list_.size();i++)
{
if (author == list_[i].name)
{

View File

@ -121,10 +121,10 @@ void slides_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slides" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -156,10 +156,10 @@ 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();
content_type * 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++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -199,10 +199,10 @@ void slideMasters_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideMasters" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -233,10 +233,10 @@ 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();
content_type * 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++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -275,14 +275,14 @@ void slideLayouts_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideLayouts" ;
NSDirectory::CreateDirectory(path.c_str());
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
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();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/slideLayouts/") + fileName, kWSConType);
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
@ -327,12 +327,12 @@ void ppt_charts_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
NSDirectory::CreateDirectory(path.c_str());
for (int i = 0; i < charts_.size(); i++)
for (size_t i = 0; i < charts_.size(); i++)
{
if (!charts_[i]) continue;
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();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
@ -357,14 +357,14 @@ void ppt_themes_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"theme" ;
NSDirectory::CreateDirectory(path.c_str());
for (int i = 0; i < themes_.size(); i++)
for (size_t i = 0; i < themes_.size(); i++)
{
if (!themes_[i]) continue;
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();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/theme/") + fileName, kWSConType);
std::wstringstream content;
@ -383,9 +383,9 @@ void ppt_comments_files::write(const std::wstring & RootPath)
std::wstring comm_path = RootPath + FILE_SEPARATOR_STR + L"comments";
NSDirectory::CreateDirectory(comm_path.c_str());
for (int i = 0; i < comments_.size(); i++)
for (size_t i = 0; i < comments_.size(); i++)
{
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.comments+xml";
contentTypes->add_override(std::wstring(L"/ppt/comments/") + comments_[i].filename, kWSConType);

View File

@ -282,7 +282,7 @@ void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_p
odf_reader::text_list_style * text_list_style = odf_context_.listStyleContainer().list_style_by_name(list_style_stack_.back());
if ((text_list_style) && (Level < text_list_style->get_content().size()))
if ((text_list_style) && (Level < (int)text_list_style->get_content().size()))
{
odf_reader::office_element_ptr elm = text_list_style->get_content()[Level];
odf_reader::office_element_ptr elm_list;

View File

@ -62,7 +62,7 @@ public:
CP_XML_NODE(L"authors")
{
for (int i = 0 ; i < author_list_.size(); i++)
for (size_t i = 0 ; i < author_list_.size(); i++)
{
const std::wstring & a = author_list_[i];
CP_XML_NODE(L"author")
@ -74,7 +74,7 @@ public:
CP_XML_NODE(L"commentList")
{
for (int i = 0 ; i < xlsx_comment_.size(); i++)
for (size_t i = 0 ; i < xlsx_comment_.size(); i++)
{
const _xlsx_comment & c = xlsx_comment_[i];
@ -107,7 +107,7 @@ public:
CP_XML_ATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office");
CP_XML_ATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel");
for (int i = 0; i < xlsx_comment_.size(); i++)
for (size_t i = 0; i < xlsx_comment_.size(); i++)
{
const _xlsx_comment & c = xlsx_comment_[i];
@ -222,7 +222,7 @@ public:
void add(_xlsx_comment & c)
{
bool find = false;
for (long i = 0; i < author_list_.size(); i++)
for (size_t i = 0; i < author_list_.size(); i++)
{
if (c.author_ == author_list_[i])
{

View File

@ -78,7 +78,7 @@ public:
{
CP_XML_NODE(L"definedNames")
{
for (int i = 0 ; i < content_.size(); i++)
for (size_t i = 0 ; i < content_.size(); i++)
{
CP_XML_NODE(L"definedName")
{

View File

@ -252,7 +252,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
CP_XML_NODE(L"xdr:cNvGraphicFramePr");
}
val.serialize_xfrm(CP_XML_STREAM(), L"xdr");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{
@ -289,7 +289,8 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
xlsx_serialize_group(strm, val);
}
else if (val.type == typeOleObject ||
val.type == typeMsObject )
val.type == typeMsObject ||
val.type == typeControl)
{
xlsx_serialize_object(strm, val);
}
@ -371,5 +372,37 @@ void _xlsx_drawing::serialize_object (std::wostream & strm)
}
void _xlsx_drawing::serialize_control (std::wostream & strm)
{
if (type != typeControl) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"control")
{
CP_XML_ATTR(L"r:id", objectId);
CP_XML_ATTR(L"shapeId", id);
//CP_XML_ATTR(L"name", objectProgId);
CP_XML_NODE(L"controlPr")
{
CP_XML_ATTR(L"defaultSize", 0);
if (fill.bitmap)
{
CP_XML_ATTR(L"r:id", fill.bitmap->rId);
}
CP_XML_NODE(L"anchor")
{
CP_XML_ATTR(L"moveWithCells", 1);
from_.serialize (CP_XML_STREAM(), L"");
to_.serialize (CP_XML_STREAM(), L"");
}
}
}
}
}
}
}

View File

@ -66,7 +66,8 @@ public:
std::wstring content_group_;
void serialize (std::wostream & strm);
void serialize_object (std::wostream & strm);
void serialize_object (std::wostream & strm);
void serialize_control (std::wostream & strm);
};
}
}

View File

@ -297,6 +297,11 @@ void xlsx_drawing_context::set_ms_object(const std::wstring & path, const std::w
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
}
void xlsx_drawing_context::set_control(const std::wstring & ctrlPropId)
{
impl_->object_description_.type_ = typeControl;
impl_->object_description_.xlink_href_ = ctrlPropId;
}
void xlsx_drawing_context::set_image(const std::wstring & path)
{
int pos_replaicement = path.find(L"ObjectReplacements");
@ -575,15 +580,14 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
}
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
std::wstring ref;
bool isMediaInternal = true;
if (drawing.type_anchor == 2) // absolute
{
//пересчет нужен для оле
//пересчет нужен
xlsx_table_position from, to;
process_position_properties (obj, table_metrics, from, to);
@ -600,11 +604,19 @@ void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx
drawing.to_.position.row = to.row;
drawing.to_.position.rowOff = static_cast<size_t>(odf_types::length(to.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
}
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, true);
if (obj.type_ == typeControl)
{
drawing.objectId = obj.xlink_href_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
}
else
{
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, true);
}
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
@ -680,7 +692,8 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
case typeShape: process_shape ( obj, drawing, xlsx_drawings_); break;
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
case typeMsObject:
case typeOleObject:
case typeOleObject:
case typeControl:
process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
}
}

View File

@ -95,6 +95,7 @@ public:
void set_chart (const std::wstring & path);
void set_ole_object (const std::wstring & path, const std::wstring & progId);
void set_ms_object (const std::wstring & path, const std::wstring & progId);
void set_control (const std::wstring & ctrlPropId);
void set_text_box ();
void end_frame();

View File

@ -104,7 +104,7 @@ public:
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(CP_XML_STREAM());
}
@ -121,7 +121,15 @@ public:
xlsx_drawings_[i].serialize_object(strm);
}
}
void serialize_controls(std::wostream & strm)
{
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
{
if (xlsx_drawings_[i].type != typeControl) continue;
xlsx_drawings_[i].serialize_control(strm);
}
}
bool empty() const
{
return (xlsx_drawings_.empty());
@ -193,6 +201,10 @@ void xlsx_drawings::serialize_objects(std::wostream & strm)
{
impl_->serialize_objects(strm);
}
void xlsx_drawings::serialize_controls(std::wostream & strm)
{
impl_->serialize_controls(strm);
}
bool xlsx_drawings::empty() const
{

View File

@ -73,6 +73,7 @@ public:
void serialize (std::wostream & _Wostream);
void serialize_objects (std::wostream & _Wostream);
void serialize_controls (std::wostream & _Wostream);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;

View File

@ -90,7 +90,7 @@ void xlsx_dxfs::serialize(std::wostream & _Wostream) const
{
CP_XML_ATTR(L"count", impl_->dxf_array.size());
for (int i = 0; i < impl_->dxf_array.size(); i++)
for (size_t i = 0; i < impl_->dxf_array.size(); i++)
{
CP_XML_NODE(L"dxf")
{

View File

@ -65,7 +65,7 @@ public:
{
CP_XML_ATTR(L"count", merges_.size());
for (int i = 0 ; i < merges_.size(); i++)
for (size_t i = 0 ; i < merges_.size(); i++)
{
merge & m = merges_[i];

View File

@ -58,6 +58,7 @@ public:
std::wstringstream dataValidations_;
std::wstringstream ole_objects_;
std::wstringstream page_props_;
std::wstringstream controls_;
rels sheet_rels_;
@ -136,6 +137,10 @@ std::wostream & xlsx_xml_worksheet::ole_objects()
{
return impl_->ole_objects_;
}
std::wostream & xlsx_xml_worksheet::controls()
{
return impl_->controls_;
}
std::wostream & xlsx_xml_worksheet::page_properties()
{
return impl_->page_props_;
@ -203,7 +208,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->drawing_.str();
if (impl_->commentsId_.length()>0)
if (!impl_->commentsId_.empty())
{
CP_XML_NODE(L"legacyDrawing")
{
@ -216,6 +221,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
if (!impl_->controls_.str().empty())
{
CP_XML_NODE(L"controls")
{
CP_XML_STREAM() << impl_->controls_.str();
}
}
CP_XML_STREAM() << impl_->picture_background_.str();

View File

@ -66,6 +66,7 @@ public:
std::wostream & sort();
std::wostream & ole_objects();
std::wostream & page_properties();
std::wostream & controls();
rels & sheet_rels(); //hyperlink, background image, external, media ...

View File

@ -148,7 +148,7 @@ void sheets_files::write(const std::wstring & RootPath)
const std::wstring fileName = std::wstring(L"sheet") + std::to_wstring(i + 1) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/xl/worksheets/") + fileName, kWSConType);
if (rels_)
@ -194,6 +194,10 @@ void xl_files::write(const std::wstring & RootPath)
sheets_files_.set_main_document( this->get_main_document() );
sheets_files_.write(path);
}
{
control_props_files_.set_main_document( this->get_main_document() );
control_props_files_.write(path);
}
int index = 1;
if (true)
{
@ -210,7 +214,7 @@ void xl_files::write(const std::wstring & RootPath)
connections_->write(path);
rels_files_.add( relationship( L"cnId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections", L"connections.xml" ) );
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
contentTypes->add_override(L"/xl/connections.xml", L"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml");
}
@ -322,6 +326,10 @@ void xl_files::add_jsaProject(const std::string &content)
{
jsaProject_ = package::simple_element::create(L"jsaProject.bin", content);
}
void xl_files::add_control_props (simple_element_ptr element)
{
control_props_files_.add_control_props(element);
}
//----------------------------------------------------------------------------------------
void xl_pivot_cache_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
{
@ -332,7 +340,7 @@ void xl_pivot_cache_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"pivotCache";
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConTypeD = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
static const std::wstring kWSConTypeR = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml";
@ -384,7 +392,7 @@ void xl_pivot_table_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"pivotTables";
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
@ -425,7 +433,7 @@ void xl_charts_files::write(const std::wstring & RootPath)
{
count++;
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(i + 1) + L".xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/xl/charts/") + fileName, kWSConType);
@ -440,6 +448,33 @@ void xl_charts_files::write(const std::wstring & RootPath)
relFiles.write(path);
}
}
//----------------------------------------------------------------------------------------
void xl_control_props_files::add_control_props(simple_element_ptr query_table)
{
control_props_.push_back(query_table);
}
void xl_control_props_files::write(const std::wstring & RootPath)
{
if (control_props_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"ctrlProps";
NSDirectory::CreateDirectory(path);
content_type *contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.ms-excel.controlproperties+xml";
for (size_t i = 0; i < control_props_.size(); i++)
{
if (!control_props_[i])continue;
const std::wstring fileName = control_props_[i]->get_filename();
contentTypes->add_override(std::wstring(L"/xl/ctrlProps/") + fileName, kWSConType);
control_props_[i]->write(path);
}
}
//------------------------------------------------------------------------------------------------------
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms)
{
@ -463,7 +498,7 @@ void xl_drawings::write(const std::wstring & RootPath)
relFiles.add_rel_file(r);
relFiles.write(path);
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
const std::wstring kDrawingCT = L"application/vnd.openxmlformats-officedocument.drawing+xml";
contentTypes->add_override(L"/xl/drawings/" + drawings_[i].filename, kDrawingCT);
@ -483,7 +518,7 @@ void xl_comments::write(const std::wstring & RootPath)
for (size_t i = 0; i < comments_.size(); i++)
{
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
contentTypes->add_override(std::wstring(L"/xl/") + comments_[i].filename, kWSConType);

View File

@ -211,13 +211,23 @@ private:
rels_files * rels_;
};
//----------------------------------------------------------------------------------------------------------
class xl_control_props_files : public element
{
public:
xl_control_props_files(){}
void add_control_props(simple_element_ptr props);
virtual void write(const std::wstring & RootPath);
std::vector<simple_element_ptr> control_props_;
};
//----------------------------------------------------------------------------------------------------------
class xl_files : public element
{
public:
xl_files();
public:
virtual void write(const std::wstring & RootPath);
void set_workbook (element_ptr Element);
@ -233,6 +243,7 @@ public:
void add_pivot_cache (pivot_cache_content_ptr cache);
void add_pivot_table (pivot_table_content_ptr table);
void add_jsaProject (const std::string &content);
void add_control_props (simple_element_ptr Element);
private:
rels_files rels_files_;
@ -240,7 +251,8 @@ private:
xl_charts_files charts_files_;
xl_pivot_cache_files pivot_cache_files_;
xl_pivot_table_files pivot_table_files_;
xl_control_props_files control_props_files_;
element_ptr theme_;
element_ptr workbook_;

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