Compare commits

..

77 Commits

Author SHA1 Message Date
cfe59582fc x2t - convert bigest meta file in raster without svg 2018-02-27 11:50:19 +03:00
b214dc93d8 XlsFormatReader - fix convert elements chart; fix convert color scale cond. format 2018-02-26 19:37:14 +03:00
a2d0c4ad7d Fix build 3rd-party on macOS 2018-02-26 14:57:24 +03:00
43f29d2877 [bug] Fix bug 35691 2018-02-26 13:29:37 +03:00
5f5f22a0f0 Merge branch 'release/v5.1.0' of https://github.com/ONLYOFFICE/core into release/v5.1.0 2018-02-26 12:03:27 +03:00
5256afe04c x2t version up 2.4.519 2018-02-26 12:05:13 +03:00
b9080eb9c2 XlsFormat - workbook protections 2018-02-24 14:08:58 +03:00
5649fb3e2e RtfFormat; XlsFormat - extended chart layouts for series, titles 2018-02-24 12:54:55 +03:00
348b8e4045 [x2t][feat] Add Word app version in Editor.bin 2018-02-22 18:32:27 +03:00
2087e9f195 [fonts] AllFontsGen 2018-02-22 18:13:47 +03:00
ccd84e1850 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-02-22 17:43:29 +03:00
08ca56873e RtfFormatWriter - fix shapes size (for previous) 2018-02-22 17:42:54 +03:00
72761a21e3 x2t fix linux build 2018-02-22 17:41:05 +03:00
9e5a1f004e Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-02-22 17:30:51 +03:00
57fea23de4 RtfFormatWriter - convert ooxml chart to ole object 2018-02-22 16:27:45 +03:00
bc67fc8e55 . 2018-02-21 17:36:28 +03:00
4aae1b21e9 RtfFormatWriter - fix write ole object 2018-02-21 17:34:16 +03:00
ae69f892f1 XlsFormatReader - fix users file - fix layout plot area chart from newest format 2018-02-21 15:23:46 +03:00
93d8634ca3 x2t fix linux compaund. version up to 2.4.518 2018-02-21 14:42:59 +03:00
bdd4b68f43 XlsFormat - fix users file - chart title & bevel shape 2018-02-21 12:28:48 +03:00
a9a674c895 RtfFormatReaderWriter - convert ole object. 2018-02-21 12:06:17 +03:00
ed575b3b68 [x2t][config] Rename m_oInputLimits param 2018-02-20 16:20:58 +03:00
016d46d030 [x2t][feat] Add m_oInput param to limit commpressed/uncommpressed size of zip 2018-02-20 14:56:20 +03:00
486685e4b4 [feat] Add COfficeUtils::GetFilesSize to determine commpressed/uncommpressed size of archive 2018-02-20 14:54:31 +03:00
26a6a77b8d [fonts] New scheme AllFontsGen 2018-02-19 19:08:52 +03:00
90aa7973ed [fonts] New scheme AllFontsGen 2018-02-19 17:19:29 +03:00
b2363c02c0 [allfontsgen] Log 2018-02-16 17:01:57 +03:00
32b59120aa Escape building HtmlFileInternal on Mac OS 2018-02-16 12:57:06 +03:00
7186b56b64 DocFormatReader - fix table mapping 2018-02-16 11:54:24 +03:00
6247490047 RtfFormatReader - fix ole xls chart
RtfFormatWriter - fix table bounds
2018-02-15 19:20:19 +03:00
f30e14c421 Add mac support 2018-02-15 18:54:26 +03:00
e340a2af22 Fix typo 2018-02-15 17:24:49 +03:00
6a5cddf0ce Add multi thread building v8 on mac 2018-02-15 17:13:05 +03:00
312728fe9a Fix typo 2018-02-15 17:00:44 +03:00
182da130da RtfFormatWriter - fix table layouts 2018-02-14 20:01:13 +03:00
eb3ba8c42e RtfFormatWriter - fix table padding 2018-02-13 19:47:23 +03:00
dec099b19b [x2t] Fix bug #36922 2018-02-13 19:24:28 +03:00
21762360ac RtfFormatWriter - fix linux build 2018-02-13 12:13:42 +03:00
563fe88842 [x2t][UnicodeConverter] Change UTF-16,UTF-32 encoding name to UTF-16LE
As described in http://unicode.org/faq/utf_bom.html#gen6 UTF-16,UTF-32 requires BOM
2018-02-13 11:33:32 +03:00
0e085fbb13 RtfFormatWriter - fix text in ooxml shapes, expand properties ooxml shapes 2018-02-12 19:54:28 +03:00
ed409e745a fix bug #36905 2018-02-12 19:44:59 +03:00
4bc58482b3 [ios][x2t] fixed build project 2018-02-12 14:55:08 +03:00
89ee039a05 RtfFormatReader - fix convert shapes 2018-02-08 11:11:49 +03:00
5d5b1202c7 fix for ms office editor. bug 36869. 2018-02-07 17:57:11 +03:00
c7646fd813 Changed main default fonts 2018-02-07 17:09:40 +03:00
b1d406b448 fix xdr xfrm in graphiicFrame 2018-02-07 15:36:51 +03:00
ea37eab86e . 2018-02-07 13:15:58 +03:00
d045609523 DocFormatReader - fix shape 2018-02-06 20:13:06 +03:00
9336448ca9 fix bug 36861 2018-02-06 17:55:37 +03:00
5830e7824a fix bug #36740 - for csv preview remove error return 2018-02-06 17:35:11 +03:00
821feb51b5 . 2018-02-06 15:59:20 +03:00
547979cd9b bug: fix open CBulletColor with no UniColor 2018-02-06 14:22:27 +03:00
c4481eb125 DocFormatReader - adding decrypt for format 1995, adding xor method decrypting 2018-02-06 13:55:59 +03:00
ad0f2c89e0 fix bug #35277
XlsFormatReader - adding decrypt for format 1995, adding xor method decrypting
2018-02-05 17:38:14 +03:00
e15c75b6aa add sha-256 hash agrorithm 2018-02-05 13:52:29 +03:00
b2fb7f0fe7 . 2018-02-05 12:52:24 +03:00
410e5ebd75 . 2018-02-05 12:11:35 +03:00
9c57088ef1 RtfFormatWriter - add application property for info
OdfFormatWriter - ods - fix theme color in font
2018-02-03 18:55:49 +03:00
24230e12a3 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-02-02 18:26:11 +03:00
2acef0d4a2 . 2018-02-02 18:25:30 +03:00
aca5ffa36f add standard priority to "Wingdings" font-family 2018-02-02 16:58:10 +03:00
4fc3726f37 fix read strict ooxml textbox (namespace wne) 2018-02-02 15:08:11 +03:00
2682e1fbac Ooxml - fix vml image without image 2018-02-02 14:52:15 +03:00
f5c3ae779b . 2018-02-02 13:59:58 +03:00
068c60afa0 fix bug #36740 - extending error code
x2t version 2.4.515
2018-02-01 19:33:59 +03:00
5b8ca5b417 OdfFormatWriter - write columns table parts in formulas as ref 2018-02-01 18:55:57 +03:00
acfd12ea30 fix bug #36740 2018-02-01 16:42:34 +03:00
a04b83cada . 2018-02-01 12:28:46 +03:00
a7bf12c052 . 2018-01-31 18:17:45 +03:00
5c01b23dee . 2018-01-30 20:09:22 +03:00
db11b75a2e x2t version 2.4.514 2018-01-30 19:37:10 +03:00
2ba4c18cdf bug: initialize m_pWorkbookComments 2018-01-30 17:22:39 +03:00
b264f20f29 . 2018-01-30 15:21:05 +03:00
5e04ea62f7 fix operation priority 2018-01-30 14:44:52 +03:00
3d1db63c0e bug: bug on save onlyoffice extention for comments in xlsx 2018-01-29 19:51:06 +03:00
f124d18256 bug: save nil shading to docx 2018-01-29 18:14:23 +03:00
9bffb65dcb x2t 2.4.512 2018-01-29 15:46:08 +03:00
297 changed files with 6153 additions and 4012 deletions

View File

@ -35,143 +35,148 @@
namespace DocFileFormat
{
EncryptionHeader::EncryptionHeader( FileInformationBlock* fib, POLE::Stream* tableStream )
EncryptionHeader::EncryptionHeader( FileInformationBlock* fib, POLE::Stream* tableStream ) : bStandard(false), bXOR(false), bAES(false)
{
VirtualStreamReader tStream( tableStream, 0, fib->m_bOlderVersion);
if (fib->m_FibBase.fObfuscation)
if (fib->m_FibBase.fObfuscation || fib->m_bOlderVersion)
{
//xor
return;
}
unsigned short vMajor = tStream.ReadUInt16();
unsigned short vMinor = tStream.ReadUInt16();
if(0x0001 == vMajor) // RC4 encryption header structure
{// fib->m_FibBase.lKey == 52
bStandard = true;
crypt_data_rc4.Salt.b1 = tStream.ReadUInt32();
crypt_data_rc4.Salt.b2 = tStream.ReadUInt32();
crypt_data_rc4.Salt.b3 = tStream.ReadUInt32();
crypt_data_rc4.Salt.b4 = tStream.ReadUInt32();
bXOR = true;
crypt_data_rc4.EncryptedVerifier.b1 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifier.b2 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifier.b3 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifier.b4 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b1 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b2 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b3 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b4 = tStream.ReadUInt32();
crypt_data_xor.key = fib->m_FibBase.lKey >> 16;
crypt_data_xor.hash = fib->m_FibBase.lKey - (crypt_data_xor.key << 16);
}
else
{
bStandard = false;
crypt_data_aes.bAgile = false;
unsigned short vMajor = tStream.ReadUInt16();
unsigned short vMinor = tStream.ReadUInt16();
unsigned short flags = tStream.ReadUInt32();
unsigned char *pDataRead = NULL;
if(0x0001 == vMajor) // RC4 encryption header structure
{// fib->m_FibBase.lKey == 52
bStandard = true;
bool fCryptoAPI = GETBIT(flags, 1);
bool fDocProps = GETBIT(flags, 2);
bool fExternal = GETBIT(flags, 3);
bool fAES = GETBIT(flags, 4);
//EncryptionHeader
int HeaderSize = tStream.ReadUInt32();
int Flags = tStream.ReadUInt32();
int SizeExtra = tStream.ReadUInt32();
int AlgID = tStream.ReadUInt32();
int AlgIDHash = tStream.ReadUInt32();
int KeySize = tStream.ReadUInt32();
int ProviderType= tStream.ReadUInt32();
int Reserved1 = tStream.ReadUInt32();
int Reserved2 = tStream.ReadUInt32();
int pos = tStream.GetPosition();
int size = tStream.GetSize();
std::vector<char> dataCSPName;
while(pos < size - 1)
crypt_data_rc4.Salt.b1 = tStream.ReadUInt32();
crypt_data_rc4.Salt.b2 = tStream.ReadUInt32();
crypt_data_rc4.Salt.b3 = tStream.ReadUInt32();
crypt_data_rc4.Salt.b4 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifier.b1 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifier.b2 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifier.b3 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifier.b4 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b1 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b2 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b3 = tStream.ReadUInt32();
crypt_data_rc4.EncryptedVerifierHash.b4 = tStream.ReadUInt32();
}
else
{
dataCSPName.push_back(tStream.ReadByte());
dataCSPName.push_back(tStream.ReadByte());
if (dataCSPName[dataCSPName.size() - 1] == 0 && dataCSPName[dataCSPName.size() - 2] == 0)
bAES = true;
crypt_data_aes.bAgile = false;
unsigned short flags = tStream.ReadUInt32();
unsigned char *pDataRead = NULL;
bool fCryptoAPI = GETBIT(flags, 1);
crypt_data_aes.fDocProps = GETBIT(flags, 2);
bool fExternal = GETBIT(flags, 3);
bool fAES = GETBIT(flags, 4);
//EncryptionHeader
int HeaderSize = tStream.ReadUInt32();
int Flags = tStream.ReadUInt32();
int SizeExtra = tStream.ReadUInt32();
int AlgID = tStream.ReadUInt32();
int AlgIDHash = tStream.ReadUInt32();
int KeySize = tStream.ReadUInt32();
int ProviderType= tStream.ReadUInt32();
int Reserved1 = tStream.ReadUInt32();
int Reserved2 = tStream.ReadUInt32();
int pos = tStream.GetPosition();
int size = tStream.GetSize();
std::vector<char> dataCSPName;
while(pos < size - 1)
{
dataCSPName.push_back(tStream.ReadByte());
dataCSPName.push_back(tStream.ReadByte());
if (dataCSPName[dataCSPName.size() - 1] == 0 && dataCSPName[dataCSPName.size() - 2] == 0)
{
break;
}
pos+=2;//unicode null-terminate string
}
//EncryptionVerifier
crypt_data_aes.saltSize = tStream.ReadUInt32();
pDataRead = tStream.ReadBytes(crypt_data_aes.saltSize, true);
if (pDataRead)
{
crypt_data_aes.saltValue = std::string((char*)pDataRead, crypt_data_aes.saltSize);
delete pDataRead;
}
pDataRead = tStream.ReadBytes(0x10, true);
if (pDataRead)
{
crypt_data_aes.encryptedVerifierInput = std::string((char*)pDataRead, 0x10);
delete pDataRead;
}
crypt_data_aes.hashSize = tStream.ReadUInt32();
int szEncryptedVerifierHash = (ProviderType == 0x0001) ? 0x14 : 0x20;
pDataRead = tStream.ReadBytes(szEncryptedVerifierHash, true);
if (pDataRead)
{
crypt_data_aes.encryptedVerifierValue = std::string((char*)pDataRead, szEncryptedVerifierHash);
delete pDataRead;
}
pos = tStream.GetPosition();
//------------------------------------------------------------------------------------------
switch(AlgIDHash)
{
case 0x8003: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::MD5; break;
case 0x0000:
case 0x8004: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::SHA1; break;
}
crypt_data_aes.spinCount = 0;
switch(AlgID)
{
case 0x0000:
if (fAES) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
if (fCryptoAPI) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
case 0x6801:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
if (crypt_data_aes.keySize == 0) crypt_data_aes.keySize = 5; // 40 bit
break;
case 0x660E:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 128 /8;
break;
case 0x660F:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 192 /8;
break;
case 0x6610:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 256 /8;
break;
}
pos+=2;//unicode null-terminate string
}
//EncryptionVerifier
crypt_data_aes.saltSize = tStream.ReadUInt32();
pDataRead = tStream.ReadBytes(crypt_data_aes.saltSize, true);
if (pDataRead)
{
crypt_data_aes.saltValue = std::string((char*)pDataRead, crypt_data_aes.saltSize);
delete pDataRead;
}
pDataRead = tStream.ReadBytes(0x10, true);
if (pDataRead)
{
crypt_data_aes.encryptedVerifierInput = std::string((char*)pDataRead, 0x10);
delete pDataRead;
}
crypt_data_aes.hashSize = tStream.ReadUInt32();
int szEncryptedVerifierHash = (ProviderType == 0x0001) ? 0x14 : 0x20;
pDataRead = tStream.ReadBytes(szEncryptedVerifierHash, true);
if (pDataRead)
{
crypt_data_aes.encryptedVerifierValue = std::string((char*)pDataRead, szEncryptedVerifierHash);
delete pDataRead;
//switch(ProviderType)
//{
// case 0x0001: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4; break;
// case 0x0018: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB; break;
//}
}
pos = tStream.GetPosition();
//------------------------------------------------------------------------------------------
switch(AlgIDHash)
{
case 0x8003: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::MD5; break;
case 0x0000:
case 0x8004: crypt_data_aes.hashAlgorithm = CRYPT_METHOD::SHA1; break;
}
crypt_data_aes.spinCount = 0;
switch(AlgID)
{
case 0x0000:
if (fAES) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
if (fCryptoAPI) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
case 0x6801:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
if (crypt_data_aes.keySize == 0) crypt_data_aes.keySize = 5; // 40 bit
break;
case 0x660E:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 128 /8;
break;
case 0x660F:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 192 /8;
break;
case 0x6610:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
crypt_data_aes.keySize = 256 /8;
break;
}
//switch(ProviderType)
//{
// case 0x0001: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4; break;
// case 0x0018: crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB; break;
//}
}
}
}

View File

@ -52,6 +52,10 @@ namespace DocFileFormat
private:
CRYPT::_rc4CryptData crypt_data_rc4;
CRYPT::_ecmaCryptData crypt_data_aes;
CRYPT::_xorCryptData crypt_data_xor;
bool bStandard;
bool bXOR;
bool bAES;
};
}

View File

@ -531,7 +531,6 @@ namespace DocFileFormat
{
if (m_FibBase.nFib > 0 && m_FibBase.nFib <= Fib1995)
{
m_RgLw97.cbMac = reader.ReadInt32();//32
/*m_FibWord97.fcSpare0 = */reader.ReadInt32();
/*m_FibWord97.fcSpare1 = */reader.ReadInt32();
/*m_FibWord97.fcSpare2 = */reader.ReadInt32();
@ -1220,9 +1219,12 @@ namespace DocFileFormat
if (m_FibBase.nFib > Fib1995)
csw = reader.ReadUInt16(); //32
if (m_FibBase.nFib > Fib1995 || m_FibBase.nFib == 0)
{
if (m_FibBase.nFib > 0 && m_FibBase.nFib <= Fib1995)
{
m_RgLw97.cbMac = reader.ReadInt32();//32
}
else if (m_FibBase.nFib > Fib1995 || m_FibBase.nFib == 0)
{
//read the RgW97
reader.ReadBytes( 26, false ); //34
m_RgW97.lidFE = reader.ReadUInt16(); //60
@ -1231,7 +1233,7 @@ namespace DocFileFormat
//read the RgLW97
m_RgLw97.cbMac = reader.ReadInt32(); //64
m_RgLw97.cbMac = reader.ReadInt32(); //64
}
reset(reader);
}

View File

@ -41,23 +41,20 @@ namespace DocFileFormat
GeometryBooleanProperties(unsigned int op)
{
fFillOK = FormatUtils::BitmaskToBool (op, 0x1);
fFillShadeShapeOK = FormatUtils::BitmaskToBool (op, 0x2);
fGtextOK = FormatUtils::BitmaskToBool (op, 0x4);
fLineOK = FormatUtils::BitmaskToBool (op, 0x8);
f3DOK = FormatUtils::BitmaskToBool (op, 0x10);
fShadowOK = FormatUtils::BitmaskToBool (op, 0x20);
fUsefFillOK = FormatUtils::BitmaskToBool (op, 0x10000);
fUsefFillShadeShapeOK = FormatUtils::BitmaskToBool (op, 0x20000);
fUsefGtextOK = FormatUtils::BitmaskToBool (op, 0x40000);
fUsefLineOK = FormatUtils::BitmaskToBool (op, 0x80000);
fUsef3DOK = FormatUtils::BitmaskToBool (op, 0x100000);
fUsefShadowOK = FormatUtils::BitmaskToBool (op, 0x200000);
fUsefShadowOK = GETBIT(op, 8);
fUsef3DOK = GETBIT(op, 9);
fUsefLineOK = GETBIT(op, 10);
fUsefGtextOK = GETBIT(op, 11);
fUsefFillShadeShapeOK = GETBIT(op, 12);
fUsefFillOK = GETBIT(op, 13);
fShadowOK = GETBIT(op, 22);
f3DOK = GETBIT(op, 23);
fLineOK = GETBIT(op, 24);
fGtextOK = GETBIT(op, 25);
fFillShadeShapeOK = GETBIT(op, 26);
fFillOK = GETBIT(op, 27);
}
public:
bool fFillOK;
bool fFillShadeShapeOK;
bool fGtextOK;

View File

@ -53,7 +53,6 @@ namespace DocFileFormat
PathParser (const unsigned char* pSegmentInfo, unsigned int pSegmentInfoSize, const unsigned char* pVertices, unsigned int pVerticesSize, std::vector<_guides> & guides)
{
int offset = 6;
if ((pSegmentInfo != NULL) && (pSegmentInfoSize > 0))
{
@ -63,6 +62,7 @@ namespace DocFileFormat
unsigned short cbElement = 4;
int offset = 6;
if (cb == 0xfff0)
cbElement = 2;
@ -86,24 +86,27 @@ namespace DocFileFormat
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pVertices, 2, pVerticesSize);
unsigned short cb = FormatUtils::BytesToUInt16(pVertices, 4, pVerticesSize);
unsigned short cbElement = cb;
unsigned short cbElement = 4;
if (cb == 0xfff0)
cbElement = 4;
cbElement = 2;
int offset = 6;
for (unsigned short i = 0; i < nElems; ++i)
{
POINT point;
if (cbElement == 4)
{
point.x = FormatUtils::BytesToInt16(pVertices + offset, (i * cbElement), pVerticesSize - offset);
point.y = FormatUtils::BytesToInt16(pVertices + offset, (i * cbElement) + (cbElement / 2), pVerticesSize - offset);
point.x = FormatUtils::BytesToInt32(pVertices + offset, 0, pVerticesSize - offset);
point.y = FormatUtils::BytesToInt32(pVertices + offset + cbElement, 0 , pVerticesSize - offset);
}
else
{
point.x = FormatUtils::BytesToInt32(pVertices + offset, (i * cbElement), pVerticesSize - offset);
point.y = FormatUtils::BytesToInt32(pVertices + offset, (i * cbElement) + (cbElement / 2), pVerticesSize - offset);
point.x = FormatUtils::BytesToInt16(pVertices + offset, 0, pVerticesSize - offset);
point.y = FormatUtils::BytesToInt16(pVertices + offset + cbElement, 0 , pVerticesSize - offset);
}
offset += cbElement * 2;
LONG lMinF = (LONG)0x80000000;
if (lMinF <= point.x)

View File

@ -71,7 +71,6 @@ namespace DocFileFormat
fUsefLockAgainstUngrouping = FormatUtils::BitmaskToBool(op,0x2000000);
}
public:
bool fLockAgainstGrouping;
bool fLockAdjustHandles;

View File

@ -49,15 +49,15 @@ namespace DocFileFormat
PropertyId_fFlipH=63,
//Protection
fLockAgainstUngrouping=118,
fLockRotation=119,
fLockAspectRatio=120,
fLockPosition=121,
fLockAgainstSelect=122,
fLockCropping=123,
fLockVertices=124,
fLockText=125,
fLockAdjustHandles=126,
//fLockAgainstUngrouping=118,
//fLockRotation=119,
//fLockAspectRatio=120,
//fLockPosition=121,
//fLockAgainstSelect=122,
//fLockCropping=123,
//fLockVertices=124,
//fLockText=125,
//fLockAdjustHandles=126,
protectionBooleans=127,
//Text
@ -75,10 +75,7 @@ namespace DocFileFormat
txdir=139,
ccol=140,
dzColMargin=141,
fSelectText=187,
fAutoTextMargin=188,
fRotateText=189,
fFitShapeToText=190,
textBooleanProperties=191,
//GeoText
@ -89,21 +86,21 @@ namespace DocFileFormat
gtextSpacing=196,
gtextFont=197,
gtextCSSFont=198,
gtextFReverseRows=240,
fGtext=241,
gtextFVertical=242,
gtextFKern=243,
gtextFTight=244,
gtextFStretch=245,
gtextFShrinkFit=246,
gtextFBestFit=247,
gtextFNormalize=248,
gtextFDxMeasure=249,
gtextFBold=250,
gtextFItalic=251,
gtextFUnderline=252,
gtextFShadow=253,
gtextFSmallcaps=254,
//gtextFReverseRows=240,
//fGtext=241,
//gtextFVertical=242,
//gtextFKern=243,
//gtextFTight=244,
//gtextFStretch=245,
//gtextFShrinkFit=246,
//gtextFBestFit=247,
//gtextFNormalize=248,
//gtextFDxMeasure=249,
//gtextFBold=250,
//gtextFItalic=251,
//gtextFUnderline=252,
//gtextFShadow=253,
//gtextFSmallcaps=254,
geometryTextBooleanProperties=255,
//BLIP
@ -128,10 +125,7 @@ namespace DocFileFormat
movie=274,
pictureRecolor=282,
picturePreserveGrays=313,
fRewind=314,
fLooping=315,
pictureGray=317,
pictureBiLevel=318,
blipBooleanProperties=319,
//Geometry
@ -161,12 +155,7 @@ namespace DocFileFormat
pInscribe=343,
cxk=344,
pFragments=345,
fColumnLineOK=377,
fShadowOK=378,
f3DOK=379,
fLineOK=380,
fGtextOK=381,
fFillShadeShapeOK=382,
geometryBooleans=383,
//Fill Style
@ -205,12 +194,6 @@ namespace DocFileFormat
fillBackColorExt=418,
fillBackColorExtMod=420,
fRecolorFillAsPicture=441,
fUseShapeAnchor=442,
fFilled=443,
fHitTestFill=444,
fillShape=445,
fillUseRect=446,
fillStyleBooleanProperties=447,
//Line Style
@ -238,12 +221,7 @@ namespace DocFileFormat
lineEndArrowLength=469,
lineJoinStyle=470,
lineEndCapStyle=471,
fInsetPen=505,
fInsetPenOK=506,
fArrowheadsOK=507,
fLine=508,
fHitTestLine=509,
lineFillShape=510,
lineStyleBooleans=511,
//Shadow Style
@ -265,7 +243,7 @@ namespace DocFileFormat
shadowWeight=527,
shadowOriginX=528,
shadowOriginY=529,
fShadow=574,
shadowStyleBooleanProperties=575,
//Perspective Style
@ -281,6 +259,7 @@ namespace DocFileFormat
perspectiveWeight=585,
perspectiveOriginX=586,
perspectiveOriginY=587,
perspectiveStyleBooleanProperties=639,
//3D Object
@ -293,9 +272,7 @@ namespace DocFileFormat
c3DExtrudePlane=646,
c3DExtrusionColor=647,
c3DCrMod=648,
f3D=700,
fc3DMetallic=701,
fc3DUseExtrusionColor=702,
threeDObjectBooleanProperties=703,
//3D Style
@ -326,10 +303,7 @@ namespace DocFileFormat
c3DFillY=728,
c3DFillZ=729,
c3DFillIntensity=730,
fc3DConstrainRotation=763,
fc3DRotationCenterAuto=764,
fc3DParallel=765,
fc3DKeyHarsh=766,
threeDStyleBooleanProperties=767,
//Shape
@ -343,14 +317,7 @@ namespace DocFileFormat
dgmNodeKind=778,
dgmLayoutMRU=779,
wzEquationXML=780,
fPolicyLabel=822,
fPolicyBarcode=823,
fFlipHQFE5152=824,
fFlipVQFE5152=825,
fPreferRelativeResize=827,
fLockShapeType=828,
fInitiator=829,
fDeleteAttachedObject=830,
shapeBooleans=831,
//Callout
@ -410,16 +377,9 @@ namespace DocFileFormat
wzAccessBlob=936,
metroBlob=937,
dhgt=938,
fLayoutInCell=944,
fIsBullet=945,
fStandardHR=946,
fNoshadeHR=947,
fHorizRule=948,
fUserDrawn=949,
fAllowOverlap=950,
fReallyHidden=951,
fScriptAnchor=952,
groupShapeBooleans = 959,
relRotation = 964,
//Unknown HTML
@ -622,7 +582,19 @@ namespace DocFileFormat
{
if (Options[i]->fComplex && Options[i]->op > 0)
{
Options[i]->opComplex = std::shared_ptr<unsigned char>(Reader->ReadBytes( Options[i]->op, true ));
unsigned int size = Options[i]->op;
if (Options[i]->pid == 0x0145 ||
Options[i]->pid == 0x0146 ||
Options[i]->pid == 0x0197 ||
Options[i]->pid == 0x0156 ||
Options[i]->pid == 0x0155 ||
Options[i]->pid == 0x0151 ||
Options[i]->pid == 0x0152 ||
Options[i]->pid == 0x0157 ||
Options[i]->pid == 0x0158)//mso arrays
size += 6;
Options[i]->opComplex = std::shared_ptr<unsigned char>(Reader->ReadBytes( size, true ));
}
OptionsByID.insert(std::make_pair(Options[i]->pid, Options[i]));

View File

@ -1,56 +1,92 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "Utils.h"
#include "../../../DesktopEditor/xml/include/xmlutils.h"
void Common::readAllShapeTypes(const OOX::CPath& oPath, std::vector<std::wstring>& aShapetypes)
{
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
while ( false != oReader.ReadNextNode() )
{
std::wstring sName = oReader.GetName();
if(_T("v:shapetype") == sName)
{
std::wstring sXml = oReader.GetOuterXml();
if(false == sXml.empty())
aShapetypes.push_back(sXml);
}
}
}
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
namespace DocFileFormat
{
class ThreeDStyleBooleanProperties
{
public:
ThreeDStyleBooleanProperties(unsigned int op)
{
fUsefc3DConstrainRotation = GETBIT(op, 0);
fUsefc3DRotationCenterAuto = GETBIT(op, 1);
fUsefc3DParallel = GETBIT(op, 2);
fUsefc3DKeyHarsh = GETBIT(op, 3);
fUsefc3DFillHarsh = GETBIT(op, 4);
fc3DConstrainRotation = GETBIT(op, 16);
fc3DRotationCenterAuto = GETBIT(op, 17);
fc3DParallel = GETBIT(op, 18);
fc3DKeyHarsh = GETBIT(op, 19);
fc3DFillHarsh = GETBIT(op, 20);
}
bool fUsefc3DConstrainRotation;
bool fUsefc3DRotationCenterAuto;
bool fUsefc3DParallel;
bool fUsefc3DKeyHarsh;
bool fUsefc3DFillHarsh;
bool fc3DConstrainRotation;
bool fc3DRotationCenterAuto;
bool fc3DParallel;
bool fc3DKeyHarsh;
bool fc3DFillHarsh;
};
class ThreeDObjectBooleanProperties
{
public:
ThreeDObjectBooleanProperties(unsigned int op)
{
fUsef3D = GETBIT(op, 0);
fUsefc3DMetallic = GETBIT(op, 1);
fUsefc3DUseExtrusionColor = GETBIT(op, 2);
fUsefc3DLightFace = GETBIT(op, 3);
// 12 unused
f3D = GETBIT(op, 16);
fc3DMetallic = GETBIT(op, 17);
fc3DUseExtrusionColor = GETBIT(op, 18);
fc3DLightFace = GETBIT(op, 19);
}
bool fUsef3D;
bool fUsefc3DMetallic;
bool fUsefc3DUseExtrusionColor;
bool fUsefc3DLightFace;
bool f3D;
bool fc3DMetallic;
bool fc3DUseExtrusionColor;
bool fc3DLightFace;
};
}

View File

@ -66,25 +66,23 @@ namespace DocFileFormat
ole->Program = L"Word.Document";
}
m_pXmlWriter->WriteNodeBegin( L"o:OLEObject", TRUE );
int relID = -1;
if ( ole->bLinked )
{
int relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
m_pXmlWriter->WriteAttribute( L"r:id", ( std::wstring( L"rId" ) + FormatUtils::IntToWideString( relID ) ));
m_pXmlWriter->WriteAttribute( L"Type", L"Link" );
m_pXmlWriter->WriteAttribute( L"UpdateMode", ole->UpdateMode);
}
else
{
int relID = -1;
{
if (ole->isEmbedded)
relID = m_context->_docx->RegisterPackage(_caller, ole->ClipboardFormat);
else
relID = m_context->_docx->RegisterOLEObject(_caller, ole->ClipboardFormat);
m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) );
m_pXmlWriter->WriteAttribute( L"Type", L"Embed" );
copyEmbeddedObject( ole );
@ -94,7 +92,8 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"ShapeID", _shapeId);
m_pXmlWriter->WriteAttribute( L"DrawAspect", L"Content" );
m_pXmlWriter->WriteAttribute( L"ObjectID", ole->ObjectId);
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"o:OLEObject" );
}

View File

@ -165,15 +165,21 @@ namespace DocFileFormat
{
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
std::list<std::wstring> entries = storageInp->entries(path);
std::list<std::wstring> entries = storageInp->entries_with_prefix(path);
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it)
{
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + L"/"+ (*it));
std::wstring stream_name_open = (*it);
std::wstring stream_name_create = (*it);
if (stream_name_open[0] < 32)
stream_name_open = stream_name_open.substr(1);
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + L"/"+ stream_name_open);
if (stream_inp == NULL)continue;
POLE::uint64 size = stream_inp->size();
POLE::Stream *stream_out = new POLE::Stream(storageOut, *it, true, size);
POLE::Stream *stream_out = new POLE::Stream(storageOut, stream_name_create, true, size);
if (stream_out)
{

View File

@ -171,7 +171,7 @@ namespace DocFileFormat
if ( (*iter)->tapx != NULL )
{
std::vector<short> tableGrid;
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, false);
TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, NULL, false);
(*iter)->tapx->Convert( tpMapping );
RELEASEOBJECT( tpMapping );
}

View File

@ -267,7 +267,6 @@ namespace DocFileFormat
}
m_pXmlWriter->WriteNodeBegin( L"v:shape", true );
m_pXmlWriter->WriteAttribute( L"type", std::wstring( L"#" + VMLShapeTypeMapping::GenerateTypeId(&type)));
count_vml_objects++;
@ -275,15 +274,9 @@ namespace DocFileFormat
m_shapeId = L"_x0000_s" + FormatUtils::IntToWideString(1024 + count_vml_objects);
m_pXmlWriter->WriteAttribute( L"id", m_shapeId);
m_pXmlWriter->WriteAttribute( L"type", std::wstring( L"#" + VMLShapeTypeMapping::GenerateTypeId(&type)));
if (m_isOlePreview)
{
m_pXmlWriter->WriteAttribute( L"o:ole", L"" );
}
else if (m_isBullete)
{
m_pXmlWriter->WriteAttribute( L"o:bullet", L"1" );
}
//todooo oбъединить с shape_mapping
for (size_t i = 0; i < options.size(); i++)
@ -423,6 +416,15 @@ namespace DocFileFormat
strStyle += L"width:" + strWidth + L"pt;" + L"height:" + strHeight + L"pt;";
m_pXmlWriter->WriteAttribute( L"style", strStyle);
if (m_isOlePreview)
{
m_pXmlWriter->WriteAttribute( L"o:ole", L"t" );
}
else if (m_isBullete)
{
m_pXmlWriter->WriteAttribute( L"o:bullet", L"1" );
}
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
if (CopyPicture(pict))

View File

@ -39,6 +39,7 @@
#include "OfficeDrawing/Shapetypes/RectangleType.h"
#include "OfficeDrawing/Shapetypes/RoundedRectangleType.h"
#include "OfficeDrawing/threeDBooleanProperties.h"
#include "OfficeDrawing/OfficeArtClientTextbox.h"
#include "OfficeDrawing/DiagramBooleanProperties.h"
#include "OfficeDrawing/GeometryBooleanProperties.h"
@ -277,10 +278,13 @@ namespace DocFileFormat
double ShadowOriginY = 0;
unsigned int xCoord = 0;
unsigned int yCoord = 0;
bool stroked = true;
bool filled = true;
bool bStroked = true;
bool bFilled = true;
bool hasTextbox = false;
bool layoutInCell = true; //anmeldebogenfos.doc
bool b3D = false;
bool bShadow = false;
int ndxTextLeft = -1;
int ndyTextTop = -1;
@ -292,16 +296,16 @@ namespace DocFileFormat
int nAdjValues = 0;
int nLTxID = -1;
std::wstring sTextboxStyle;
ShadowStyleBooleanProperties shadowBoolean(0);
std::wstring sTextboxStyle;
OptionEntryPtr opSegmentInfo;
OptionEntryPtr opVerticles;
OptionEntryPtr opInscribe;
OptionEntryPtr opConnectAngles;
OptionEntryPtr opConnectLocs;
ThreeDStyleBooleanProperties threeDStyleProps_(0);
for (size_t i = 0; i < options.size(); i++)
{
OptionEntryPtr & iter = options[i];
@ -313,12 +317,19 @@ namespace DocFileFormat
GeometryBooleanProperties booleans(iter->op);
if (booleans.fUsefLineOK && !booleans.fLineOK)
{
stroked = false;
bStroked = false;
}
if (booleans.fUsefFillOK && !booleans.fFillOK)
{
filled = false;
bFilled = false;
}
if (booleans.fUsef3DOK && booleans.f3DOK)
{
b3D = true;
}
if (booleans.fUsefShadowOK && booleans.fShadowOK)
{
bShadow = true;
}
}
break;
@ -327,7 +338,12 @@ namespace DocFileFormat
FillStyleBooleanProperties booleans(iter->op);
if (booleans.fUsefFilled && !booleans.fFilled)
{
filled = false;
bFilled = false;
}
if (booleans.fUsefUseShapeAnchor && booleans.fUseShapeAnchor)
{
appendValueAttribute(&m_fill, L"rotate", L"t");
}
}break;
case lineStyleBooleans:
@ -335,7 +351,7 @@ namespace DocFileFormat
LineStyleBooleanProperties booleans(iter->op);
if (booleans.fUsefLine && !booleans.fLine)
{
stroked = false;
bStroked = false;
}
}
break;
@ -536,6 +552,7 @@ namespace DocFileFormat
case fillFocus:
{
appendValueAttribute(&m_fill, L"focus", ( FormatUtils::IntToWideString( iter->op ) + L"%" ));
appendValueAttribute(&m_fill, L"focussize", L"");
}break;
case fillType:
{
@ -575,7 +592,7 @@ namespace DocFileFormat
break;
case fillBackOpacity:
{
appendValueAttribute(&m_fill, L"opacity2", (FormatUtils::IntToWideString(iter->op) + L"f"));
appendValueAttribute(&m_fill, L"o:opacity2", (FormatUtils::IntToWideString(iter->op) + L"f"));
}break;
// SHADOW
case shadowType:
@ -620,7 +637,8 @@ namespace DocFileFormat
}break;
case shadowStyleBooleanProperties:
{
shadowBoolean = ShadowStyleBooleanProperties(iter->op);
ShadowStyleBooleanProperties props(iter->op);
}break;
// OLE
case pictureId:
@ -649,11 +667,19 @@ namespace DocFileFormat
appendValueAttribute(&m_imagedata, L"o:title", FormatUtils::XmlEncode(name));
}break;
// 3D STYLE
case f3D:
case threeDStyleBooleanProperties:
{
threeDStyleProps_ = ThreeDStyleBooleanProperties(iter->op);
}break;
case threeDObjectBooleanProperties:
break;
{
ThreeDObjectBooleanProperties booleans(iter->op);
if (booleans.fUsef3D && !booleans.f3D) b3D = false;
}break;
case c3DRenderMode:
{
}break;
case c3DExtrudeBackward:
{
EmuValue backwardValue( (int)iter->op );
@ -686,28 +712,34 @@ namespace DocFileFormat
appendValueAttribute(&m_3dstyle, L"color", color);
}break;
case c3DSkewAngle:
if (threeDStyleProps_.fUsefc3DParallel && threeDStyleProps_.fc3DParallel)
{
FixedPointNumber skewAngle( iter->op );
appendValueAttribute(&m_3dstyle, L"skewangle", FormatUtils::DoubleToWideString( skewAngle.ToAngle() ));
}break;
case c3DXViewpoint:
if (threeDStyleProps_.fUsefc3DParallel && !threeDStyleProps_.fc3DParallel)
{
ViewPointX = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DYViewpoint:
{
if (threeDStyleProps_.fUsefc3DParallel && !threeDStyleProps_.fc3DParallel)
{
ViewPointY = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DZViewpoint:
if (threeDStyleProps_.fUsefc3DParallel && !threeDStyleProps_.fc3DParallel)
{
ViewPointZ = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DOriginX:
if (threeDStyleProps_.fUsefc3DParallel && !threeDStyleProps_.fc3DParallel)
{
FixedPointNumber dOriginX( iter->op );
viewPointOriginX = ( dOriginX.Integral / 65536.0 );
}break;
case c3DOriginY:
if (threeDStyleProps_.fUsefc3DParallel && !threeDStyleProps_.fc3DParallel)
{
FixedPointNumber dOriginY( iter->op );
viewPointOriginY = (dOriginY.Integral / 65536.0 );
@ -831,12 +863,12 @@ namespace DocFileFormat
xCoord = 21600;
yCoord = 21600;
}
if ( !filled )
if ( !bFilled )
{
m_pXmlWriter->WriteAttribute( L"filled", L"f" );
}
if ( !stroked )
if ( !bStroked )
{
m_pXmlWriter->WriteAttribute( L"stroked", L"f" );
}
@ -927,60 +959,59 @@ namespace DocFileFormat
// write shadow
if (m_shadow.GetAttributeCount() > 0)
{
if (shadowBoolean.fShadow)
{
appendValueAttribute(&m_shadow, L"on", L"t" );
}
appendValueAttribute(&m_shadow, L"on", bShadow ? L"t" : L"f" );
m_pXmlWriter->WriteString(m_shadow.GetXMLString());
}
//write the viewpoint
if ( ( ViewPointX != 0 ) || ( ViewPointY != 0 ) || ( ViewPointZ != 0 ) )
{
std::wstring viewPoint;
if ( ViewPointX != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointX ) + L"pt";
}
viewPoint += L",";
if ( ViewPointY != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointY ) + L"pt";
}
viewPoint += L",";
if ( ViewPointZ != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointZ ) + L"pt";
}
appendValueAttribute(&m_3dstyle, L"viewpoint", viewPoint);
}
// write the viewpointorigin
if ( ( viewPointOriginX != 0 ) || ( viewPointOriginY != 0 ) )
{
std::wstring viewPointOrigin;
if ( viewPointOriginX != 0 )
{
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginX, L"%.2f" );
}
if ( viewPointOriginY != 0 )
{
viewPointOrigin += L",";
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginY, L"%.2f" );
}
appendValueAttribute(&m_3dstyle, L"viewpointorigin", viewPointOrigin);
}
//write 3d style
if (m_3dstyle.GetAttributeCount() > 0)
{
appendValueAttribute(&m_3dstyle, L"v:ext", L"view" );
appendValueAttribute(&m_3dstyle, L"on", L"t" );
//write the viewpoint
if ( ( ViewPointX != 0 ) || ( ViewPointY != 0 ) || ( ViewPointZ != 0 ) )
if (b3D)
{
std::wstring viewPoint;
if ( ViewPointX != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointX ) + L"pt";
}
viewPoint += L",";
if ( ViewPointY != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointY ) + L"pt";
}
viewPoint += L",";
if ( ViewPointZ != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointZ ) + L"pt";
}
appendValueAttribute(&m_3dstyle, L"viewpoint", viewPoint);
appendValueAttribute(&m_3dstyle, L"v:ext", L"view" ); //??? вытащить
}
// write the viewpointorigin
if ( ( viewPointOriginX != 0 ) || ( viewPointOriginY != 0 ) )
{
std::wstring viewPointOrigin;
if ( viewPointOriginX != 0 )
{
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginX, L"%.2f" );
}
if ( viewPointOriginY != 0 )
{
viewPointOrigin += L",";
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginY, L"%.2f" );
}
appendValueAttribute(&m_3dstyle, L"viewpointorigin", viewPointOrigin);
}
appendValueAttribute(&m_3dstyle, L"on", b3D ? L"t" : L"f" );
m_pXmlWriter->WriteString(m_3dstyle.GetXMLString());
}
// write wrap

View File

@ -134,10 +134,11 @@ namespace DocFileFormat
// Path
m_pXmlWriter->WriteNodeBegin( L"v:path", true );
m_pXmlWriter->WriteAttribute( L"o:extrusionok", L"f");
if (_isInlineShape)
{
m_pXmlWriter->WriteAttribute( L"o:extrusionok", L"f");
m_pXmlWriter->WriteAttribute( L"gradientshapeok", L"t" );
m_pXmlWriter->WriteAttribute( L"o:connecttype", L"rect" );
}

View File

@ -174,11 +174,24 @@ namespace DocFileFormat
}
}
if (FIB->m_FibBase.fEncrypted && !FIB->m_bOlderVersion)
if (FIB->m_FibBase.fEncrypted)
{
encryptionHeader = new EncryptionHeader (FIB, TableStream);
encryptionHeader = new EncryptionHeader (FIB, TableStream);
if (encryptionHeader->bStandard)
if (encryptionHeader->bXOR)
{
CRYPT::XORDecryptor Decryptor(1, encryptionHeader->crypt_data_xor.key, encryptionHeader->crypt_data_xor.hash, m_sPassword);
if (Decryptor.IsVerify() == false)
{
Clear();
if (m_sPassword.empty() ) return AVS_ERROR_DRM;
else return AVS_ERROR_PASSWORD;
}
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
}
else if (encryptionHeader->bStandard)
{
CRYPT::RC4Decryptor Decryptor(encryptionHeader->crypt_data_rc4, m_sPassword);
@ -192,7 +205,7 @@ namespace DocFileFormat
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
}
else
else if (encryptionHeader->bAES)
{
CRYPT::ECMADecryptor Decryptor;
@ -208,9 +221,8 @@ namespace DocFileFormat
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
}
FIB->reset(VirtualStreamReader(WordDocumentStream, 68, false));
FIB->reset(VirtualStreamReader(WordDocumentStream, bOlderVersion ? 36 : 68, false));
}
else if (FIB->m_FibBase.fEncrypted) return AVS_ERROR_DRM;
//------------------------------------------------------------------------------------------------------------------
POLE::Stream * Summary = NULL;
@ -629,19 +641,37 @@ namespace DocFileFormat
for( std::list<std::wstring>::iterator it = entries_files.begin(); it != entries_files.end(); ++it )
{
std::wstring fullname = path + *it;
DecryptStream(fullname, storageIn, storageOut, Decryptor );
std::wstring fullname_create = path + *it;
if (it->at(0) < 32)
{
*it = it->substr(1); // without prefix
}
std::wstring fullname_open = path + *it;
bool bDecrypt = false;
if ( std::wstring::npos != fullname_open.find(L"WordDocument") ||
std::wstring::npos != fullname_open.find(L"Data") ||
std::wstring::npos != fullname_open.find(L"Table") ||
(std::wstring::npos != fullname_open.find(L"SummaryInformation") &&
encryptionHeader->bAES && encryptionHeader->crypt_data_aes.fDocProps)
)
{
bDecrypt = true;
}
DecryptStream(fullname_open, storageIn, fullname_create, storageOut, Decryptor, bDecrypt);
}
}
bool WordDocument::DecryptStream(std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
bool WordDocument::DecryptStream(std::wstring streamName_open, POLE::Storage * storageIn, std::wstring streamName_create, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor, bool bDecrypt)
{
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
POLE::Stream *stream = new POLE::Stream(storageIn, streamName_open);
if (!stream) return false;
stream->seek(0);
POLE::uint64 size_stream = stream->size();
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName_create, true, size_stream);
if (!streamNew) return false;
unsigned char* data_stream = new unsigned char[size_stream];
@ -650,9 +680,9 @@ namespace DocFileFormat
unsigned char* data_store = NULL;
int size_data_store = 0;
if ( std::wstring::npos != streamName.find(L"WordDocument") )
if ( std::wstring::npos != streamName_open.find(L"WordDocument") )
{
size_data_store = 68;
size_data_store = bOlderVersion ? 36 : 68;
data_store = new unsigned char[size_data_store];
}
@ -662,14 +692,16 @@ namespace DocFileFormat
size_t size_block = 0x200;
unsigned long block = 0;
for (POLE::uint64 pos = 0; pos < size_stream; pos += size_block, block++)
for (POLE::uint64 pos = /*bOlderVersion ? size_data_store :*/ 0; pos < size_stream; pos += size_block, block++)
{
if (pos + size_block > size_stream)
size_block = size_stream - pos;
Decryptor->Decrypt((char*)data_stream + pos, size_block, block);
if (bDecrypt)
{
Decryptor->Decrypt((char*)data_stream + pos, size_block, block);
}
}
if (data_store)
memcpy(data_stream, data_store, size_data_store);

View File

@ -107,7 +107,7 @@ namespace DocFileFormat
private:
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
bool DecryptStream (std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
bool DecryptStream (std::wstring streamName_open, POLE::Storage * storageIn, std::wstring streamName_create, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor, bool bDecrypt);
void DecryptStream (int level, std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
inline OfficeArtContent* GetOfficeArt ()

View File

@ -21,8 +21,6 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS \
@ -237,6 +235,7 @@ HEADERS += \
../../DocDocxConverter/OfficeDrawing/RecordFactory.h \
../../DocDocxConverter/OfficeDrawing/RegularContainer.h \
../../DocDocxConverter/OfficeDrawing/ShadowStyleBooleanProperties.h \
../../DocDocxConverter/OfficeDrawing/threeDBooleanProperties.h \
../../DocDocxConverter/OfficeDrawing/Shape.h \
../../DocDocxConverter/OfficeDrawing/ShapeContainer.h \
../../DocDocxConverter/OfficeDrawing/ShapeOptions.h \

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -894,6 +895,10 @@
RelativePath="..\..\DocDocxConverter\OfficeDrawing\SplitMenuColorContainer.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OfficeDrawing\threeDBooleanProperties.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OfficeDrawing\UnknownRecord.h"
>

View File

@ -318,20 +318,29 @@ public:
docRGB Color;
CThemeColor ThemeColor;
bool bValue;
bool bColor;
bool bThemeColor;
Shd()
{
Value = shd_Nil;
bValue = false;
bColor = false;
bThemeColor = false;
}
std::wstring ToString()
{
std::wstring sShd;
if(bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
if(bValue || bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
{
sShd += L"<w:shd w:val=\"clear\" w:color=\"auto\"";
sShd += L"<w:shd";
if(bValue)
{
if(shd_Nil == Value)
sShd += L" w:val=\"nil\"";
else
sShd += L" w:val=\"clear\"";
}
sShd += L" w:color=\"auto\"";
if(bColor)
sShd += L" w:fill=\"" + Color.ToString() + L"\"";
if(bThemeColor && ThemeColor.IsNoEmpty())

View File

@ -266,7 +266,10 @@ private:
Shd* pShd = static_cast<Shd*>(poResult);
switch(type)
{
case c_oSerShdType::Value: pShd->Value = m_oBufferedStream.GetUChar();break;
case c_oSerShdType::Value:
pShd->bValue = true;
pShd->Value = m_oBufferedStream.GetUChar();
break;
case c_oSerShdType::Color:
pShd->bColor = true;
pShd->Color = ReadColor();
@ -451,11 +454,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
orPr->bShd = true;
orPr->Shd = oShd.ToString();
}
orPr->bShd = true;
orPr->Shd = oShd.ToString();
break;
}
case c_oSerProp_rPrType::RStyle:
@ -801,15 +801,7 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
else
{
std::wstring sShd(L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>");
pCStringWriter->WriteString(sShd);
}
pCStringWriter->WriteString(oShd.ToString());
break;
}
case c_oSerProp_pPrType::WidowControl:
@ -1782,11 +1774,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
else if( c_oSerProp_tblPrType::tblpPr == type )
{
@ -2244,10 +2233,7 @@ public:
bCellShd = true;
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
pCStringWriter->WriteString(oShd.ToString());
}
else if( c_oSerProp_cellPrType::TableCellBorders == type )
{

View File

@ -416,7 +416,7 @@ namespace MathEquation
virtual void BeginEquation()
{
int nCurPos = WriteItemStart(BinDocxRW::c_oSerParType::OMath);
int nCurPos = WriteItemStart(BinDocxRW::c_oSer_OMathContentType::OMath);
m_aEquationStack.push(nCurPos);
}
virtual void EndEquation()
@ -618,7 +618,7 @@ namespace MathEquation
nRows = m_aRowsCounter.top();
m_aRowsCounter.pop();
}
int nPos = m_oStream.GetPosition();
int nPos = 0;
if (!m_aRowsPosCounter.empty())
{
nPos = m_aRowsPosCounter.top();

View File

@ -155,7 +155,8 @@ extern int g_nCurFormatVersion;
Footnotes = 10,
Endnotes = 11,
Background = 12,
VbaProject = 13
VbaProject = 13,
App = 14
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
@ -1021,6 +1022,11 @@ extern int g_nCurFormatVersion;
PrEndPos = 10,
PrRef = 11
};}
namespace c_oSerApp{enum c_oSerApp
{
Application = 0,
AppVersion = 1
};}
namespace c_oSerDocPr{enum c_oSerDocPr
{
Id = 0,

View File

@ -87,10 +87,14 @@ namespace BinDocxRW
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, pHdrFtr->m_arrShapeTypes);
smart_ptr<OOX::IFileContainer> oldRels = m_pOfficeDrawingConverter->GetRels();
m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_pOfficeDrawingConverter->ClearShapeTypes();
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
m_pOfficeDrawingConverter->SetRels(oldRels);
}
}

View File

@ -60,6 +60,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/HeaderFooter.h"
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
namespace BinDocxRW
{
@ -3016,25 +3017,13 @@ namespace BinDocxRW
bool m_bWriteSectPr;//Записывать ли свойства верхнего уровня в данном экземпляре BinaryOtherTableWriter
//---------------------------------
BinaryDocumentTableWriter(ParamsWriter& oParamsWriter, ParamsDocumentWriter& oParamsDocumentWriter, std::map<int, bool>* mapIgnoreComments, BinaryHeaderFooterTableWriter* oBinaryHeaderFooterTableWriter):
m_oParamsWriter(oParamsWriter), m_oParamsDocumentWriter(oParamsDocumentWriter),m_oBcw(oParamsWriter),bpPrs(oParamsWriter, oBinaryHeaderFooterTableWriter),brPrs(oParamsWriter),btblPrs(oParamsWriter),m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter),m_mapIgnoreComments(mapIgnoreComments)
m_oParamsWriter(oParamsWriter), m_oParamsDocumentWriter(oParamsDocumentWriter), m_oBcw(oParamsWriter),bpPrs(oParamsWriter, oBinaryHeaderFooterTableWriter),brPrs(oParamsWriter),btblPrs(oParamsWriter),m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter),m_mapIgnoreComments(mapIgnoreComments)
{
pBackground = NULL;
pSectPr = NULL;
poDocument = NULL;
m_bWriteSectPr = false;
}
void prepareOfficeDrawingConverter(NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, OOX::IFileContainer *rels, std::vector<std::wstring>& aShapeTypes)
{
smart_ptr<OOX::IFileContainer> oldRels = pOfficeDrawingConverter->GetRels();
pOfficeDrawingConverter->SetRels(rels);
for(size_t i = 0, length = aShapeTypes.size(); i < length; ++i)
{
std::wstring& sShapeType = aShapeTypes[i];
pOfficeDrawingConverter->AddShapeType(sShapeType);
}
pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteVbaProject(OOX::VbaProject& oVbaProject)
{
m_oBcw.m_oStream.StartRecord(0);
@ -3131,23 +3120,6 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
}
//Write JsaProject
if (NULL != poDocument)
{
smart_ptr<OOX::File> pFile = poDocument->Get(OOX::FileTypes::JsaProject);
if (pFile.IsInit() && OOX::FileTypes::JsaProject == pFile->type())
{
OOX::JsaProject& jsaProject = pFile.as<OOX::JsaProject>();
BYTE* pData = NULL;
DWORD nBytesCount;
if(NSFile::CFileBinary::ReadAllBytes(jsaProject.filename().GetPath(), &pData, nBytesCount))
{
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject);
m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount);
m_oBcw.WriteItemEnd(nCurPos);
}
}
}
}
void WriteBackground (OOX::Logic::CBackground* pBackground)
{
@ -7741,7 +7713,7 @@ namespace BinDocxRW
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oFootnotes.m_arrFootnote, oParamsDocumentWriter, oFootnotes.m_arrShapeTypes);
WriteNotes(oFootnotes.m_arrFootnote, oParamsDocumentWriter);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteEndnotes(OOX::CEndnotes& oEndnotes)
@ -7750,20 +7722,27 @@ namespace BinDocxRW
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oEndnotes.m_arrEndnote, oParamsDocumentWriter, oEndnotes.m_arrShapeTypes);
WriteNotes(oEndnotes.m_arrEndnote, oParamsDocumentWriter);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteNotes(const std::vector<OOX::CFtnEdn*>& arrNotes, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<std::wstring>& arrShapeTypes)
void WriteNotes(const std::vector<OOX::CFtnEdn*>& arrNotes, ParamsDocumentWriter& oParamsDocumentWriter)
{
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, NULL);
smart_ptr<OOX::IFileContainer> oldRels = m_pOfficeDrawingConverter->GetRels();
m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_pOfficeDrawingConverter->ClearShapeTypes();
int nCurPos = 0;
for(size_t i = 0 ; i < arrNotes.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::Note);
WriteNote(*arrNotes[i], oParamsDocumentWriter, arrShapeTypes);
WriteNote(*arrNotes[i], oBinaryDocumentTableWriter);
m_oBcw.WriteItemEnd(nCurPos);
}
m_pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteNote(const OOX::CFtnEdn& oFtnEdn, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<std::wstring>& arrShapeTypes)
void WriteNote(const OOX::CFtnEdn& oFtnEdn, BinaryDocumentTableWriter & oBinaryDocumentTableWriter)
{
int nCurPos = 0;
if(oFtnEdn.m_oType.IsInit())
@ -7778,16 +7757,44 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteLONG(oFtnEdn.m_oId->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::NoteContent);
oBinaryDocumentTableWriter.WriteDocumentContent(oFtnEdn.m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
}
};
class BinaryAppTableWriter
{
BinaryCommonWriter m_oBcw;
ParamsWriter& m_oParamsWriter;
public:
BinaryAppTableWriter(ParamsWriter& oParamsWriter):
m_oBcw(oParamsWriter),m_oParamsWriter(oParamsWriter)
{
}
void Write(OOX::CApp& oApp)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteProperties(oApp);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteProperties(OOX::CApp& oApp)
{
int nCurPos = 0;
if (oApp.m_sApplication.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::Application);
m_oBcw.m_oStream.WriteStringW3(oApp.m_sApplication.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oApp.m_sAppVersion.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::AppVersion);
m_oBcw.m_oStream.WriteStringW3(oApp.m_sAppVersion.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
class BinaryFileWriter
{
BinaryCommonWriter m_oBcw;
@ -7864,101 +7871,102 @@ namespace BinDocxRW
OOX::CDocx oDocx = OOX::CDocx(OOX::CPath(sDir));
m_oParamsWriter.m_poTheme = oDocx.GetTheme();
m_oParamsWriter.m_oSettings = oDocx.GetSettings();
m_oParamsWriter.m_poTheme = oDocx.m_pTheme;
m_oParamsWriter.m_oSettings = oDocx.m_pSettings;
*oBufferedStream.m_pTheme = smart_ptr<PPTX::Theme>(oDocx.GetTheme());
*oBufferedStream.m_pTheme = smart_ptr<PPTX::Theme>(oDocx.m_pTheme);
oBufferedStream.m_pTheme->AddRef();
OOX::CFontTable* pFontTable = oDocx.GetFontTable();
if(NULL != pFontTable)
m_oParamsWriter.m_pFontProcessor->setFontTable(pFontTable);
if(NULL != oDocx.m_pFontTable)
m_oParamsWriter.m_pFontProcessor->setFontTable(oDocx.m_pFontTable);
//ищем первый SectPr и расставляем pageBreak
OOX::CDocument* poDocument = oDocx.GetDocument();
if (poDocument == NULL) return;
OOX::Logic::CSectionProperty* pFirstSectPr = poDocument->m_oSectPr.GetPointer();
if (oDocx.m_pDocument == NULL) return;
OOX::Logic::CSectionProperty* pFirstSectPr = oDocx.m_pDocument->m_oSectPr.GetPointer();
this->WriteMainTableStart();
int nCurPos = 0;
//Write Settings
OOX::CSettings* pSettings = oDocx.GetSettings();
if(NULL != pSettings)
if(NULL != oDocx.m_pSettings)
{
BinDocxRW::BinarySettingsTableWriter oBinarySettingsTableWriter(m_oParamsWriter);
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Settings);
oBinarySettingsTableWriter.Write(*pSettings);
oBinarySettingsTableWriter.Write(*oDocx.m_pSettings);
this->WriteTableEnd(nCurPos);
}
//Write Comments
OOX::CComments* pComments = oDocx.GetComments();
OOX::CCommentsExt* pCommentsExt = oDocx.GetCommentsExt();
OOX::CPeople* pPeople = oDocx.GetPeople();
if(NULL != pComments)
if(NULL != oDocx.m_pComments)
{
BinDocxRW::BinaryCommentsTableWriter oBinaryCommentsTableWriter(m_oParamsWriter);
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Comments);
oBinaryCommentsTableWriter.Write(*pComments, pCommentsExt, pPeople, m_oParamsWriter.m_mapIgnoreComments);
oBinaryCommentsTableWriter.Write(*oDocx.m_pComments, oDocx.m_pCommentsExt, oDocx.m_pPeople, m_oParamsWriter.m_mapIgnoreComments);
this->WriteTableEnd(nCurPos);
}
//Write StyleTable
OOX::CStyles* pStyles = oDocx.GetStyles();
BinDocxRW::BinaryStyleTableWriter oBinaryStyleTableWriter(m_oParamsWriter);
if(NULL != pStyles)
if(NULL != oDocx.m_pStyles)
{
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Style);
oBinaryStyleTableWriter.Write(*pStyles);
oBinaryStyleTableWriter.Write(*oDocx.m_pStyles);
this->WriteTableEnd(nCurPos);
}
//Write Numbering
OOX::CNumbering* pNumbering = oDocx.GetNumbering();
BinDocxRW::BinaryNumberingTableWriter oBinaryNumberingTableWriter(m_oParamsWriter);
if(NULL != pNumbering)
if(NULL != oDocx.m_pNumbering)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Numbering);
oBinaryNumberingTableWriter.Write(*pNumbering);
oBinaryNumberingTableWriter.Write(*oDocx.m_pNumbering);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryNotesTableWriter oBinaryNotesWriter(m_oParamsWriter);
//Write Footnotes
OOX::CFootnotes* pFootnotes = oDocx.GetFootnotes();
if(NULL != pFootnotes)
if(NULL != oDocx.m_pFootnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Footnotes);
oBinaryNotesWriter.WriteFootnotes(*pFootnotes);
oBinaryNotesWriter.WriteFootnotes(*oDocx.m_pFootnotes);
this->WriteTableEnd(nCurPos);
}
//Write Endnotes
OOX::CEndnotes* pEndnotes = oDocx.GetEndnotes();
if(NULL != pEndnotes)
if(NULL != oDocx.m_pEndnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Endnotes);
oBinaryNotesWriter.WriteEndnotes(*pEndnotes);
oBinaryNotesWriter.WriteEndnotes(*oDocx.m_pEndnotes);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, poDocument, &m_oParamsWriter.m_mapIgnoreComments);
//Write App
if(NULL != oDocx.m_pApp)
{
BinDocxRW::BinaryAppTableWriter oBinaryAppWriter(m_oParamsWriter);
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::App);
oBinaryAppWriter.Write(*oDocx.m_pApp);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, oDocx.m_pDocument, &m_oParamsWriter.m_mapIgnoreComments);
//Write DocumentTable
ParamsDocumentWriter oParamsDocumentWriter(poDocument);
ParamsDocumentWriter oParamsDocumentWriter(oDocx.m_pDocument);
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
//DocumentTable всегда пишем последней, чтобы сначала заполнить все вспомогательные структуры, а при заполении документа, вызывать методы типа Style_Add...
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, &oBinaryHeaderFooterTableWriter);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_oParamsWriter.m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, poDocument->m_arrShapeTypes);
m_oParamsWriter.m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_oParamsWriter.m_pOfficeDrawingConverter->ClearShapeTypes();
oBinaryDocumentTableWriter.pSectPr = pFirstSectPr;
oBinaryDocumentTableWriter.pBackground = poDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.poDocument = poDocument;
oBinaryDocumentTableWriter.pBackground = oDocx.m_pDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.poDocument = oDocx.m_pDocument;
oBinaryDocumentTableWriter.m_bWriteSectPr = true;
//Write Vba
if(NULL != oDocx.m_pVbaProject)
{
@ -7966,9 +7974,22 @@ namespace BinDocxRW
oBinaryDocumentTableWriter.WriteVbaProject(*oDocx.m_pVbaProject);
this->WriteTableEnd(nCurPos);
}
//Write JsaProject
if (NULL != oDocx.m_pJsaProject)
{
BYTE* pData = NULL;
DWORD nBytesCount;
if(NSFile::CFileBinary::ReadAllBytes(oDocx.m_pJsaProject->filename().GetPath(), &pData, nBytesCount))
{
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject);
m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount);
m_oBcw.WriteItemEnd(nCurPos);
}
}
// Write content
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Document);
oBinaryDocumentTableWriter.Write(poDocument->m_arrItems);
oBinaryDocumentTableWriter.Write(oDocx.m_pDocument->m_arrItems);
this->WriteTableEnd(nCurPos);
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::HdrFtr);

View File

@ -85,7 +85,7 @@ namespace BinXlsxRW{
sMediaPath = pathMediaDir.GetPath();
sEmbedPath = pathEmbedDir.GetPath();
}
bool CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
int 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);
@ -97,11 +97,10 @@ namespace BinXlsxRW{
oDrawingConverter.SetMediaDstPath(sMediaDir);
oDrawingConverter.SetEmbedDstPath(sEmbedDir);
BinXlsxRW::BinaryFileReader oBinaryFileReader;
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
return true;
BinXlsxRW::BinaryFileReader oBinaryFileReader;
return oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
}
bool CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
int CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
{
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
@ -137,10 +136,10 @@ namespace BinXlsxRW{
oOfficeDrawingConverter.SetFontPicker(pFontPicker);
BinXlsxRW::BinaryFileWriter oBinaryFileWriter(fp);
oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
int result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
RELEASEOBJECT(pFontPicker);
return true;
return result;
}
bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilepath, const long& lChartNumber)
{

View File

@ -62,8 +62,8 @@ namespace BinXlsxRW {
static void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath);
bool loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
bool saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
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);
bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilename, const long& lChartNumber);

View File

@ -16,8 +16,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
USE_AVSOFFICESTUDIO_XMLUTILS \
SOLUTION_ASCOFFICEDOCXFILE2 \
#DISABLE_FILE_DOWNLOADER \

View File

@ -22,8 +22,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -777,7 +777,8 @@ void docx_conversion_context::process_section(std::wostream & strm, odf_reader::
{
double page_width = 0;
const odf_reader::page_layout_instance * pp = root()->odf_context().pageLayoutContainer().page_layout_first();
if (pp)
if ((pp) && (pp->properties()))
{
odf_reader::style_page_layout_properties_attlist & attr_page = pp->properties()->attlist_;
if (attr_page.fo_page_width_)
@ -1169,7 +1170,7 @@ void docx_conversion_context::docx_convert_delayed()
{
odf_reader::office_element * elm = delayed_elements_.front();
elm->docx_convert(*this);
delayed_elements_.pop_front();
delayed_elements_.erase(delayed_elements_.begin(), delayed_elements_.begin() + 1);
}
delayed_converting_=false;
}

View File

@ -763,7 +763,7 @@ private:
std::wstring automatic_parent_style_;
std::wstring current_master_page_name_;
std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
std::vector<std::wstring> list_style_stack_;
bool first_element_list_item_;
bool page_break_after_;
@ -781,9 +781,9 @@ private:
int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
NoteType process_note_;
std::list<odf_reader::office_element *> delayed_elements_;
std::vector<odf_reader::office_element*> delayed_elements_;
std::list< const odf_reader::style_text_properties * > text_properties_stack_;
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

@ -73,7 +73,7 @@ public:
private:
docx_conversion_context & context_;
std::wstring table_style_;
std::list<std::wstring> table_row_style_stack_;
std::vector<std::wstring> table_row_style_stack_;
std::wstring default_row_cell_style_name_;
int current_table_column_;
unsigned int columns_spanned_num_;
@ -188,7 +188,7 @@ public:
private:
docx_conversion_context & context_;
std::list<docx_table_state> table_states_;
std::vector<docx_table_state> table_states_;
};

View File

@ -82,7 +82,7 @@ private:
std::wstring table_style_;
std::list<std::wstring> table_row_style_stack_;
std::vector<std::wstring> table_row_style_stack_;
std::wstring default_row_cell_style_name_;
int current_table_column_;
@ -214,7 +214,7 @@ public:
private:
std::wstringstream output_stream_;
pptx_conversion_context & context_;
std::list<pptx_table_state> table_states_;
std::vector<pptx_table_state> table_states_;
};
void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::style_instance *> & style_inst, oox::pptx_conversion_context & Context);

View File

@ -126,13 +126,13 @@ private:
std::wstring base_style_name_;
odf_types::style_family::type base_style_family_;//Presentation Or SpreadSheet
/////////////lists////////////
std::list<std::wstring> list_style_stack_;
//-------------------------------------------------------------------------------
std::vector<std::wstring> list_style_stack_;
bool first_element_list_item_;
// счетчик для нумерации имен созданных в процессе конвертации стилей
int new_list_style_number_;
// цепочки переименований нумераций
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;
int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
boost::unordered_map<std::wstring, std::wstring> list_style_renames_; // цепочки переименований нумераций
void write_list_styles(std::wostream & strm);
//void write_list_properties(std::wostream & strm);

View File

@ -233,8 +233,9 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
Context.set_paragraph_state (false);
Context.set_run_state (false);
Context.get_math_context().base_font_size_ = baseFontHeight_;
Context.start_math_formula();
Context.get_math_context().base_font_size_ = baseFontHeight_;
office_math_->oox_convert(Context.get_math_context());
Context.end_math_formula();

View File

@ -61,6 +61,7 @@ private:
document_context::document_context() : impl_( new document_context::Impl() )
{
level = 0;
}
document_context::~document_context()

View File

@ -45,10 +45,11 @@ class document_context
public:
document_context();
virtual ~document_context();
public:
void set_last_paragraph(text::paragraph * Paragraph);
text::paragraph * get_last_paragraph();
int level;
private:
class Impl;

View File

@ -151,6 +151,8 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
{
if (page_layout_instance * lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{
Context.next_dump_page_properties(true);
lastPageLayout->docx_serialize(Context.output_stream(), Context);
//Context.remove_page_properties();
}

View File

@ -82,11 +82,11 @@ void chart_chart::add_child_element( xml::sax * Reader, const std::wstring & Ns,
{
if CP_CHECK_NAME(L"text", L"tracked-changes")
{
CP_CREATE_ELEMENT(tracked_changes_);
//CP_CREATE_ELEMENT(tracked_changes_);
}
else if CP_CHECK_NAME(L"table", L"content-validations")
{
CP_CREATE_ELEMENT(content_validations_);
//CP_CREATE_ELEMENT(content_validations_);
}
else
CP_CREATE_ELEMENT(content_);

View File

@ -213,7 +213,7 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context &
double kf_max_width_ms =1.;
const page_layout_instance * pp = Context.root()->odf_context().pageLayoutContainer().page_layout_first();//
if (pp)
if ((pp) && (pp->properties()))
{
style_page_layout_properties_attlist & attr_page = pp->properties()->attlist_;
if (attr_page.fo_page_width_)

View File

@ -312,14 +312,29 @@ void paragraph::afterCreate(document_context * Context)
// вызывается сразу после создания объекта
if (Context)
{
// выставляем у предыдущего параграфа указатель на следующий (т.е. на вновь созданный)
if (paragraph * prevPar = Context->get_last_paragraph())
prevPar->set_next(this);
// запоминаем в контексте вновь созданный параграф
Context->set_last_paragraph(this);
Context->level++;
// выставляем у предыдущего параграфа указатель на следующий (т.е. на вновь созданный)
if (Context->level == 1)
{
if (paragraph * prevPar = Context->get_last_paragraph())
{
prevPar->set_next(this);
}
// запоминаем в контексте вновь созданный параграф
Context->set_last_paragraph(this);
}
}
}
void paragraph::afterReadContent(document_context * Context)
{
if (Context)
{
Context->level--;
}
}
const wchar_t * emptyParagraphContent = L"<w:pPr></w:pPr><w:r><w:rPr></w:rPr></w:r>";
const wchar_t * emptyParagraphDrawing = L"<w:p><w:pPr></w:pPr></w:p>";
@ -435,27 +450,6 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
std::wostream & _Wostream = Context.output_stream();
if (next_par_)
{
// проверяем не сменит ли следующий параграф свойства страницы.
// если да — устанавливаем контексту флаг на то что необходимо в конце текущего параграфа
// распечатать свойства раздела
//проверить ... не она ли текущая - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const std::wstring & next_styleName = next_par_->attrs_.text_style_name_;
const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(next_styleName);
if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName))
{
Context.next_dump_page_properties(true);
is_empty = false;
}
}
if (next_section_ || next_end_section_)
{
Context.get_section_context().get().is_dump_ = true;
is_empty = false;
}
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(styleName);
if (masterPageName)
@ -469,6 +463,27 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty = false;
}
if (next_par_)
{
// проверяем не сменит ли следующий параграф свойства страницы.
// если да — устанавливаем контексту флаг на то что необходимо в текущем параграфе
// распечатать свойства раздела/секции
//проверить ... не она ли текущая - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const std::wstring & next_styleName = next_par_->attrs_.text_style_name_;
const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(next_styleName);
if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName))
{
Context.next_dump_page_properties(true);
is_empty = false;
}
}
if (next_section_/* || next_end_section_*/)
{
Context.get_section_context().get().is_dump_ = true;
is_empty = false;
}
std::wstringstream strm;
if (Context.process_page_properties(strm))
{
@ -604,7 +619,10 @@ void h::afterCreate()
{
paragraph_.afterCreate( getContext() );
}
void h::afterReadContent()
{
paragraph_.afterReadContent( getContext() );
}
void h::docx_convert(oox::docx_conversion_context & Context)
{
paragraph_.docx_convert(Context);
@ -627,7 +645,10 @@ void p::afterCreate()
{
paragraph_.afterCreate( getContext() );
}
void p::afterReadContent()
{
paragraph_.afterReadContent( getContext() );
}
std::wostream & p::text_to_stream(std::wostream & _Wostream) const
{
return paragraph_.text_to_stream(_Wostream);

View File

@ -73,7 +73,8 @@ public:
}
void afterCreate(document_context * ctx);
void afterReadContent(document_context * ctx);
void docx_convert (oox::docx_conversion_context & Context) ;
void xlsx_convert (oox::xlsx_conversion_context & Context) ;
void pptx_convert (oox::pptx_conversion_context & Context) ;
@ -114,7 +115,9 @@ public:
void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual void afterCreate();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void afterReadContent();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
paragraph paragraph_;
@ -151,8 +154,9 @@ public:
void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual void afterCreate();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void afterReadContent();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
p(){};
paragraph paragraph_;
@ -245,7 +249,8 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void afterCreate();
virtual void afterCreate();
virtual void afterReadContent();
private:

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -49,7 +49,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -2,27 +2,25 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormatWriterLib", "..\source\win32\OdfFormat.vcproj", "{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}"
ProjectSection(ProjectDependencies) = postProject
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{609ED938-3CA8-4BED-B363-25096D4C4812} = {609ED938-3CA8-4BED-B363-25096D4C4812}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oox2OdfConverter", "..\source\win32\Oox2OdfConverter.vcproj", "{BEE01B53-244A-44E6-8947-ED9342D9247E}"
ProjectSection(ProjectDependencies) = postProject
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFileWriterTest", "OdfFileWTest.vcproj", "{FBA8446A-150F-4A10-B4DA-1022048D6473}"
ProjectSection(ProjectDependencies) = postProject
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
{BEE01B53-244A-44E6-8947-ED9342D9247E} = {BEE01B53-244A-44E6-8947-ED9342D9247E}
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\..\Common\DocxFormat\Projects\DocxFormat2005.vcproj", "{A100103A-353E-45E8-A9B8-90B87CC5C0B0}"
@ -31,32 +29,32 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormulasConvert", "..\..
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\..\DesktopEditor\graphics\graphics_vs2005.vcproj", "{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}"
ProjectSection(ProjectDependencies) = postProject
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfCommon", "..\..\ASCOfficeOdfFile\win32\cpcommon.vcproj", "{609ED938-3CA8-4BED-B363-25096D4C4812}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster", "..\..\DesktopEditor\raster\raster_vs2005.vcproj", "{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}"
ProjectSection(ProjectDependencies) = postProject
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jbig2", "..\..\DesktopEditor\raster\JBig2\win32\jbig2.vcproj", "{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "..\..\DesktopEditor\cximage\CxImage\cximage_vs2005.vcproj", "{BC52A07C-A797-423D-8C4F-8678805BBB36}"
ProjectSection(ProjectDependencies) = postProject
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
{818753F2-DBB9-4D3B-898A-A604309BE470} = {818753F2-DBB9-4D3B-898A-A604309BE470}
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jasper", "..\..\DesktopEditor\cximage\jasper\jasper_vs2005.vcproj", "{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}"

View File

@ -22,8 +22,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -1624,9 +1624,9 @@ void odf_chart_context::set_cash(std::wstring format, std::vector<std::wstring>
ref1 = std::wstring(L"local-table.") + utils::getColAddress(start_col) + boost::lexical_cast<std::wstring>(start_row);
//
if (by_row)
ref2 = std::wstring(L"local-table.") + utils::getColAddress(start_col) + boost::lexical_cast<std::wstring>(start_row + count_cash_values);
ref2 = std::wstring(L"local-table.") + utils::getColAddress(start_col) + std::to_wstring(start_row + count_cash_values);
else
ref2 = std::wstring(L"local-table.") + utils::getColAddress(start_col + count_cash_values) + boost::lexical_cast<std::wstring>(start_row);
ref2 = std::wstring(L"local-table.") + utils::getColAddress(start_col + count_cash_values) + std::to_wstring(start_row);
ref = ref1 + L":" + ref2;
}

View File

@ -313,25 +313,25 @@ void odf_number_styles_context::create_default(int oox_num_fmt, std::wstring for
default:
/////////////////////////////////// с неопределенным formatCode .. он задается в файле
if (oox_num_fmt >=5 && oox_num_fmt <=8)state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=43 && oox_num_fmt <=44)state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=5 && oox_num_fmt <=8) state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=43 && oox_num_fmt <=44) state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=27 && oox_num_fmt <=31)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=50 && oox_num_fmt <=54)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=57 && oox_num_fmt <=58)state.ods_type =office_value_type::Date;
if (oox_num_fmt ==36)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=27 && oox_num_fmt <=31) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=50 && oox_num_fmt <=54) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=57 && oox_num_fmt <=58) state.ods_type =office_value_type::Date;
if (oox_num_fmt ==36) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=32 && oox_num_fmt <=35)state.ods_type =office_value_type::Time;
if (oox_num_fmt >=55 && oox_num_fmt <=56)state.ods_type =office_value_type::Time;
if (oox_num_fmt >=32 && oox_num_fmt <=35) state.ods_type =office_value_type::Time;
if (oox_num_fmt >=55 && oox_num_fmt <=56) state.ods_type =office_value_type::Time;
if (oox_num_fmt >=60 && oox_num_fmt <=62)state.ods_type =office_value_type::Float;
if (oox_num_fmt >=69 && oox_num_fmt <=70)state.ods_type =office_value_type::Float;
if (oox_num_fmt >=60 && oox_num_fmt <=62) state.ods_type =office_value_type::Float;
if (oox_num_fmt >=69 && oox_num_fmt <=70) state.ods_type =office_value_type::Float;
if (oox_num_fmt >=67 && oox_num_fmt <=68)state.ods_type =office_value_type::Percentage;
if (oox_num_fmt >=67 && oox_num_fmt <=68) state.ods_type =office_value_type::Percentage;
if (oox_num_fmt >=71 && oox_num_fmt <=74)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=75 && oox_num_fmt <=80)state.ods_type =office_value_type::Time;
if (oox_num_fmt ==81)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=71 && oox_num_fmt <=74) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=75 && oox_num_fmt <=80) state.ods_type =office_value_type::Time;
if (oox_num_fmt ==81) state.ods_type =office_value_type::Date;
}
boost::algorithm::split(state.format_code, formatCode, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
@ -402,53 +402,122 @@ void odf_number_styles_context::create_number_style(number_format_state & state,
{
office_element_ptr elm;
create_numbers(state, elm);
root_elm->add_child_element(elm);
create_numbers(state, elm, root_elm);
}
}
void odf_number_styles_context::create_numbers(number_format_state & state, office_element_ptr & elm)
void odf_number_styles_context::create_numbers(number_format_state & state, office_element_ptr & elm, office_element_ptr & root_elm)
{
optional< int>::Type min_digit, min_decimal;
create_element(L"number", L"number", elm, odf_context_);
styles_elments.push_back(elm);
office_element_ptr elm_text;
number_number* number_number_ = dynamic_cast<number_number*>(elm.get());
if (!number_number_) return;
if (number_number_)
bool bText = false;
int indText = -1;
int indNumber = -1;
if (state.format_code[0].empty())
{
if (state.format_code[0].length()>0)
//формат не определен .. дефолтный
min_digit =1;
}
else
{
std::vector<std::wstring> splits;
boost::algorithm::split(splits, state.format_code[0], boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < splits.size(); i++)
{
std::wstring str1,str2;
boost::wregex re1(L"([^0-9.,]+)");
boost::wsmatch result;
boost::wregex re2(L"([^#.,]+)");
str1 = boost::regex_replace(state.format_code[0], re1, L"",boost::match_default | boost::format_all);
str2 = boost::regex_replace(state.format_code[0], re2, L"",boost::match_default | boost::format_all);
if (str1.length()<str2.length())str1=str2;
std::vector<std::wstring> numbers;
boost::algorithm::split(numbers, str1, boost::algorithm::is_any_of(L".,"), boost::algorithm::token_compress_on);
int ind=1;//
for (size_t i = 0;i < numbers.size(); i++)
if (std::wstring::npos != splits[i].find(L"\""))
{
if (numbers[i].length()<1)continue;
if (ind==1)min_digit= numbers[i].length();
if (ind==2)min_decimal= numbers[i].length();
ind++;
bText = true;
indText = i;
break;
}
}
for (size_t i = 0; i < splits.size(); i++)
{
if (i != indText)
{
indNumber = i;
break;
}
}
std::wstring str1,str2;
boost::wregex re1(L"([^0-9.,]+)");
boost::wsmatch result;
boost::wregex re2(L"([^#.,]+)");
str1 = boost::regex_replace(splits[indNumber], re1, L"", boost::match_default | boost::format_all);
str2 = boost::regex_replace(splits[indNumber], re2, L"", boost::match_default | boost::format_all);
if (str1.length() < str2.length()) str1 = str2;
std::vector<std::wstring> numbers;
boost::algorithm::split(numbers, str1, boost::algorithm::is_any_of(L".,"), boost::algorithm::token_compress_on);
int ind = 1;//
for (size_t i = 0; i < numbers.size(); i++)
{
if (numbers[i].empty())continue;
if (ind == 1) min_digit= numbers[i].length();
if (ind == 2) min_decimal= numbers[i].length();
ind++;
}
if (bText && root_elm)
{
int res1 = (int) splits[indText].find(L"\"");
int res2 = (int) splits[indText].find(L"\"", res1 + 1);
if (res2 > 0)
{
std::wstring text = splits[indText].substr(res1 + 1, res2 - res1 - 1);
if (!text.empty())
{
if (indText < indNumber) text = text + L" ";
else text = L" " + text;
create_element(L"number", L"text", elm_text, odf_context_);
number_text* number_text_ = dynamic_cast<number_text*>(elm_text.get());
if (number_text_)
number_text_->add_text(text);
}
}
}
}
number_number_->number_min_integer_digits_ = min_digit;
number_number_->number_decimal_places_ = min_decimal;
if (root_elm)
{
if (bText)
{
number_number_->number_grouping_ = true;
if (indText < indNumber)
{
root_elm->add_child_element(elm_text);
root_elm->add_child_element(elm);
}
else
{
root_elm->add_child_element(elm);
root_elm->add_child_element(elm_text);
}
}
else
{
//формат не определен .. дефолтный
min_digit =1;
root_elm->add_child_element(elm);
}
number_number_->number_min_integer_digits_= min_digit;
number_number_->number_decimal_places_= min_decimal;
//number_number_->number_grouping_ = true;
}
}
void odf_number_styles_context::create_percentage_style(number_format_state & state, office_element_ptr & root_elm)
@ -457,7 +526,8 @@ void odf_number_styles_context::create_percentage_style(number_format_state & st
office_element_ptr elm;
create_numbers(state, elm);
office_element_ptr empty;
create_numbers(state, elm, empty);
root_elm->add_child_element(elm);
create_element(L"number", L"text", elm, odf_context_);
@ -472,9 +542,9 @@ void odf_number_styles_context::create_currency_style(number_format_state & stat
{
create_element(L"number", L"currency-style", root_elm, odf_context_);
{
int res1= state.format_code[0].rfind(L"]");
int res2= state.format_code[0].rfind(L"#");
int res3= state.format_code[0].rfind(L"0");
int res1 = state.format_code[0].rfind(L"]");
int res2 = state.format_code[0].rfind(L"#");
int res3 = state.format_code[0].rfind(L"0");
office_element_ptr elm_symbol;
create_element(L"number", L"currency-symbol", elm_symbol, odf_context_);
@ -485,7 +555,7 @@ void odf_number_styles_context::create_currency_style(number_format_state & stat
{
std::wstring number_country,number_language;
for (long i=0; state.language_code >0 && i < sizeof(LanguageCodeTable)/sizeof(def_language_code); i++)
for (long i = 0; state.language_code > 0 && i < sizeof(LanguageCodeTable)/sizeof(def_language_code); i++)
{
if (LanguageCodeTable[i].id == state.language_code)
{
@ -507,11 +577,12 @@ void odf_number_styles_context::create_currency_style(number_format_state & stat
}
///////////////////
office_element_ptr elm_number;
create_numbers(state, elm_number);
office_element_ptr empty;
create_numbers(state, elm_number, empty);
//////////////////////////////////////////
office_element_ptr elm_text;
create_element(L"number", L"text", elm_text, odf_context_);
number_text* number_text_ = dynamic_cast<number_text*>(elm_text.get());
number_text* number_text_ = dynamic_cast<number_text*>(elm_text.get());
if (number_text_)number_text_->add_text(L" ");
styles_elments.push_back(elm_text);
////////////////////////////////////////////
@ -540,6 +611,7 @@ void odf_number_styles_context::create_date_style(number_format_state & state, o
boost::algorithm::to_lower(s);
boost::wregex re(L"([a-zA-Z]+)(\\W+)");//(L"(\\w+)");
std::list<std::wstring> result;
bool b = boost::regex_split(std::back_inserter(result),s, re);
result.push_back(s);//последний ..выносится - так уж работает boost.regex_split
@ -594,7 +666,7 @@ void odf_number_styles_context::create_date_style(number_format_state & state, o
}
else
{ //////////////////// делитель ////////////////////
if(sz>1)
if(sz > 1)
{
//выкинем "лишние" слэши
XmlUtils::replace_all( s, L"\\", L"");
@ -627,12 +699,12 @@ void odf_number_styles_context::create_time_style(number_format_state & state, o
int res;
int sz=0;
for (std::list<std::wstring>::iterator i=result.begin(); i!=result.end(); ++i)
for (std::list<std::wstring>::iterator it = result.begin(); it != result.end(); ++it)
{
office_element_ptr elm;
s = *i;
s = *it;
sz = s.length();
if ((res=s.find(L"h")) >=0)
if ((res=s.find(L"h")) >= 0)
{
create_element(L"number", L"hours", elm, odf_context_);
number_hours* number_hours_ = dynamic_cast<number_hours*>(elm.get());
@ -670,7 +742,7 @@ void odf_number_styles_context::create_time_style(number_format_state & state, o
else if((res=s.find(L"pm")) <0)//так уж формат делится .. а этот текст нам не нужен
{
//////////////////// делитель ////////////////////
if(sz>1)
if(sz > 1)
{
//выкинем "лишние" слэши
XmlUtils::replace_all( s, L"\\", L"");
@ -700,14 +772,14 @@ void odf_number_styles_context::create_text_style(number_format_state & state, o
void odf_number_styles_context::detect_format(number_format_state & state)
{
if (state.ods_type != office_value_type::Custom)return;
if (state.format_code.size()<1)return;
if (state.format_code.empty())return;
//find [$<Currency String>-<language info>].
boost::wregex re(L"(?:\\[)(?:\\$)(\\S+)?\-(\\S+)(?:\\])");
boost::wsmatch result;
bool b = boost::regex_search(state.format_code[0], result, re);
if (b && result.size()==3)
if (b && result.size() == 3)
{
state.currency_str=result[1];
int code = -1;
@ -720,48 +792,58 @@ void odf_number_styles_context::detect_format(number_format_state & state)
//state.format_code[0] = boost::regex_replace( state.format_code[0],re,L"");
}
if (state.currency_str.length()>0)
if (!state.currency_str.empty() && state.language_code != 0xF400 && state.language_code != 0xF800)
{
state.ods_type = office_value_type::Currency;
return;
}
std::wstring tmp = state.format_code[0];
XmlUtils::GetLower(tmp);
if (state.format_code.size() == 1)//any
//if (state.format_code.size() == 2)//>0, <0
//{
//}
//else if (state.format_code.size() == 3)//>0, <0, ==0
//{
//}
if (state.format_code.size() > 0) //any
{
int res=0;
if ((res=tmp.find(L"at"))>=0 || (res=tmp.find(L"pm"))>=0 ||
(res=tmp.find(L"h"))>=0 || (res=tmp.find(L"s"))>=0 || state.language_code == 0xF400)
std::wstring tmp = state.format_code[0];
XmlUtils::GetLower(tmp);
if (std::wstring::npos != tmp.find(L"at") ||
std::wstring::npos != tmp.find(L"pm") ||
std::wstring::npos != tmp.find(L"h") ||
std::wstring::npos != tmp.find(L"s") || state.language_code == 0xF400)
{
state.ods_type = office_value_type::Time;
if (b)state.format_code[0] = boost::regex_replace( state.format_code[0],re,L"");
if (b)
state.format_code[0] = boost::regex_replace( state.format_code[0], re, L"");
return;
}
if ((res=tmp.find(L"y"))>=0 || (res=tmp.find(L"d"))>=0 || (res=tmp.find(L"m"))>=0)//minutes отсеялись выше
if (std::wstring::npos != tmp.find(L"y") ||
std::wstring::npos != tmp.find(L"d") ||
std::wstring::npos != tmp.find(L"m") || state.language_code == 0xF800)//minutes отсеялись выше
{
state.ods_type = office_value_type::Date;
if (b)state.format_code[0] = boost::regex_replace( state.format_code[0],re,L"");
if (b)
state.format_code[0] = boost::regex_replace( state.format_code[0], re, L"");
return;
}
if ((res=tmp.find(L"%"))>=0)
if (std::wstring::npos != tmp.find(L"%"))
{
state.ods_type = office_value_type::Percentage;
return;
}
state.ods_type = office_value_type::Float;
return;
if (std::wstring::npos != tmp.find(L"#") ||
std::wstring::npos != tmp.find(L"?") ||
std::wstring::npos != tmp.find(L"0"))
{
state.ods_type = office_value_type::Float;
return;
}
}
else if (state.format_code.size() == 2)//>0, <0
{
}
else if (state.format_code.size() == 3)//>0, <0, ==0
{
}
///////////////////////////////
}
}
}

View File

@ -93,7 +93,7 @@ private:
void create_text_style (number_format_state & state, office_element_ptr & root_elm);
void create_percentage_style(number_format_state & state, office_element_ptr & root_elm);
void create_numbers(number_format_state & state, office_element_ptr & elm);
void create_numbers(number_format_state & state, office_element_ptr & elm, office_element_ptr & root_elm);
};

View File

@ -90,6 +90,11 @@ void odp_conversion_context::end_document()
{
odf_conversion_context::end_document();
}
size_t odp_conversion_context::get_pages_count()
{
return root_presentation_->pages_.size();
}
void odp_conversion_context::start_slide()
{
slide_context_.set_styles_context(styles_context());

View File

@ -52,6 +52,8 @@ public:
void start_slide();
void end_slide();
size_t get_pages_count();
void start_master_slide(std::wstring name);
void end_master_slide();

View File

@ -31,7 +31,7 @@
*/
#pragma once
#include <list>
#include <vector>
#include "odp_page_state.h"
#include "odf_table_context.h"
@ -83,7 +83,7 @@ private:
odf_table_context table_context_;
odf_comment_context comment_context_;
std::list<odp_page_state> page_state_list_;
std::vector<odp_page_state> page_state_list_;
int count_slides_;
friend class odp_conversion_context;

View File

@ -115,6 +115,10 @@ void ods_conversion_context::set_table_part_autofilter(bool val)
{
table_context_.set_table_part_autofilter(val);
}
void ods_conversion_context::add_table_part_column(std::wstring name)
{
table_context_.add_table_part_column(name);
}
void ods_conversion_context::end_table_part()
{
table_context_.end_table_part();

View File

@ -110,6 +110,7 @@ public:
void start_table_part (std::wstring name, std::wstring ref);
void end_table_part ();
void set_table_part_autofilter(bool val);
void add_table_part_column(std::wstring name);
void start_conditional_formats();
void end_conditional_formats(){}

View File

@ -78,8 +78,36 @@ void ods_table_context::start_table_part(std::wstring name, std::wstring ref)
table_database_ranges_.root->add_child_element(elm);
table_database_ranges_.elements.push_back(elm);
table_part_state part_state;
part_state.name = name;
part_state.ref = ref;
int r = ref.rfind(L":");
if (r < 0) return;//тута однозначно .. по правилам оох
utils::parsing_ref (ref.substr(0, r), part_state.col_start, part_state.row_start);
utils::parsing_ref (ref.substr(r + 1, ref.size() - r), part_state.col_end, part_state.row_end);
state().table_parts_.push_back(part_state);
}
void ods_table_context::add_table_part_column(std::wstring name)
{
if (state().table_parts_.empty()) return;
size_t column = state().table_parts_.back().columns.size();
std::wstring sCol = utils::getColAddress(state().table_parts_.back().col_start + column - 1);
std::wstring ref;//table name ????
ref += sCol + std::to_wstring(state().table_parts_.back().row_start);
ref += L":";
ref += sCol + std::to_wstring(state().table_parts_.back().row_end);
state().table_parts_.back().columns.push_back(std::make_pair(name, ref));
}
void ods_table_context::set_table_part_autofilter(bool val)
{
if (!val) return;
@ -152,15 +180,13 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
if (sheet_id >=0)
{
int i=0;
for (std::list<ods_table_state>::iterator iter = table_state_list_.begin(); iter != table_state_list_.end(); iter++)
for (size_t i = 0; i < table_state_list_.size(); ++i)
{
if (i == sheet_id)
{
iter->add_definded_expression(elm);
table_state_list_[i].add_definded_expression(elm);
break;
}
i++;
}
}
else
@ -187,31 +213,23 @@ void ods_table_context::add_defined_expression(const std::wstring & name, const
named_expression->table_name_ = name;
named_expression->table_expression_ = odf_value;
if (sheet_id >=0)
if (sheet_id >=0 && sheet_id < table_state_list_.size())
{
int i=0;
for (std::list<ods_table_state>::iterator iter = table_state_list_.begin(); iter != table_state_list_.end(); iter++)
odf_base_cell = table_state_list_[sheet_id].office_table_name_ + L".$A$1";
table_state_list_[sheet_id].add_definded_expression(elm);
if ( printable)
{
if (i == sheet_id)
{
odf_base_cell = iter->office_table_name_ + L".$A$1";
iter->add_definded_expression(elm);
if ( printable)
{
XmlUtils::replace_all( odf_value, L"[", L"");
XmlUtils::replace_all( odf_value, L"]", L"");
XmlUtils::replace_all( odf_value, L";", L" ");
XmlUtils::replace_all( odf_value, L"[", L"");
XmlUtils::replace_all( odf_value, L"]", L"");
XmlUtils::replace_all( odf_value, L";", L" ");
iter->set_print_range(odf_value);
}
break;
}
i++;
table_state_list_[sheet_id].set_print_range(odf_value);
}
}
else
{
if (!table_defined_expressions_.root)create_element(L"table", L"named-expressions",table_defined_expressions_.root,&context_);
if (!table_defined_expressions_.root)create_element(L"table", L"named-expressions", table_defined_expressions_.root,&context_);
table_defined_expressions_.root->add_child_element(elm);
}

View File

@ -52,8 +52,6 @@ struct table_additional_elements_state
std::vector<office_element_ptr> elements;
};
/// \class ods_table_context
class ods_table_context
{
public:
@ -76,13 +74,14 @@ public:
void start_table_part(std::wstring name, std::wstring ref);
void set_table_part_autofilter(bool val);
void add_table_part_column(std::wstring name);
void end_table_part();
private:
ods_conversion_context & context_;
std::list<ods_table_state> table_state_list_;
std::vector<ods_table_state> table_state_list_;
table_additional_elements_state table_defined_expressions_;
table_additional_elements_state table_database_ranges_;

View File

@ -634,15 +634,15 @@ void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col,
if (spanned_cols > 10000)spanned_cols = 1024;
for (std::list<ods_cell_state>::iterator cell = cells_.begin(); cell != cells_.end(); cell++)
for (size_t i = 0; i < cells_.size(); ++i)
{
if (cell->row > end_row) break;
if (cells_[i].row > end_row) break;
if (cell->row >= start_row)
if (cells_[i].row >= start_row)
{
if (cell->col >= start_col)
if (cells_[i].col >= start_col)
{
table_table_cell* cell_elm = dynamic_cast<table_table_cell*>(cell->elm.get());
table_table_cell* cell_elm = dynamic_cast<table_table_cell*>(cells_[i].elm.get());
if (cell_elm == NULL)return;
cell_elm->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
@ -668,6 +668,24 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
}
std::wstring odfFormula = formulas_converter_table.convert_formula(formula);
if (std::wstring::npos != odfFormula.find(L"["))
{
for (size_t i = 0; i < table_parts_.size(); i++)
{
if (table_parts_[i].in_ref(current_table_column_, current_table_row_))
{
for (size_t j = 0; j < table_parts_[i].columns.size(); j ++)
{
std::wstring name = table_parts_[i].name + L"[" + table_parts_[i].columns[j].first + L"]";
//Таблица1[ Сумма за кв. 3 ]
XmlUtils::replace_all(odfFormula, name, table_parts_[i].columns[j].second);
}
break;
}
}
}
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
@ -684,7 +702,7 @@ std::wstring ods_table_state::replace_cell_row(boost::wsmatch const & what)
int col_formula=0, row_formula=0;
utils::parsing_ref(ref_formula, col_formula, row_formula);col_formula--;//инче отсчет с 1
ref_formula = utils::getColAddress(col_formula)+boost::lexical_cast<std::wstring>(row_formula+current_table_row_ -tmp_row_);
ref_formula = utils::getColAddress(col_formula) + std::to_wstring(row_formula +current_table_row_ - tmp_row_);
return ref_formula;

View File

@ -69,7 +69,8 @@ class odf_text_context;
class table_table;
class style;
namespace utils {
namespace utils
{
static std::wstring getColAddress(size_t col)
{
static const size_t r = (L'Z' - L'A' + 1);
@ -78,8 +79,8 @@ namespace utils {
if (r0 > 0)
{
const std::wstring rest = getColAddress(col - r*r0);
const std::wstring res = getColAddress(r0-1) + rest;
const std::wstring rest = getColAddress(col - r * r0);
const std::wstring res = getColAddress(r0 - 1) + rest;
return res;
}
else
@ -210,6 +211,24 @@ struct ods_shared_formula_state
int moving_type; //1 - col, 2 - row
};
struct table_part_state
{
std::wstring name;
std::wstring ref;
int col_start = 0;
int row_start = 0;
int col_end = 0;
int row_end = 0;
bool in_ref(int col, int row)
{
return (col >= col_start && col <= col_end && row >= row_start && row <= row_end);
}
std::vector<std::pair<std::wstring, std::wstring>> columns; //name, odf_ref
};
struct ods_array_formula_state
{
std::wstring formula;
@ -341,12 +360,14 @@ private:
std::vector<office_element_ptr> current_level_;//постоянно меняющийся список уровней ("0-й элемент - сама таблица)
std::list<ods_cell_state> cells_;
std::vector<ods_cell_state> cells_;
long cells_size_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::vector<ods_shared_formula_state> shared_formulas_;
std::vector<table_part_state> table_parts_;
odf_drawing_context drawing_context_;
friend class ods_table_context;

View File

@ -141,7 +141,7 @@ odf_writer::odf_conversion_context* DocxConverter::odf_context()
PPTX::Theme* DocxConverter::oox_theme()
{
if (docx_document)
return docx_document->GetTheme();
return docx_document->m_pTheme;
else
return NULL;
}
@ -151,22 +151,17 @@ OOX::IFileContainer* DocxConverter::current_document()
return oox_current_child_document;
else
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
return dynamic_cast<OOX::IFileContainer*>(oox_doc);
return dynamic_cast<OOX::IFileContainer*>(docx_document->m_pDocument);
}
}
NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId)
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
smart_ptr<OOX::File> oFile;
if (oox_doc)
{
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else
oFile = oox_doc->Find(sId);
}
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else if (docx_document->m_pDocument)
oFile = docx_document->m_pDocument->Find(sId);
return oFile;
}
@ -185,10 +180,9 @@ std::wstring DocxConverter::find_link_by_id (std::wstring sId, int type)
}
if (!ref.empty()) return ref;
OOX::CDocument *oox_doc = docx_document->GetDocument();
if (oox_doc == NULL) return L"";
if (docx_document->m_pDocument == NULL) return L"";
oFile = oox_doc->Find(sId);
oFile = docx_document->m_pDocument->Find(sId);
ref = OoxConverter::find_link_by(oFile, type);
return ref;
@ -221,8 +215,7 @@ void DocxConverter::convertDocument()
void DocxConverter::convert_document()
{
const OOX::CDocument* document = docx_document->GetDocument();
if (!document)return;
if (!docx_document->m_pDocument)return;
std::vector<_section> sections;
//----------------------------------------------------------------------------------------------------------
@ -231,13 +224,13 @@ void DocxConverter::convert_document()
OOX::Logic::CSectionProperty* prev = NULL;
for (size_t i = 0; i < document->m_arrItems.size(); ++i)
for (size_t i = 0; i < docx_document->m_pDocument->m_arrItems.size(); ++i)
{
if ((document->m_arrItems[i]) == NULL) continue;
if ((docx_document->m_pDocument->m_arrItems[i]) == NULL) continue;
if (document->m_arrItems[i]->getType() == OOX::et_w_p)
if (docx_document->m_pDocument->m_arrItems[i]->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(document->m_arrItems[i]);
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(docx_document->m_pDocument->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty))
{
@ -260,15 +253,17 @@ void DocxConverter::convert_document()
}
_section section;
section.props = document->m_oSectPr.GetPointer();
section.props = docx_document->m_pDocument->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = document->m_arrItems.size();
section.end_para = docx_document->m_pDocument->m_arrItems.size();
section.bContinue = compare (prev, section.props);
sections.push_back(section);
//----------------------------------------------------------------------------------------------------------
convert(docx_document->m_pDocument->m_oSectPr.GetPointer(), false, L"Standard");
odt_context->text_context()->clear_params();
for (size_t sect = 0; sect < sections.size(); sect++)
@ -277,7 +272,7 @@ void DocxConverter::convert_document()
for (size_t i = sections[sect].start_para; i < sections[sect].end_para; ++i)
{
convert(document->m_arrItems[i]);
convert(docx_document->m_pDocument->m_arrItems[i]);
}
}
}
@ -1419,7 +1414,7 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi
}
}
}
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection)
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name)
{
if (oox_section_pr == NULL) return;
current_section_properties = NULL;
@ -1444,18 +1439,24 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!last_section_properties && (!bSection || continuous == false || oox_section_pr->m_oTitlePg.IsInit()))
{
last_section_properties = oox_section_pr;
}
else if (!bSection || continuous == false)
bool bDefault = (master_name == L"Standard");
if (!bDefault)
{
apply_HF_from(last_section_properties, oox_section_pr);
if (!last_section_properties && (!bSection || continuous == false || oox_section_pr->m_oTitlePg.IsInit()))
{
last_section_properties = oox_section_pr;
}
else if (!bSection || continuous == false)
{
apply_HF_from(last_section_properties, oox_section_pr);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!bSection || continuous == false)
{
odt_context->page_layout_context()->add_master_page(bSection ? L"" : L"Standard");
odt_context->page_layout_context()->add_master_page(master_name);
}
bool present_header = false;
@ -1572,7 +1573,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
//nullable<SimpleTypes::CDecimalNumber<> > m_oCode;
}
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 1);//подложка - вот в таком она месте :(, причём одна на все разделы, не как в оо
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 1);//подложка - вот в таком она месте :(, причём одна на все разделы, не как в оо
//nullable<ComplexTypes::Word::CTextDirection > m_oTextDirection;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oRtlGutter;
//nullable<ComplexTypes::Word::CVerticalJc > m_oVAlign;
@ -1592,7 +1593,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
if (continuous == false || oox_section_pr->m_oTitlePg.IsInit())
{
OOX::Logic::CSectionProperty* s = last_section_properties;
OOX::Logic::CSectionProperty* s = last_section_properties ? last_section_properties : oox_section_pr;
bool present_title_page = s->m_oTitlePg.IsInit() ? true : false;
bool present_odd_even_pages = odt_context->page_layout_context()->even_and_left_headers_;
@ -1621,7 +1622,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
if (s->m_arrHeaderReference[i]->m_oId.IsInit())
{
convert_hdr_ftr(s->m_arrHeaderReference[i]->m_oId->GetValue());
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 2);
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 2);
}
odt_context->end_header_footer();
@ -1649,7 +1650,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
if (s->m_arrFooterReference[i]->m_oId.IsInit())
{
convert_hdr_ftr(s->m_arrFooterReference[i]->m_oId->GetValue());
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 3);
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 3);
}
odt_context->end_header_footer();
@ -1659,7 +1660,8 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
if (!add_odd_even_pages_footer && present_odd_even_pages) odt_context->add_empty_footer(1);
if (!add_default_footer && (present_odd_even_pages || present_title_page)) odt_context->add_empty_footer(0);
odt_context->is_paragraph_in_current_section_ = true;
if (!bDefault)
odt_context->is_paragraph_in_current_section_ = true;
//odt_context->set_master_page_name(odt_context->page_layout_context()->last_master() ?
// odt_context->page_layout_context()->last_master()->get_name() : L"");
@ -1701,24 +1703,27 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
std::vector<std::pair<double,double>> width_space;
for (size_t i = 0; i< oox_section_pr->m_oCols->m_arrColumns.size(); i++)
if (num_columns > 1) //
{
if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue;
std::vector<std::pair<double,double>> width_space;
double space = default_space_pt;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit())
space = oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace->ToPoints();
double w = -1;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oW.IsInit())
w = oox_section_pr->m_oCols->m_arrColumns[i]->m_oW->ToPoints();
for (size_t i = 0; i < oox_section_pr->m_oCols->m_arrColumns.size(); i++)
{
if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue;
double space = default_space_pt;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit())
space = oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace->ToPoints();
width_space.push_back(std::pair<double,double>(w, space));
}
double w = -1;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oW.IsInit())
w = oox_section_pr->m_oCols->m_arrColumns[i]->m_oW->ToPoints();
width_space.push_back(std::pair<double,double>(w, space));
}
odt_context->add_section_column(width_space);
odt_context->add_section_column(width_space);
}
}
}
void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type)
@ -2335,8 +2340,7 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
if (oox_font_theme == NULL) return;
PPTX::Theme * docx_theme= docx_document->GetTheme();
if (docx_theme == NULL) return;
if (docx_document->m_pTheme == NULL) return;
std::wstring font;
@ -2344,23 +2348,23 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
case SimpleTypes::themeMajorAscii:
case SimpleTypes::themeMajorHAnsi :
font = docx_theme->themeElements.fontScheme.majorFont.latin.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.latin.typeface;
break;
case SimpleTypes::themeMajorBidi:
font = docx_theme->themeElements.fontScheme.majorFont.cs.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.cs.typeface;
break;
case SimpleTypes::themeMajorEastAsia:
font = docx_theme->themeElements.fontScheme.majorFont.ea.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.ea.typeface;
break;
case SimpleTypes::themeMinorAscii:
case SimpleTypes::themeMinorHAnsi:
font = docx_theme->themeElements.fontScheme.minorFont.latin.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.latin.typeface;
break;
case SimpleTypes::themeMinorBidi:
font = docx_theme->themeElements.fontScheme.minorFont.cs.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.cs.typeface;
break;
case SimpleTypes::themeMinorEastAsia:
font = docx_theme->themeElements.fontScheme.minorFont.ea.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.ea.typeface;
break;
}
if (!font.empty()) odf_font_name = font;
@ -2867,11 +2871,9 @@ void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
}
if(theme_color && result == false)
{
PPTX::Theme * docx_theme= docx_document->GetTheme();
std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = docx_theme->themeElements.clrScheme.Scheme.find(theme_color->ToString());
std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = docx_document->m_pTheme->themeElements.clrScheme.Scheme.find(theme_color->ToString());
if (pFind != docx_theme->themeElements.clrScheme.Scheme.end())
if (pFind != docx_document->m_pTheme->themeElements.clrScheme.Scheme.end())
{
PPTX::Logic::UniColor & color = pFind->second;
@ -2890,38 +2892,36 @@ void DocxConverter::convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf_types
PPTX::Logic::ClrMap* DocxConverter::oox_clrMap()
{
//return current_clrMap; todoooo
OOX::CSettings * docx_settings = docx_document->GetSettings();
if (!docx_settings) return NULL;
if (!docx_document->m_pSettings) return NULL;
return docx_settings->m_oClrSchemeMapping.GetPointer();
return docx_document->m_pSettings->m_oClrSchemeMapping.GetPointer();
}
void DocxConverter::convert_settings()
{
if (!odt_context) return;
OOX::CSettings * docx_settings = docx_document->GetSettings();
if (!docx_settings) return;
if (!docx_document->m_pSettings) return;
if (docx_settings->m_oZoom.IsInit())
if (docx_document->m_pSettings->m_oZoom.IsInit())
{
}
if (docx_settings->m_oMirrorMargins.IsInit())
if (docx_document->m_pSettings->m_oMirrorMargins.IsInit())
{
odt_context->page_layout_context()->set_pages_mirrored(true);
}
odt_context->page_layout_context()->even_and_left_headers_ = docx_settings->m_oEvenAndOddHeaders.IsInit();
odt_context->page_layout_context()->even_and_left_headers_ = docx_document->m_pSettings->m_oEvenAndOddHeaders.IsInit();
if (docx_settings->m_oPrintTwoOnOne.IsInit())
if (docx_document->m_pSettings->m_oPrintTwoOnOne.IsInit())
{
if (docx_settings->m_oGutterAtTop.IsInit()){} //portrait
if (docx_document->m_pSettings->m_oGutterAtTop.IsInit()){} //portrait
else {}//landscape
}
if (docx_settings->m_oDefaultTabStop.IsInit())
if (docx_document->m_pSettings->m_oDefaultTabStop.IsInit())
{
_CP_OPT(odf_types::length) length;
convert(docx_settings->m_oDefaultTabStop->m_oVal.GetPointer(), length);
convert(docx_document->m_pSettings->m_oDefaultTabStop->m_oVal.GetPointer(), length);
odf_writer::odf_style_state_ptr state;
if (odt_context->styles_context()->find_odf_default_style_state(odf_types::style_family::Paragraph, state) && state)
@ -2941,7 +2941,7 @@ void DocxConverter::convert_lists_styles()
{
if (!odt_context) return;
OOX::CNumbering * lists_styles = docx_document->GetNumbering();
OOX::CNumbering * lists_styles = docx_document->m_pNumbering;
if (!lists_styles)return;
@ -2979,27 +2979,25 @@ void DocxConverter::convert_lists_styles()
void DocxConverter::convert_styles()
{
if (!odt_context) return;
OOX::CStyles * docx_styles = docx_document->GetStyles();
if (!docx_styles)return;
if (!docx_document->m_pStyles)return;
//nullable<OOX::CLatentStyles > m_oLatentStyles;
convert(docx_styles->m_oDocDefaults.GetPointer());
convert(docx_document->m_pStyles->m_oDocDefaults.GetPointer());
for (size_t i=0; i< docx_styles->m_arrStyle.size(); i++)
for (size_t i=0; i< docx_document->m_pStyles->m_arrStyle.size(); i++)
{
if (docx_styles->m_arrStyle[i] == NULL) continue;
if (docx_document->m_pStyles->m_arrStyle[i] == NULL) continue;
if (!current_font_size.empty())
{
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
}
convert(docx_styles->m_arrStyle[i]);
convert(docx_document->m_pStyles->m_arrStyle[i]);
if (i == 0 && docx_styles->m_arrStyle[i]->m_oDefault.IsInit() && docx_styles->m_arrStyle[i]->m_oDefault->ToBool())
if (i == 0 && docx_document->m_pStyles->m_arrStyle[i]->m_oDefault.IsInit() && docx_document->m_pStyles->m_arrStyle[i]->m_oDefault->ToBool())
{
//NADIE_COMO_TU.docx тут дефолтовый стиль не прописан явно, берем тот что Normal
odf_writer::odf_style_state_ptr def_style_state;
@ -3285,7 +3283,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
if (oox_num_lvl->m_oLvlPicBulletId.IsInit() && oox_num_lvl->m_oLvlPicBulletId->m_oVal.IsInit())
{
int id = oox_num_lvl->m_oLvlPicBulletId->m_oVal->GetValue();
OOX::CNumbering * lists_styles = docx_document->GetNumbering();
OOX::CNumbering * lists_styles = docx_document->m_pNumbering;
for (size_t i = 0; (lists_styles) && (i < lists_styles->m_arrNumPicBullet.size()); i++)
{
@ -3582,12 +3580,11 @@ void DocxConverter::convert(OOX::Logic::CEndnoteReference* oox_ref)
}
void DocxConverter::convert_comment(int oox_comm_id)
{
OOX::CComments * docx_comments = docx_document->GetComments();
if (!docx_comments)return;
if (!docx_document->m_pComments)return;
for (size_t comm = 0 ; comm < docx_comments->m_arrComments.size(); comm++)
for (size_t comm = 0 ; comm < docx_document->m_pComments->m_arrComments.size(); comm++)
{
OOX::CComment* oox_comment = docx_comments->m_arrComments[comm];
OOX::CComment* oox_comment = docx_document->m_pComments->m_arrComments[comm];
if (oox_comment == NULL) continue;
if (oox_comment->m_oId.IsInit() == false) continue;
@ -3611,14 +3608,13 @@ void DocxConverter::convert_comment(int oox_comm_id)
}
void DocxConverter::convert_footnote(int oox_ref_id)
{
OOX::CFootnotes * footnotes = docx_document->GetFootnotes();
if (!footnotes)return;
if (!docx_document->m_pFootnotes)return;
odt_context->start_note(oox_ref_id, 1);
for (size_t n = 0 ; n < footnotes->m_arrFootnote.size(); n++)
for (size_t n = 0 ; n < docx_document->m_pFootnotes->m_arrFootnote.size(); n++)
{
OOX::CFtnEdn* oox_note = footnotes->m_arrFootnote[n];
OOX::CFtnEdn* oox_note = docx_document->m_pFootnotes->m_arrFootnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;
@ -3639,14 +3635,13 @@ void DocxConverter::convert_footnote(int oox_ref_id)
}
void DocxConverter::convert_endnote(int oox_ref_id)
{
OOX::CEndnotes * endnotes = docx_document->GetEndnotes();
if (!endnotes)return;
if (!docx_document->m_pEndnotes)return;
odt_context->start_note(oox_ref_id, 2);
for (size_t n = 0 ; n < endnotes->m_arrEndnote.size(); n++)
for (size_t n = 0 ; n < docx_document->m_pEndnotes->m_arrEndnote.size(); n++)
{
OOX::CFtnEdn* oox_note = endnotes->m_arrEndnote[n];
OOX::CFtnEdn* oox_note = docx_document->m_pEndnotes->m_arrEndnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;

View File

@ -184,7 +184,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CBackground *oox_background, int type);
void convert(OOX::Logic::CSdt *oox_sdt);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name = L"");
void convert(OOX::Logic::CParagraph *oox_paragraph);
void convert(OOX::Logic::CRun *oox_run);
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);

View File

@ -1329,8 +1329,17 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
if (current_theme && current_clrMap)
current_theme->SetColorMap(*current_clrMap);
std::wstring page_name;
if (oox_slide->attrName.IsInit())
odp_context->current_slide().set_page_name(oox_slide->attrName.get());
page_name = oox_slide->attrName.get();
if (page_name.empty())
{
if (type == Slide)
page_name = L"Slide_" + std::to_wstring(odp_context->get_pages_count());
}
odp_context->current_slide().set_page_name(page_name);
if (type != Notes && type != NotesMaster)
{

View File

@ -32,9 +32,10 @@
#include "XlsxConverter.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Comments/Comments.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/CalcChain/CalcChain.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinks.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinkPath.h"
@ -267,6 +268,30 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
pos++;
}
//todooo для оптимизации - перенести мержи в начало
//выносные части таблицы
if (oox_sheet->m_oTableParts.IsInit())
{
for (size_t i=0 ; i < oox_sheet->m_oTableParts->m_arrItems.size(); i++)
{
OOX::Spreadsheet::CTablePart *oox_table_part = oox_sheet->m_oTableParts->m_arrItems[i];
if (!oox_table_part)continue;
if (!oox_table_part->m_oRId.IsInit())continue;
smart_ptr<OOX::File> oFile = oox_sheet->Find(oox_table_part->m_oRId->GetValue());
if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Table == oFile->type())
{
OOX::Spreadsheet::CTableFile* pTableFile = (OOX::Spreadsheet::CTableFile*)oFile.operator->();
if ((pTableFile) && (pTableFile->m_oTable.IsInit()))
{
oox_current_child_document = dynamic_cast<OOX::IFileContainer*>(pTableFile);
convert(pTableFile->m_oTable.GetPointer());
oox_current_child_document = NULL;
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//колонки
ods_context->start_columns();
@ -327,29 +352,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
ods_context->end_conditional_formats();
}
//выносные части таблицы
if (oox_sheet->m_oTableParts.IsInit())
{
for (size_t i=0 ; i < oox_sheet->m_oTableParts->m_arrItems.size(); i++)
{
OOX::Spreadsheet::CTablePart *oox_table_part = oox_sheet->m_oTableParts->m_arrItems[i];
if (!oox_table_part)continue;
if (!oox_table_part->m_oRId.IsInit())continue;
smart_ptr<OOX::File> oFile = oox_sheet->Find(oox_table_part->m_oRId->GetValue());
if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Table == oFile->type())
{
OOX::Spreadsheet::CTableFile* pTableFile = (OOX::Spreadsheet::CTableFile*)oFile.operator->();
if ((pTableFile) && (pTableFile->m_oTable.IsInit()))
{
oox_current_child_document = dynamic_cast<OOX::IFileContainer*>(pTableFile);
convert(pTableFile->m_oTable.GetPointer());
oox_current_child_document = NULL;
}
}
}
}
/////////////////////////////////////////////////////////////////////////
convert(oox_sheet->m_oSheetViews.GetPointer());
convert(oox_sheet->m_oHeaderFooter.GetPointer());
@ -417,11 +420,27 @@ void XlsxConverter::convert(OOX::Spreadsheet::CTable *oox_table_part)
if (oox_table_part->m_oAutoFilter.IsInit())
ods_context->set_table_part_autofilter(true);
convert(oox_table_part->m_oTableColumns.GetPointer());
OoxConverter::convert(oox_table_part->m_oExtLst.GetPointer());
ods_context->end_table_part();
}
void XlsxConverter::convert(OOX::Spreadsheet::CTableColumns *oox_table_part_columns)
{
if (!oox_table_part_columns) return;
for (size_t i = 0; i < oox_table_part_columns->m_arrItems.size(); i++)
{
std::wstring name;
if (oox_table_part_columns->m_arrItems[i]->m_oName.IsInit())
name = oox_table_part_columns->m_arrItems[i]->m_oName.get2();
ods_context->add_table_part_column(name);
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CCommentItem * oox_comment)
{
if (!oox_comment) return;
@ -537,7 +556,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
int ifx_style = oox_cell->m_oStyle.IsInit() ? oox_cell->m_oStyle->GetValue() : -1;
ods_context->start_cell(ref,ifx_style);
ods_context->start_cell(ref, ifx_style);
int value_type = -1;//not defined
if (oox_cell->m_oType.IsInit())
@ -1617,7 +1636,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
{
if (!color)return;
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
unsigned char ucA = 0, ucR =0, ucG =0, ucB = 0;
bool result = false;
if(color->m_oRgb.IsInit())//easy, faster,realy !!
@ -1629,18 +1648,18 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
result = true;
}
if(color->m_oThemeColor.IsInit())
if(color->m_oThemeColor.IsInit() && xlsx_document->m_pTheme.IsInit())
{
std::wstring sColor = color->m_oThemeColor->ToString();
DWORD argb = 0;
result = OoxConverter::convert(sColor, argb) ;
DWORD argb = xlsx_document->m_pTheme->themeElements.clrScheme.GetARGBFromScheme(color->m_oThemeColor->ToString());
ucR = (argb & 0x0000FF);
ucB = (argb & 0x00FF00) >> 8;
ucG = (argb & 0xFF0000) >> 16;
ucA = argb >> 24;
result = true;
}
if(color->m_oIndexed.IsInit())
{
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->m_pStyles;

View File

@ -48,6 +48,7 @@ namespace OOX
class CWorksheet;
class CTable;
class CTableColumns;
class CCol;
class CRow;
class CCell;
@ -157,6 +158,7 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CWorksheet *oox_sheet);
void convert(OOX::Spreadsheet::CDefinedName *oox_defined);
void convert(OOX::Spreadsheet::CTable *oox_table_part);
void convert(OOX::Spreadsheet::CTableColumns *oox_table_part_columns);
void convert(OOX::Spreadsheet::CPictureWorksheet *oox_background);
void convert(OOX::Spreadsheet::CHeaderFooter *oox_header_footer);

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4996"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -23,8 +23,6 @@ DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED \
USE_LITE_READER \
_USE_XMLLITE_READER_ \
_PRESENTATION_WRITER_ \
_SVG_CONVERT_TO_IMAGE_ \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -187,12 +187,12 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
{
std::wstring strContentTypes = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\
<Default Extension=\"bmp\" ContentType=\"image/bmp\" />\
<Default Extension=\"png\" ContentType=\"image/png\" />\
<Default Extension=\"jpeg\" ContentType=\"image/jpeg\" />\
<Default Extension=\"wmf\" ContentType=\"image/x-wmf\" />\
<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\" />\
<Default Extension=\"xml\" ContentType=\"application/xml\" />\
<Default Extension=\"bmp\" ContentType=\"image/bmp\"/>\
<Default Extension=\"png\" ContentType=\"image/png\"/>\
<Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/>\
<Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/>\
<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>\
<Default Extension=\"xml\" ContentType=\"application/xml\"/>\
<Default Extension=\"gif\" ContentType=\"image/gif\"/>\
<Default Extension=\"emf\" ContentType=\"image/x-emf\"/>\
<Default Extension=\"wav\" ContentType=\"audio/wav\"/>\
@ -207,7 +207,7 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
<Default Extension=\"xls\" ContentType=\"application/vnd.ms-excel\"/>\
<Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\
<Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>";
<Default Extension=\"jpg\" ContentType=\"image/jpeg\"/>";
if (m_pDocument->m_bMacros)
{

View File

@ -959,7 +959,7 @@ public:
case NSOfficeDrawing::adjust10Value:
{
LONG lIndexAdj = pProperty->m_ePID - NSOfficeDrawing::adjustValue;
if (lIndexAdj >= 0 && lIndexAdj < pShape->m_arAdjustments.size())
if (lIndexAdj >= 0 && lIndexAdj < (LONG)pShape->m_arAdjustments.size())
{
pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue);
}
@ -1639,7 +1639,7 @@ public:
}
//------ shape properties ----------------------------------------------------------------------------------------
for (int nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
for (size_t nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
{
CPPTElement oElement;
oElement.SetUpProperties(pElement, pTheme, pSlideWrapper, pSlide, &oArrayOptions[nIndexProp]->m_oProperties);
@ -1756,7 +1756,7 @@ public:
}
else
{//image, audio, video ....
for (int nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
for (size_t nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
{
CPPTElement oElement;
oElement.SetUpProperties(pElement, pTheme, pSlideWrapper, pSlide, &oArrayOptions[nIndexProp]->m_oProperties);

View File

@ -70,7 +70,7 @@ public:
int sz = pStream->tell() - m_lOffsetInStream;
if (sz >= m_oHeader.RecLen)
if (sz >= (int)m_oHeader.RecLen)
break;
}
@ -85,7 +85,7 @@ public:
if (m_arrSIs.size() < 1) return;
int pos_text = 0, pos_si = 0;
int ind = 0;
size_t ind = 0;
for (size_t i = 0; i < pText->m_arParagraphs.size(); i++)
{

View File

@ -65,6 +65,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -937,6 +937,12 @@ void CDrawingConverter::SetEmbedDstPath(const std::wstring& sPath)
NSDirectory::CreateDirectory(sPath);
}
void CDrawingConverter::ClearShapeTypes()
{
m_mapShapeTypes.clear();
}
HRESULT CDrawingConverter::AddShapeType(const std::wstring& bsXml)
{
std::wstring strXml = L"<main ";
@ -974,20 +980,24 @@ HRESULT CDrawingConverter::AddShapeType(const std::wstring& bsXml)
if (oNode.IsValid())
{
CPPTShape* pShape = new CPPTShape();
pShape->m_bIsShapeType = true;
XmlUtils::CXmlNode oNodeST = oNode.ReadNodeNoNS(L"shapetype");
std::wstring strId = oNodeST.GetAttribute(L"id");
pShape->LoadFromXMLShapeType(oNodeST);
CShapePtr pS = CShapePtr(new CShape(NSBaseShape::unknown, 0));
pS->setBaseShape(CBaseShapePtr(pShape));
LoadCoordSize(oNodeST, pS);
//if (m_mapShapeTypes.find(strId) == m_mapShapeTypes.end())//?? с затиранием ???
{
CPPTShape* pShape = new CPPTShape();
pShape->m_bIsShapeType = true;
pShape->LoadFromXMLShapeType(oNodeST);
m_mapShapeTypes.insert(std::pair<std::wstring, CShapePtr>(strId, pS));
CShapePtr pS = CShapePtr(new CShape(NSBaseShape::unknown, 0));
pS->setBaseShape(CBaseShapePtr(pShape));
LoadCoordSize(oNodeST, pS);
m_mapShapeTypes.insert(std::make_pair(strId, pS));
}
}
return S_OK;
@ -1094,6 +1104,12 @@ PPTX::Logic::SpTreeElem CDrawingConverter::ObjectFromXml(const std::wstring& sXm
}
else if (strName == L"pict" || strName == L"object")
{
//сначала shape type
XmlUtils::CXmlNode oNodeST;
if (oParseNode.GetNode(L"v:shapetype", oNodeST))
{
AddShapeType(oNodeST.GetXml());
}
XmlUtils::CXmlNodes oChilds;
if (oParseNode.GetNodes(L"*", oChilds))
{
@ -1148,10 +1164,6 @@ PPTX::Logic::SpTreeElem CDrawingConverter::ObjectFromXml(const std::wstring& sXm
#endif
}
}
else if (L"shapetype" == strNameP)
{
AddShapeType(oNodeP.GetXml());
}
else
{
continue;
@ -1447,6 +1459,13 @@ bool CDrawingConverter::ParceObject(const std::wstring& strXml, std::wstring** p
}
else if (strName == L"pict" || strName == L"object")
{
//сначала shape type
XmlUtils::CXmlNode oNodeST;
if (oParseNode.GetNode(L"v:shapetype", oNodeST))
{
AddShapeType(oNodeST.GetXml());
}
XmlUtils::CXmlNodes oChilds;
if (oParseNode.GetNodes(L"*", oChilds))
{
@ -1487,10 +1506,6 @@ bool CDrawingConverter::ParceObject(const std::wstring& strXml, std::wstring** p
doc_LoadGroup(pElem, oNodeP, pMainProps, true);
}
}
else if (L"shapetype" == strNameP)
{
AddShapeType(oNodeP.GetXml());
}
else
{
continue;
@ -2817,6 +2832,13 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
if (bIsTop) pTree->m_lGroupIndex = 0;
else pTree->m_lGroupIndex = 1;
//сначала shape type
XmlUtils::CXmlNode oNodeST;
if (oNode.GetNode(L"v:shapetype", oNodeST))
{
AddShapeType(oNodeST.GetXml());
}
XmlUtils::CXmlNodes oNodes;
if (oNode.GetNodes(L"*", oNodes))
{
@ -2828,30 +2850,7 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
std::wstring strNameP = XmlUtils::GetNameNoNS(oNodeT.GetName());
if (L"shapetype" == strNameP)
{
//AddShapeType(oNodeT.GetXml());
std::wstring strId = oNodeT.GetAttribute(L"id");
if (strId.length() > 0)
{
if (m_mapShapeTypes.find(strId) == m_mapShapeTypes.end())
{
CPPTShape* pShape = new CPPTShape();
pShape->m_bIsShapeType = true;
pShape->LoadFromXMLShapeType(oNodeT);
CShapePtr pS = CShapePtr(new CShape(NSBaseShape::unknown, 0));
pS->setBaseShape(CBaseShapePtr(pShape));
LoadCoordSize(oNodeT, pS);
m_mapShapeTypes.insert(std::pair<std::wstring, CShapePtr>(strId, pS));
}
}
}
else if (L"shape" == strNameP ||
if (L"shape" == strNameP ||
L"rect" == strNameP ||
L"oval" == strNameP ||
L"line" == strNameP ||
@ -2873,6 +2872,8 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
if (_el.is_init())
pTree->SpTreeElems.push_back(_el);
}
else
continue;
}
}
@ -3985,8 +3986,19 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
nullable_string sRid;
oNodeFill.ReadAttributeBase(L"r:id", sRid);
if (sRid.is_init())
{
PPTX::Logic::BlipFill* pBlipFill = new PPTX::Logic::BlipFill();
{
PPTX::Logic::BlipFill* pBlipFill = NULL;
if (pPicture)
{
pBlipFill = &pPicture->blipFill;
}
else
{
pBlipFill = new PPTX::Logic::BlipFill();
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
pBlipFill->m_namespace = L"a";
pBlipFill->blip = new PPTX::Logic::Blip();
pBlipFill->blip->embed = new OOX::RId(*sRid);
@ -3999,9 +4011,6 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
{
pBlipFill->stretch = new PPTX::Logic::Stretch();
}
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
nullable_string sRotate;
oNodeFill.ReadAttributeBase(L"rotate", sRotate);
@ -4128,7 +4137,19 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
nullable_string sType;
oNodeFillID.ReadAttributeBase(L"type", sType);
PPTX::Logic::BlipFill* pBlipFill = new PPTX::Logic::BlipFill();
PPTX::Logic::BlipFill* pBlipFill = NULL;
if (pPicture)
{
pBlipFill = &pPicture->blipFill;
}
else
{
pBlipFill = new PPTX::Logic::BlipFill();
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
pBlipFill->m_namespace = L"a";
pBlipFill->blip = new PPTX::Logic::Blip();
@ -4180,51 +4201,50 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
else
pBlipFill->srcRect->b = str0;
}
if (pShape)
{
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
if (pPicture)
{
pSpPr->Fill.m_type = PPTX::Logic::UniFill::notInit;
pPicture->blipFill = *pBlipFill;
}
}
}
}
// default params
if (!pSpPr->Fill.Fill.is_init())
if (pPicture)
{
if (pPPTShape->IsWordArt())
{
PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill();
pNoFill->m_namespace = L"a";
pSpPr->Fill.m_type = PPTX::Logic::UniFill::notInit;
pSpPr->Fill.m_type = PPTX::Logic::UniFill::noFill;
pSpPr->Fill.Fill = pNoFill;
if (false == pPicture->blipFill.blip.is_init())
{//MSF_Lec3-4.docx
oElem->InitElem(NULL);
}
else
}
else
{
// default params for fill shape
if (!pSpPr->Fill.Fill.is_init())
{
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(0xFF, 0xFF, 0xFF);
pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pSpPr->Fill.Fill = pSolid;
if (sOpacity.is_init())
if (pPPTShape->IsWordArt())
{
BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
PPTX::Logic::ColorModifier oMod;
oMod.name = L"alpha";
int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod.val = nA;
pSolid->Color.Color->Modifiers.push_back(oMod);
PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill();
pNoFill->m_namespace = L"a";
pSpPr->Fill.m_type = PPTX::Logic::UniFill::noFill;
pSpPr->Fill.Fill = pNoFill;
}
else
{
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(0xFF, 0xFF, 0xFF);
pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pSpPr->Fill.Fill = pSolid;
if (sOpacity.is_init())
{
BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
PPTX::Logic::ColorModifier oMod;
oMod.name = L"alpha";
int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod.val = nA;
pSolid->Color.Color->Modifiers.push_back(oMod);
}
}
}
}

View File

@ -225,7 +225,8 @@ namespace NSBinPptxRW
void SetMediaDstPath (const std::wstring& sMediaPath);
void SetEmbedDstPath (const std::wstring& sEmbedPath);
HRESULT AddShapeType (const std::wstring& sXml);
void ClearShapeTypes ();
HRESULT AddObject (const std::wstring& sXml, std::wstring** pMainProps);
HRESULT SaveObject (long lStart, long lLength, const std::wstring& sMainProps, std::wstring & sXml);
@ -293,6 +294,7 @@ namespace NSBinPptxRW
void Clear();
HRESULT SetCurrentRelsPath();
HRESULT AddShapeType (const std::wstring& sXml);
};
}
#endif //OOX_IFILE_CONTAINER_INCLUDE_H_

View File

@ -537,7 +537,14 @@ namespace NSShapeImageGen
bool bIsRaster = true;
oWriterSVG.IsRaster(&bIsRaster);
if(bIsRaster)
LONG lSvgDataSize = 0;
oWriterSVG.GetSVGDataSize(&lSvgDataSize);
bool bIsBigestSVG = (lSvgDataSize > 5 * 1024 *1024);
if(bIsRaster || bIsBigestSVG)
{
//случай растрового wmf/emf
if (lWidth <= 0 || lHeight <= 0)

View File

@ -40,10 +40,12 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Rels.h"
#include "../../Common/DocxFormat/Source/DocxFormat/ContentTypes.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Media.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FileTypes.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Image.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include <boost/unordered_map.hpp>
namespace PPTX
@ -87,12 +89,71 @@ namespace PPTX
void FileContainer::read(const OOX::CPath& filename)
{
//OOX::IFileContainer::read(filename);
}
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path)
{
}
const bool FileContainer::IsExist(const OOX::FileType& oType) const
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> pFile = m_arContainer[i];
if (oType == pFile->type())
return true;
}
return false;
}
smart_ptr<OOX::File> FileContainer::Get(const OOX::FileType& oType)
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> &pFile = m_arContainer[i];
if (oType == pFile->type())
return pFile;
}
return smart_ptr<OOX::File>(new OOX::UnknowTypeFile( m_oUnknown ));
}
void FileContainer::Get(const OOX::FileType& oType, std::vector<smart_ptr<OOX::File>> & files)
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> &pFile = m_arContainer[i];
if ( oType == pFile->type() )
files.push_back(pFile);
}
}
std::wstring FileContainer::GetImagePathNameFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::Image> p = IFileContainer::Get<OOX::Image>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
std::wstring FileContainer::GetLinkFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::External> pExt = Find(rid).smart_dynamic_cast<OOX::External>();
if (pExt.IsInit())
return pExt->Uri().m_strFilename;
smart_ptr<OOX::Media> pMedia = Find(rid).smart_dynamic_cast<OOX::Media>();
if (pMedia.IsInit())
return pMedia->filename().m_strFilename;
return _T("");
}
std::wstring FileContainer::GetOleFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::OleObject> p = IFileContainer::Get<OOX::OleObject>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path, FileMap& map, IPPTXEvent* Event)
{
bool bIsSlide = false;

View File

@ -55,32 +55,14 @@ namespace PPTX
virtual ~FileContainer()
{
}
virtual std::wstring GetImagePathNameFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::Image> p = Get<OOX::Image>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
virtual std::wstring GetLinkFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::External> pExt = Find(rid).smart_dynamic_cast<OOX::External>();
if (pExt.IsInit())
return pExt->Uri().m_strFilename;
const bool IsExist(const OOX::FileType& oType) const;
smart_ptr<OOX::Media> pMedia = Find(rid).smart_dynamic_cast<OOX::Media>();
if (pMedia.IsInit())
return pMedia->filename().m_strFilename;
return _T("");
}
virtual std::wstring GetOleFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::OleObject> p = Get<OOX::OleObject>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
smart_ptr<OOX::File> Get(const OOX::FileType& oType);
void Get(const OOX::FileType& oType, std::vector<smart_ptr<OOX::File>> & files);
virtual std::wstring GetImagePathNameFromRId(const OOX::RId& rid)const;
virtual std::wstring GetLinkFromRId (const OOX::RId& rid)const;
virtual std::wstring GetOleFromRId (const OOX::RId& rid)const;
protected:
void read(const OOX::CPath& filename);
void read(const OOX::CRels& rels, const OOX::CPath& path);

View File

@ -79,11 +79,11 @@ namespace PPTX
if (_presentation->IsExist(OOX::FileTypes::VbaProject))
{
_presentation->m_bMacroEnabled = true;
_presentation->m_pVbaProject = _presentation->Get(OOX::FileTypes::VbaProject).smart_dynamic_cast<OOX::VbaProject>();
_presentation->m_pVbaProject = _presentation->Get(OOX::FileTypes::VbaProject).smart_dynamic_cast<OOX::VbaProject>();
}
if (_presentation->IsExist(OOX::FileTypes::JsaProject))
{
_presentation->m_pJsaProject = _presentation->Get(OOX::FileTypes::JsaProject).smart_dynamic_cast<OOX::JsaProject>();
_presentation->m_pJsaProject = _presentation->Get(OOX::FileTypes::JsaProject).smart_dynamic_cast<OOX::JsaProject>();
}
_presentation->comments = _presentation->Get(OOX::Presentation::FileTypes::SlideComments).smart_dynamic_cast<PPTX::Comments>();
}
@ -191,17 +191,17 @@ namespace PPTX
return true;//FileContainer::exist(OOX::Presentation::FileTypes::Presentation);
}
void Document::extractPictures(const OOX::CPath& path)
{
OOX::CSystemUtility::CreateDirectories(path);
FileContainer::ExtractPictures(path);
}
//void Document::extractPictures(const OOX::CPath& path)
//{
// OOX::CSystemUtility::CreateDirectories(path);
// FileContainer::ExtractPictures(path);
//}
void Document::extractPictures(const OOX::CPath& source, const OOX::CPath& path)
{
//read(source);
extractPictures(path);
}
//void Document::extractPictures(const OOX::CPath& source, const OOX::CPath& path)
//{
// //read(source);
// extractPictures(path);
//}
long Document::CountFiles(const OOX::CPath& path)
{

View File

@ -50,8 +50,8 @@ namespace PPTX
const bool isValid(const OOX::CPath& path) const;
void extractPictures(const OOX::CPath& path);
void extractPictures(const OOX::CPath& source, const OOX::CPath& path);
//void extractPictures(const OOX::CPath& path);
//void extractPictures(const OOX::CPath& source, const OOX::CPath& path);
private:
long CountFiles(const OOX::CPath& path);
};

View File

@ -486,14 +486,14 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
nullable<PrstTxWarp> prstTxWarp;
TextFit Fit;
nullable<Scene3d> scene3d;
nullable_int flatTx;
nullable<Sp3d> sp3d;
// Attributes
// Attributes
nullable_limit<Limit::TextAnchor> anchor;
nullable_bool anchorCtr;
nullable_int bIns;
@ -513,9 +513,8 @@ namespace PPTX
nullable_limit<Limit::TextVerticalType> vert;
nullable_limit<Limit::VertOverflow> vertOverflow;
nullable_limit<Limit::TextWrap> wrap;
//private:
public:
mutable std::wstring m_namespace;
mutable std::wstring m_namespace;
protected:
virtual void FillParentPointersForChilds()
{

View File

@ -57,7 +57,7 @@ namespace PPTX
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
Color.fromXML(oReader);
}
}
virtual OOX::EElementType getType () const

View File

@ -115,10 +115,14 @@ namespace PPTX
}
else
{
Logic::BuClr* pClr = new Logic::BuClr();
pReader->Skip(5); // len + type(0)
pClr->Color.fromPPTY(pReader);
m_Color.reset(pClr);
LONG len = pReader->GetLong();
if(len > 0)
{
Logic::BuClr* pClr = new Logic::BuClr();
pReader->Skip(1); // type(0)
pClr->Color.fromPPTY(pReader);
m_Color.reset(pClr);
}
}
pReader->Seek(_end_rec);

View File

@ -162,7 +162,17 @@ namespace PPTX
else if(parentFileIs<TableStyles>())
RGB = parentFileAs<TableStyles>().GetARGBFromMap(str);
else if(parentFileIs<Theme>())
RGB = parentFileAs<Theme>().GetARGBFromMap(str);
{
Theme & theme = parentFileAs<Theme>();
if (theme.isMapPresent())
{
RGB = parentFileAs<Theme>().GetARGBFromMap(str);
}
else
{
RGB = parentFileAs<Theme>().GetABGRFromScheme(str);
}
}
else if(parentFileIs<Presentation>())
RGB = parentFileAs<Presentation>().GetARGBFromMap(str);
//{

View File

@ -135,8 +135,14 @@ namespace PPTX
{
smart_ptr<OOX::OleObject> pOleObject;
if (pRels != NULL) pOleObject = pRels->Get<OOX::OleObject>(oRId);
else if(parentFileIs<FileContainer>()) pOleObject = parentFileAs<FileContainer>().Get<OOX::OleObject>(oRId);
if (pRels != NULL)
pOleObject = pRels->Get<OOX::OleObject>(oRId);
else
{
OOX::IFileContainer* pContainer = dynamic_cast<OOX::IFileContainer*>(const_cast<PPTX::WrapperFile*>(parentFile));
if (pContainer)
pOleObject = pContainer->Get<OOX::OleObject>(oRId);
}
if (pOleObject.IsInit())
return pOleObject->filename().m_strFilename;

View File

@ -40,7 +40,6 @@ namespace PPTX
{
namespace Logic
{
class SolidFill : public WrapperWritingElement
{
public:
@ -127,10 +126,8 @@ namespace PPTX
if(Color.is_init())
fill.Color = Color;
}
public:
UniColor Color;
std::wstring m_namespace;
UniColor Color;
std::wstring m_namespace;
protected:
virtual void FillParentPointersForChilds()
{

View File

@ -140,14 +140,11 @@ namespace PPTX
pReader->Seek(_end_rec);
}
UniColor Color;
nullable_limit<Limit::FontStyleIndex> idx;
public:
UniColor Color;
// Attributes
nullable_limit<Limit::FontStyleIndex> idx;
//private:
public:
std::wstring m_name;
std::wstring m_name;
protected:
virtual void FillParentPointersForChilds()
{

File diff suppressed because one or more lines are too long

View File

@ -99,6 +99,9 @@ namespace PPTX
SpTreeElem element;
std::wstring GetVmlXmlBySpid(smart_ptr<OOX::IFileContainer> & rels) const;
void ChartToOlePackageInStorage(OOX::IFileContainer* pRels, const std::wstring &sTempDirectory, int nCurrentGenerateId);
std::wstring ChartToXlsx(OOX::IFileContainer* pRels, const std::wstring &sTempDirectory);
protected:
virtual void FillParentPointersForChilds();
};

View File

@ -288,7 +288,7 @@ namespace PPTX
}
else if (7 == _at)//OleObject Binary FileName (bin, xls, doc, ... other stream file)
{
m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
std::wstring strOlePath = pReader->GetString2();
m_OleObjectFile->set_filename(strOlePath, false); //temp !!! for ImageManager original file name
}
@ -297,8 +297,9 @@ namespace PPTX
}
if (m_sData.IsInit() && m_OleObjectFile.IsInit() == false)
m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
{
m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
}
BYTE embedded_type = 0;
@ -335,6 +336,17 @@ namespace PPTX
std::wstring strOlePath = pReader->GetString(_embed_data_size);
m_OleObjectFile->set_filename(strOlePath, false); //temp !!! for ImageManager original file name
}
else if (embedded_type == 4)
{
pReader->Seek(pReader->GetPos() - 4); //roll back to size record
std::wstring sXmlContent;
pReader->m_pMainDocument->getXmlContentElem(OOX::et_m_oMathPara, *pReader, sXmlContent);
if (!sXmlContent.empty())
{
m_sAlternateContenteXml = sXmlContent;
}
}
else if (embedded_type == 1)
{
m_OleObjectFile = new OOX::OleObject(NULL, true, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
@ -503,12 +515,14 @@ namespace PPTX
smart_ptr<OOX::OleObject> ole_file = m_OleObjectFile;
if (ole_file.IsInit() == false)
{
if (pRels != NULL) ole_file = pRels->Get<OOX::OleObject>(oRId);
else if(parentFileIs<Slide>()) ole_file = parentFileAs<Slide>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<SlideLayout>()) ole_file = parentFileAs<SlideLayout>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<SlideMaster>()) ole_file = parentFileAs<SlideMaster>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<Theme>()) ole_file = parentFileAs<Theme>().Get<OOX::OleObject>(oRId);
if (pRels != NULL)
ole_file = pRels->Get<OOX::OleObject>(oRId);
else
{
OOX::IFileContainer* pContainer = dynamic_cast<OOX::IFileContainer*>(const_cast<PPTX::WrapperFile*>(parentFile));
if (pContainer)
ole_file = pContainer->Get<OOX::OleObject>(oRId);
}
}
return ole_file;
}
@ -861,7 +875,7 @@ namespace PPTX
if(oleObject.IsInit() && blipFill.blip.IsInit())
{
if (oleObject->m_OleObjectFile.IsInit() == false)
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);
@ -945,7 +959,7 @@ namespace PPTX
if (oleObject->m_OleObjectFile.IsInit() == false)
{
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin, false);
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);

View File

@ -221,6 +221,8 @@ namespace PPTX
nullable_int m_oDxaOrig;
nullable_int m_oDyaOrig;
nullable_string m_sAlternateContenteXml;
};
class Pic : public WrapperWritingElement

View File

@ -151,6 +151,11 @@ namespace PPTX
m_bData = false;
ReadAttributes( oReader );
FillParentPointersForChilds();
if (id_data.IsInit())
{
m_bData = true;
}
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
@ -158,6 +163,11 @@ namespace PPTX
node.ReadAttributeBase(L"r:id", id_data);
FillParentPointersForChilds();
if (id_data.IsInit())
{
m_bData = true;
}
}
virtual std::wstring toXML() const;
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;

View File

@ -73,8 +73,6 @@ namespace PPTX
}
virtual void read(const OOX::CPath& filename, FileMap& map)
{
//FileContainer::read(filename, map);
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile(filename.m_strFilename);

View File

@ -324,15 +324,18 @@ namespace PPTX
}
DWORD GetARGBFromMap(const std::wstring& str)const
{
return GetARGBFromScheme(m_map->GetColorSchemeIndex(str));
if (m_map) return GetARGBFromScheme(m_map->GetColorSchemeIndex(str));
else return 0;
}
DWORD GetBGRAFromMap(const std::wstring& str)const
{
return GetBGRAFromScheme(m_map->GetColorSchemeIndex(str));
if (m_map) return GetBGRAFromScheme(m_map->GetColorSchemeIndex(str));
else return 0;
}
DWORD GetABGRFromMap(const std::wstring& str)const
{
return GetABGRFromScheme(m_map->GetColorSchemeIndex(str));
if (m_map) return GetABGRFromScheme(m_map->GetColorSchemeIndex(str));
else return 0;
}
void GetLineStyle(int number, Logic::Ln& lnStyle)const
{
@ -357,6 +360,7 @@ namespace PPTX
void SetColorMap(const Logic::ClrMap& map){m_map = &map;};
bool isMapPresent() {return (m_map != NULL);}
private:
Logic::ClrMap const* m_map;
};

View File

@ -47,7 +47,6 @@ namespace PPTX
public:
PPTX_LOGIC_BASE(ThemeElements)
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
clrScheme = node.ReadNode(_T("a:clrScheme"));
@ -117,7 +116,6 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
ClrScheme clrScheme;
FontScheme fontScheme;
FmtScheme fmtScheme;

View File

@ -26,8 +26,6 @@ include($$PWD/../../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML \
#DISABLE_FILE_DOWNLOADER \
CXIMAGE_DONT_DECLARE_TCHAR \

View File

@ -54,6 +54,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -21,8 +21,6 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE _UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS \
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML

View File

@ -51,6 +51,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -38,77 +38,105 @@
#include <boost/algorithm/string.hpp>
HRESULT ConvertOle1ToOle2(BYTE *pData, int nSize, std::wstring sOle2Name)
void ConvertOle1ToOle2(BYTE *pData, int nSize, std::wstring sOle2Name)
{
HRESULT hr = S_FALSE;
Ole1FormatReader ole1Reader(pData, nSize);
Ole1FormatReaderWriter ole1Reader(pData, nSize);
bool bResult = false;
if (ole1Reader.NativeDataSize > 0)
{
POLE::Storage * storageOut = new POLE::Storage(sOle2Name.c_str());
if ( (storageOut) && (storageOut->open(true, true)))
NSFile::CFileBinary file;
file.CreateFileW(sOle2Name);
file.WriteFile(ole1Reader.NativeData, ole1Reader.NativeDataSize);
file.CloseFile();
POLE::Storage * storageIn = new POLE::Storage(sOle2Name.c_str());
if ( (storageIn) && (storageIn->open(false, false))) //storage in storage
{
_UINT32 tmp = 0;
std::string name = ole1Reader.Header.ClassName.val;
_UINT32 name_size = name.length() + 1;
//Ole
BYTE dataOleInfo[] = {0x01,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
POLE::Stream oStream3(storageOut, L"\001Ole", true, 20);
oStream3.write(dataOleInfo, 20);
oStream3.flush();
//CompObj
BYTE dataCompObjHeader[28] = {0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x0a,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
POLE::Stream oStream1(storageOut, L"\001CompObj", true, 28 + (name_size + 5) + 2 * (ole1Reader.Header.ClassName.size + 4) + 4 * 4);
oStream1.write(dataCompObjHeader, 28);
//test package stream??? xls ole -> xlsx ole
bResult = true;
storageIn->close();
}
delete storageIn;
if (!bResult)
{
POLE::Storage * storageOut = new POLE::Storage(sOle2Name.c_str());
if ( (storageOut) && (storageOut->open(true, true)))
{
_UINT32 tmp = 0;
std::string name = ole1Reader.Header.ClassName.val;
_UINT32 name_size = name.length() + 1;
//Ole
BYTE dataOleInfo[] = {0x01,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
POLE::Stream oStream3(storageOut, L"\001Ole", true, 20);
oStream3.write(dataOleInfo, 20);
oStream3.flush();
//CompObj
BYTE dataCompObjHeader[28] = {0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x0a,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
POLE::Stream oStream1(storageOut, L"\001CompObj", true, 28 + (name_size + 5) + 2 * (ole1Reader.Header.ClassName.size + 4) + 4 * 4);
oStream1.write(dataCompObjHeader, 28);
oStream1.write((BYTE*)&name_size, 4);
oStream1.write((BYTE*)name.c_str(), name_size);
oStream1.write((BYTE*)&name_size, 4);
oStream1.write((BYTE*)name.c_str(), name_size);
//oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
//oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
//oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
//oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
tmp = 0x71B239F4;
oStream1.write((BYTE*)&tmp, 4); // UnicodeMarker
tmp = 0x71B239F4;
oStream1.write((BYTE*)&tmp, 4); // UnicodeMarker
tmp = 0;
oStream1.write((BYTE*)&tmp, 4); // UnicodeUserType
oStream1.write((BYTE*)&tmp, 4); // UnicodeClipboardFormat
oStream1.write((BYTE*)&tmp, 4); //
oStream1.flush();
tmp = 0;
oStream1.write((BYTE*)&tmp, 4); // UnicodeUserType
oStream1.write((BYTE*)&tmp, 4); // UnicodeClipboardFormat
oStream1.write((BYTE*)&tmp, 4); //
oStream1.flush();
//ObjInfo
BYTE dataObjInfo[] = {0x00,0x00,0x03,0x00,0x04,0x00};
POLE::Stream oStream2(storageOut, L"\003ObjInfo", true, 6);
oStream2.write(dataObjInfo, 6);
oStream2.flush();
//Ole10Native
POLE::Stream streamData(storageOut, L"\001Ole10Native", true, ole1Reader.NativeDataSize + 4);
streamData.write((BYTE*)&ole1Reader.NativeDataSize, 4);
streamData.write(ole1Reader.NativeData, ole1Reader.NativeDataSize);
streamData.flush();
//ObjInfo
BYTE dataObjInfo[] = {0x00,0x00,0x03,0x00,0x04,0x00};
POLE::Stream oStream2(storageOut, L"\003ObjInfo", true, 6);
oStream2.write(dataObjInfo, 6);
oStream2.flush();
//Ole10Native
POLE::Stream streamData(storageOut, L"\001Ole10Native", true, ole1Reader.NativeDataSize + 4);
streamData.write((BYTE*)&ole1Reader.NativeDataSize, 4);
storageOut->close();
delete storageOut;
_UINT32 sz_write = 0;
_UINT32 sz = 4096;
while (sz_write < ole1Reader.NativeDataSize)
{
if (sz_write + sz > ole1Reader.NativeDataSize)
sz = ole1Reader.NativeDataSize - sz_write;
streamData.write(ole1Reader.NativeData + sz_write, sz);
sz_write += sz;
}
streamData.flush();
storageOut->close();
delete storageOut;
bResult = true;
}
}
}
else //conv_NI38P7GBIpw1aD84H3k.rtf
if (!bResult) //conv_NI38P7GBIpw1aD84H3k.rtf
{
NSFile::CFileBinary file;
file.CreateFileW(sOle2Name);
file.WriteFile(pData, nSize);
file.CloseFile();
bResult = true;
}
return S_FALSE;
}
//-----------------------------------------------------------------------------------------
bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
{
if ( "ansi" == sCommand ) oDocument.m_oProperty.m_eCodePage = RtfDocumentProperty::cp_ansi;
@ -1168,26 +1196,28 @@ bool RtfTableCellPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
COMMAND_RTF_BOOL( "clmgf", cellProps->m_bMergeFirst, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clmrg", cellProps->m_bMerge, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clvmgf", cellProps->m_bMergeFirstVertical, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clvmrg", cellProps->m_bMergeVertical, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clFitText", cellProps->m_bFitText, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clvmgf", cellProps->m_bMergeFirstVertical, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clvmrg", cellProps->m_bMergeVertical, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clFitText", cellProps->m_bFitText, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "clNoWrap", cellProps->m_bNoWrap, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadfl", cellProps->m_nIsPaddingLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadl", cellProps->m_nPaddingLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadft", cellProps->m_nIsPaddingTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadt", cellProps->m_nPaddingTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadfr", cellProps->m_nIsPaddingRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadr", cellProps->m_nPaddingRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadfb", cellProps->m_nIsPaddingBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadb", cellProps->m_nPaddingBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspfl", cellProps->m_nIsSpacingLeft, sCommand, hasParameter, parameter )
//https://www.office-forums.com/threads/rtf-file-weirdness-clpadt-vs-clpadl.2163500/
COMMAND_RTF_INT ( "clpadft", cellProps->m_ePaddingLeftUnit, sCommand, hasParameter, parameter ) //перепутаны top & left
COMMAND_RTF_INT ( "clpadt", cellProps->m_nPaddingLeft, sCommand, hasParameter, parameter ) //перепутаны top & left
COMMAND_RTF_INT ( "clpadfl", cellProps->m_ePaddingTopUnit, sCommand, hasParameter, parameter ) //перепутаны top & left
COMMAND_RTF_INT ( "clpadl", cellProps->m_nPaddingTop, sCommand, hasParameter, parameter ) //перепутаны top & left
COMMAND_RTF_INT ( "clpadfr", cellProps->m_ePaddingRightUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadr", cellProps->m_nPaddingRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadfb", cellProps->m_ePaddingBottomUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clpadb", cellProps->m_nPaddingBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspfl", cellProps->m_eSpacingLeftUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspl", cellProps->m_nSpacingLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspft", cellProps->m_nIsSpacingTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspft", cellProps->m_eSpacingTopUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspt", cellProps->m_nSpacingTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspfr", cellProps->m_nIsSpacingRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspfr", cellProps->m_eSpacingRightUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspr", cellProps->m_nSpacingRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspfb", cellProps->m_nIsSpacingBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspfb", cellProps->m_eSpacingBottomUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "clspb", cellProps->m_nSpacingBottom, sCommand, hasParameter, parameter )
else if ( "clftsWidth" == sCommand )
@ -1196,10 +1226,12 @@ bool RtfTableCellPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
{
switch( parameter )
{
case 0:cellProps->m_eWidthUnits = mu_none;break;
case 1:cellProps->m_eWidthUnits = mu_Auto;break;
case 2:cellProps->m_eWidthUnits = mu_Percent;break;
case 3:cellProps->m_eWidthUnits = mu_Twips;break;
case 0: cellProps->m_eWidthUnit = mu_none; break;
case 1: cellProps->m_eWidthUnit = mu_Auto; break;
case 2: cellProps->m_eWidthUnit = mu_Percent; break;
case 3: cellProps->m_eWidthUnit = mu_Twips; break;
default:
break;
}
}
}
@ -1215,13 +1247,13 @@ bool RtfTableCellPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
COMMAND_RTF_INT ( "cltxtbrlv", cellProps->m_oCellFlow, sCommand, true, RtfCellProperty::cf_tbrlv )
//table style
COMMAND_RTF_INT ( "tscellpaddfl", cellProps->m_nIsPaddingLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddfl", cellProps->m_ePaddingLeftUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddl", cellProps->m_nPaddingLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddft", cellProps->m_nIsPaddingTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddft", cellProps->m_ePaddingTopUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddt", cellProps->m_nPaddingTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddfr", cellProps->m_nIsPaddingRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddfr", cellProps->m_ePaddingRightUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddr", cellProps->m_nPaddingRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddfb", cellProps->m_nIsPaddingBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddfb", cellProps->m_ePaddingBottomUnit,sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tscellpaddb", cellProps->m_nPaddingBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "tsnowrap", cellProps->m_bNoWrap, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tsvertalt", cellProps->m_eAlign, sCommand, true, RtfCellProperty::ca_Top )
@ -1255,55 +1287,22 @@ bool RtfTableRowPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
COMMAND_RTF_INT ( "trqr", rowProps->m_eJust, sCommand, true, RtfRowProperty::rj_trqr )
COMMAND_RTF_INT ( "trqc", rowProps->m_eJust, sCommand, true, RtfRowProperty::rj_trqc )
COMMAND_RTF_INT ( "trrh", rowProps->m_nHeight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trrh", rowProps->m_nHeight, sCommand, hasParameter, parameter )
else if ( "trftsWidth" == sCommand )
{
if ( hasParameter )
{
switch( parameter )
{
case 0: rowProps->m_eMUWidth = mu_none; break;
case 1: rowProps->m_eMUWidth = mu_Auto; break;
case 2: rowProps->m_eMUWidth = mu_Percent; break;
case 3: rowProps->m_eMUWidth = mu_Twips; break;
}
}
}
COMMAND_RTF_INT ( "trwWidth", rowProps->m_nWidth, sCommand, hasParameter, parameter )
else if ( "trftsWidthB" == sCommand )
{
if ( hasParameter )
{
switch( parameter )
{
case 0: rowProps->m_eMUStartInvCell = mu_none; break;
case 1: rowProps->m_eMUStartInvCell = mu_Auto; break;
case 2: rowProps->m_eMUStartInvCell = mu_Percent; break;
case 3: rowProps->m_eMUStartInvCell = mu_Twips; break;
}
}
}
COMMAND_RTF_INT ( "trwWidthB", rowProps->m_nWidthStartInvCell, sCommand, hasParameter, parameter )
else if ( "trftsWidthA" == sCommand )
{
if ( hasParameter )
{
switch( parameter )
{
case 0: rowProps->m_eMUEndInvCell = mu_none; break;
case 1: rowProps->m_eMUEndInvCell = mu_Auto; break;
case 2: rowProps->m_eMUEndInvCell = mu_Percent; break;
case 3: rowProps->m_eMUEndInvCell = mu_Twips; break;
}
}
}
COMMAND_RTF_INT ( "trwWidthA", rowProps->m_nWidthEndInvCell, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "taprtl", rowProps->m_bBidi, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trftsWidth", rowProps->m_eWidthUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trwWidth", rowProps->m_nWidth, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trftsWidthB", rowProps->m_eWidthStartInvCellUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trwWidthB", rowProps->m_nWidthStartInvCell, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trftsWidthA", rowProps->m_eWidthEndInvCellUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trwWidthA", rowProps->m_nWidthEndInvCell, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "taprtl", rowProps->m_bBidi, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trautofit", rowProps->m_nAutoFit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trgaph", rowProps->m_nGraph, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tblind", rowProps->nTableIndent, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tblindtype", rowProps->nTableIndentUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trgaph", rowProps->m_nGraph, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tblind", rowProps->nTableIndent, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tblindtype", rowProps->eTableIndentUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tdfrmtxtLeft", rowProps->m_nWrapLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tdfrmtxtRight", rowProps->m_nWrapRight, sCommand, hasParameter, parameter )
@ -1311,26 +1310,26 @@ bool RtfTableRowPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
COMMAND_RTF_INT ( "tdfrmtxtBottom", rowProps->m_nWrapBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "tabsnoovrlp", rowProps->m_bOverlap, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tphmrg", rowProps->m_eHRef, sCommand, true, RtfTableProperty::hr_phmrg )
COMMAND_RTF_INT ( "tphmrg", rowProps->m_eHRef, sCommand, true, RtfTableProperty::hr_phmrg )
COMMAND_RTF_INT ( "tphpg", rowProps->m_eHRef, sCommand, true, RtfTableProperty::hr_phpg )
COMMAND_RTF_INT ( "tphcol", rowProps->m_eHRef, sCommand, true, RtfTableProperty::hr_phcol )
COMMAND_RTF_INT ( "tphcol", rowProps->m_eHRef, sCommand, true, RtfTableProperty::hr_phcol )
COMMAND_RTF_INT ( "tposx", rowProps->m_nHPos, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tposnegx", rowProps->m_nHPos, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tposxc", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxc )
COMMAND_RTF_INT ( "tposxi", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxi )
COMMAND_RTF_INT ( "tposxo", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxo )
COMMAND_RTF_INT ( "tposxl", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxl )
COMMAND_RTF_INT ( "tposxr", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxr )
COMMAND_RTF_INT ( "tposxc", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxc )
COMMAND_RTF_INT ( "tposxi", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxi )
COMMAND_RTF_INT ( "tposxo", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxo )
COMMAND_RTF_INT ( "tposxl", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxl )
COMMAND_RTF_INT ( "tposxr", rowProps->m_eHPos, sCommand, true, RtfTableProperty::hp_posxr )
COMMAND_RTF_INT ( "tpvmrg", rowProps->m_eVRef, sCommand, true, RtfTableProperty::vr_pvmrg )
COMMAND_RTF_INT ( "tpvmrg", rowProps->m_eVRef, sCommand, true, RtfTableProperty::vr_pvmrg )
COMMAND_RTF_INT ( "tpvpg", rowProps->m_eVRef, sCommand, true, RtfTableProperty::vr_pvpg )
COMMAND_RTF_INT ( "tpvpara", rowProps->m_eVRef, sCommand, true, RtfTableProperty::vr_pvpara )
COMMAND_RTF_INT ( "tposy", rowProps->m_nVPos, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tposnegy", rowProps->m_nVPos, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tposyt", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyt )
COMMAND_RTF_INT ( "tposyt", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyt )
COMMAND_RTF_INT ( "tposyil", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyil )
COMMAND_RTF_INT ( "tposyb", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyb )
COMMAND_RTF_INT ( "tposyc", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyc )
COMMAND_RTF_INT ( "tposyb", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyb )
COMMAND_RTF_INT ( "tposyc", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyc )
COMMAND_RTF_INT ( "tposyin", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyin )
COMMAND_RTF_INT ( "tposyout", rowProps->m_eVPos, sCommand, true, RtfTableProperty::vp_posyout )
@ -1342,21 +1341,25 @@ bool RtfTableRowPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
if ( PROP_DEF == rowProps->nTableIndent )
{
rowProps->nTableIndent = parameter;
rowProps->nTableIndentUnits = 3;
if ( PROP_DEF == rowProps->eTableIndentUnit )
rowProps->eTableIndentUnit = 3;
}
}
}
COMMAND_RTF_INT ( "trwWidth", rowProps->m_nWidth, sCommand, hasParameter, parameter )
else if ( "trleft" == sCommand )
else if ( "trftsWidth" == sCommand )
{
if ( hasParameter )
{
switch( parameter )
{
case 0: rowProps->m_eMUWidth = mu_none; break;
case 1: rowProps->m_eMUWidth = mu_Auto; break;
case 2: rowProps->m_eMUWidth = mu_Percent; break;
case 3: rowProps->m_eMUWidth = mu_Twips; break;
case 0: rowProps->m_eWidthUnit = mu_none; break;
case 1: rowProps->m_eWidthUnit = mu_Auto; break;
case 2: rowProps->m_eWidthUnit = mu_Percent; break;
case 3: rowProps->m_eWidthUnit = mu_Twips; break;
default:
break;
}
}
}
@ -1364,20 +1367,21 @@ bool RtfTableRowPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
COMMAND_RTF_INT ( "trpaddl", rowProps->m_nDefCellMarLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddr", rowProps->m_nDefCellMarRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddt", rowProps->m_nDefCellMarTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddfb", rowProps->m_nDefCellMarBottomUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddfl", rowProps->m_nDefCellMarLeftUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddfr", rowProps->m_nDefCellMarRightUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddft", rowProps->m_nDefCellMarTopUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddfb", rowProps->m_eDefCellMarBottomUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddfl", rowProps->m_eDefCellMarLeftUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddfr", rowProps->m_eDefCellMarRightUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trpaddft", rowProps->m_eDefCellMarTopUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdb", rowProps->m_nDefCellSpBottom, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdl", rowProps->m_nDefCellSpLeft, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdr", rowProps->m_nDefCellSpRight, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdt", rowProps->m_nDefCellSpTop, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdfb", rowProps->m_nDefCellSpBottomUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdfl", rowProps->m_nDefCellSpLeftUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdfr", rowProps->m_nDefCellSpRightUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdft", rowProps->m_nDefCellSpTopUnits, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdfb", rowProps->m_eDefCellSpBottomUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdfl", rowProps->m_eDefCellSpLeftUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdfr", rowProps->m_eDefCellSpRightUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "trspdft", rowProps->m_eDefCellSpTopUnit, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "ts", rowProps->m_nStyle, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "ts", rowProps->m_nStyle, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tbllkhdrrows", rowProps->m_bAutoFirstRow, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "tbllklastrow", rowProps->m_bAutoLastRow, sCommand, hasParameter, parameter )
@ -1795,48 +1799,15 @@ bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, st
if ( 0 != nSize && pData)
{
HRESULT hRes = S_FALSE;
boost::shared_array<BYTE> buffer(pData);
m_oOle.m_oOle1Data = std::make_pair(buffer, nSize);
//конвертация Ole1 в Ole2
#if 0//defined(_WIN32) || defined(_WIN64)
RtfOle1ToOle2Stream oStream;
oStream.lpstbl = new OLESTREAMVTBL();
oStream.lpstbl->Get = &OleGet1;
oStream.lpstbl->Put = &OlePut1;
oStream.pBuffer = pData;
oStream.nBufferSize = nSize;
oStream.nCurPos = 0;
std::wstring sOleStorageName = Utils::CreateTempFile( oReader.m_sTempFolder );
IStorage* piMSStorage = NULL;
if ( SUCCEEDED( StgCreateDocfile( sOleStorageName.c_str(), STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED/* | STGM_DELETEONRELEASE*/, NULL, &piMSStorage) ) )
{
hRes = OleConvertOLESTREAMToIStorage( &oStream, piMSStorage, NULL );
piMSStorage->Commit( STGC_DEFAULT );
RELEASEINTERFACE( piMSStorage );
}
delete oStream.lpstbl;
#else
std::wstring sOleStorageName = NSDirectory::CreateTempFileWithUniqueName(oReader.m_sTempFolder, L"img");
hRes = ConvertOle1ToOle2(pData, nSize, sOleStorageName);
#endif
delete[] pData;
POLE::Storage * piRootStorage = new POLE::Storage(sOleStorageName.c_str());
if ( piRootStorage)
{
m_oOle.SetFilename( sOleStorageName.c_str() );
m_oOle.SetOle( piRootStorage );
hRes = S_OK;
}
if ( hRes != S_OK )
Utils::RemoveDirOrFile( sOleStorageName.c_str() );
//конвертация Ole1 в Ole2
ConvertOle1ToOle2(pData, nSize, sOleStorageName);
m_oOle.SetFilename( sOleStorageName.c_str() );
}
}
else if ( "result" == sCommand )
@ -1846,7 +1817,7 @@ bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, st
RtfAllPictReader oAllPictReader( *oNewShape );
StartSubReader( oAllPictReader, oDocument, oReader );
m_oOle.m_oResultPic = oNewShape;
m_oOle.m_oResultShape = oNewShape;
}
else
return false;
@ -1926,6 +1897,9 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt
else if ( L"posrelv" == m_sPropName ) m_oShape.m_nPositionVRelative = nValue;
else if ( L"fLayoutInCell" == m_sPropName ) m_oShape.m_bLayoutInCell = nValue;
else if ( L"fAllowOverlap" == m_sPropName ) m_oShape.m_bAllowOverlap = nValue;
else if ( L"fLockPosition" == m_sPropName ) m_oShape.m_nLockPosition = nValue;
else if ( L"fLockRotation" == m_sPropName ) m_oShape.m_nLockRotation = nValue;
//Position relative
else if ( L"pctHorizPos" == m_sPropName ) m_oShape.m_nPositionHPct = nValue;
else if ( L"pctVertPos" == m_sPropName ) m_oShape.m_nPositionVPct = nValue;
@ -2032,6 +2006,13 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt
else if ( L"dxTextRight" == m_sPropName ) m_oShape.m_nTexpRight = nValue;
else if ( L"dyTextBottom" == m_sPropName ) m_oShape.m_nTexpBottom = nValue;
else if ( L"anchorText" == m_sPropName ) m_oShape.m_nAnchorText = nValue;
else if ( L"WrapText" == m_sPropName ) m_oShape.m_nWrapText = nValue;
else if ( L"txflTextFlow" == m_sPropName ) m_oShape.m_nTxflTextFlow = nValue;
else if ( L"ccol" == m_sPropName ) m_oShape.m_nCcol = nValue;
else if ( L"txdir" == m_sPropName ) m_oShape.m_nTxdir = nValue;
else if ( L"fFitShapeToText"== m_sPropName ) m_oShape.m_bFitShapeToText = nValue;
else if ( L"fFitTextToShape"== m_sPropName ) m_oShape.m_bFitTextToShape = nValue;
else if ( L"fRotateText" == m_sPropName ) m_oShape.m_fRotateText = nValue;
//Geometry
else if ( L"adjustValue" == m_sPropName ) m_oShape.m_nAdjustValue[0] = nValue;
@ -2152,8 +2133,8 @@ bool RtfTrackerChangesReader::ExecuteCommand(RtfDocument& oDocument, RtfReader&
else if ( "clbrdrr" == sCommand ) m_eInternalState = is_borderCellRight;
else if ( "clbrdrb" == sCommand ) m_eInternalState = is_borderCellBottom;
else if ( "tsbrdrdgl" == sCommand ) m_eInternalState = is_borderCellLR;
else if ( "tsbrdrdgr" == sCommand ) m_eInternalState = is_borderCellRL;
else if ( "tsbrdrdgl" == sCommand ) m_eInternalState = is_borderCellLR;
else if ( "tsbrdrdgr" == sCommand ) m_eInternalState = is_borderCellRL;
else if ( "trbrdrl" == sCommand ) m_eInternalState = is_borderRowLeft;
else if ( "trbrdrr" == sCommand ) m_eInternalState = is_borderRowRight;
@ -2161,7 +2142,8 @@ bool RtfTrackerChangesReader::ExecuteCommand(RtfDocument& oDocument, RtfReader&
else if ( "trbrdrb" == sCommand ) m_eInternalState = is_borderRowBottom;
else if ( "trbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
else if ( "trbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
else if ( "tsbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
else if ( "tsbrdrl" == sCommand ) m_eInternalState = is_borderRowLeft;
else if ( "tsbrdrt" == sCommand ) m_eInternalState = is_borderRowTop;
@ -2197,6 +2179,8 @@ bool RtfTrackerChangesReader::ExecuteCommand(RtfDocument& oDocument, RtfReader&
case is_borderTop:
bResult = RtfBorderCommand::ExecuteCommand( oDocument, oReader, sCommand, hasParameter, parameter, m_pParagraphProps->m_oBorderTop );
break;
default:
break;
}
if (bResult) return true;
@ -2229,6 +2213,8 @@ bool RtfTrackerChangesReader::ExecuteCommand(RtfDocument& oDocument, RtfReader&
case is_borderRowVer :
bResult = RtfBorderCommand::ExecuteCommand( oDocument, oReader,sCommand, hasParameter, parameter, m_pTableRowProps->m_oBorderVert );
break;
default:
break;
}
if ( bResult ) return true;
@ -2932,9 +2918,9 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
else if ( "brdrb" == sCommand ) m_eInternalState = is_borderBottom;
else if ( "brdrl" == sCommand ) m_eInternalState = is_borderLeft;
else if ( "brdrr" == sCommand ) m_eInternalState = is_borderRight;
//else if ( "brdrbtw" == sCommand ) m_eInternalState = is_borderRight;
//else if ( "brdrbtw" == sCommand ) m_eInternalState = is_borderRight;
else if ( "brdrbar" == sCommand ) m_eInternalState = is_borderBar;
else if ( "box" == sCommand ) m_eInternalState = is_borderBox;
else if ( "box" == sCommand ) m_eInternalState = is_borderBox;
else if ( "cldglu" == sCommand ) m_eInternalState = is_borderCellLR;
else if ( "cldgll" == sCommand ) m_eInternalState = is_borderCellRL;
@ -2952,7 +2938,8 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
else if ( "trbrdrb" == sCommand ) m_eInternalState = is_borderRowBottom;
else if ( "trbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
else if ( "trbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
else if ( "tsbrdrh" == sCommand ) m_eInternalState = is_borderRowHor;
else if ( "tsbrdrv" == sCommand ) m_eInternalState = is_borderRowVer;
else if ( "tsbrdrl" == sCommand ) m_eInternalState = is_borderRowLeft;
else if ( "tsbrdrt" == sCommand ) m_eInternalState = is_borderRowTop;
@ -3020,6 +3007,8 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
case is_borderRowVer :
bResult = RtfBorderCommand::ExecuteCommand( oDocument, oReader,sCommand, hasParameter, parameter, oReader.m_oState->m_oRowProperty.m_oBorderVert );
break;
default:
break;
}
if ( bResult ) return true;

View File

@ -1148,12 +1148,16 @@ public:
RtfShapeReader oShapeReader(m_oShape);
StartSubReader( oShapeReader, oDocument, oReader );
}
if( "shppict" == sCommand )
else if( "shppict" == sCommand )
{
RtfShppictReader oShppictReader(m_oShape);
StartSubReader( oShppictReader, oDocument, oReader );
}
else if( "pict" == sCommand )
else if( "nonshppict" == sCommand )
{
Skip( oDocument, oReader );
}
else if( "pict" == sCommand )
{
m_oShape.m_eAnchorTypeShape = RtfShape::st_inline;
m_oShape.m_nShapeType = NSOfficeDrawing::sptPictureFrame;

View File

@ -58,7 +58,7 @@ public:
return pCur;
}
unsigned char ReadUChar()
unsigned char ReadUChar()
{
if (pCur + 1 >= pEnd)
return 0;
@ -67,6 +67,14 @@ public:
pCur++;
return unResult;
};
void WriteUChar(unsigned char val)
{
if (pCur + 1 >= pEnd)
return;
pCur[0] = val;
pCur++;
};
unsigned short ReadUShort()
{
if (pCur + 2 >= pEnd)
@ -76,15 +84,31 @@ public:
pCur += 2;
return ushResult;
};
unsigned int ReadULong()
void WriteUShort(unsigned short val)
{
if (pCur + 2 >= pEnd)
return;
((unsigned short*) pCur)[0] = val;
pCur += 2;
};
_UINT32 ReadULong()
{
if (pCur + 4 >= pEnd)
return 0;
unsigned int unResult = (unsigned int)((pCur[0] << 0) | ((pCur[1]) << 8) | ((pCur[2]) << 16) | ((pCur[3]) << 24));
_UINT32 unResult = (_UINT32)((pCur[0] << 0) | ((pCur[1]) << 8) | ((pCur[2]) << 16) | ((pCur[3]) << 24));
pCur += 4;
return unResult;
};
void WriteULong(_UINT32 val)
{
if (pCur + 4 >= pEnd)
return;
((_UINT32*)pCur)[0] = val;
pCur += 4;
};
double ReadDouble()
{
if (pCur + 4 >= pEnd)
@ -110,13 +134,25 @@ public:
{
return (char)ReadUChar();
};
short ReadShort()
void WriteChar(char val)
{
WriteUChar((unsigned char)val);
};
short ReadShort()
{
return (short)ReadUShort();
};
int ReadLong()
void WriteShort(short val)
{
return (int)ReadULong();
WriteUShort((unsigned short) val);
};
_INT32 ReadLong()
{
return (_INT32)ReadULong();
};
void WriteLong(_INT32 val)
{
WriteULong((_UINT32)val);
};
void ReadBytes(char* pBuffer, unsigned int ulSize)
{
@ -128,6 +164,16 @@ public:
pBuffer[ulIndex] = ReadChar();
}
};
void WriteBytes(char* pBuffer, unsigned int ulSize)
{
size_t ulRemainSize = (pEnd - pCur);
size_t ulFinalSize = (ulRemainSize > ulSize ? ulSize : ulRemainSize);
for (size_t ulIndex = 0; ulIndex < ulFinalSize; ulIndex++)
{
WriteChar(pBuffer[ulIndex]);
}
};
void ReadBytes(unsigned char* pBuffer, unsigned int ulSize)
{
size_t ulRemainSize = (pEnd - pCur);
@ -135,7 +181,17 @@ public:
for (size_t ulIndex = 0; ulIndex < ulFinalSize; ulIndex++)
{
pBuffer[ulIndex] = ReadChar();
pBuffer[ulIndex] = ReadUChar();
}
};
void WriteBytes(unsigned char* pBuffer, unsigned int ulSize)
{
size_t ulRemainSize = (pEnd - pCur);
size_t ulFinalSize = (ulRemainSize > ulSize ? ulSize : ulRemainSize);
for (size_t ulIndex = 0; ulIndex < ulFinalSize; ulIndex++)
{
WriteUChar(pBuffer[ulIndex]);
}
};
void ReadBytes(unsigned short* pBuffer, unsigned int ulSize)
@ -158,7 +214,7 @@ public:
pBuffer[ulIndex] = ReadShort();
}
}
void ReadBytes(unsigned int* pBuffer, unsigned int ulSize)
void ReadBytes(_UINT32* pBuffer, unsigned int ulSize)
{
size_t ulRemainSize = (pEnd - pCur) / 4;
size_t ulFinalSize = (ulRemainSize > ulSize ? ulSize : ulRemainSize);
@ -173,22 +229,32 @@ public:
nValue = ReadUChar();
return *this;
}
CDataStream& operator<<(unsigned char nValue)
{
WriteUChar(nValue);
return *this;
}
CDataStream& operator>>(unsigned short& nValue)
{
nValue = ReadUShort();
return *this;
}
CDataStream& operator>>(unsigned int& nValue)
CDataStream& operator<<(unsigned short nValue)
{
WriteUShort(nValue);
return *this;
}
CDataStream& operator>>(_UINT32& nValue)
{
nValue = ReadULong();
return *this;
}
CDataStream& operator>>(unsigned long& nValue)
CDataStream& operator<<(_UINT32 nValue)
{
nValue = ReadULong();
WriteULong(nValue);
return *this;
}
CDataStream& operator>>(double& dValue)
CDataStream& operator>>(double& dValue)
{
dValue = ReadDouble();
return *this;
@ -198,6 +264,11 @@ public:
nValue = ReadChar();
return *this;
}
CDataStream& operator<<(char nValue)
{
WriteChar(nValue);
return *this;
}
CDataStream& operator>>(bool& nValue)
{
nValue = !!ReadChar();
@ -208,17 +279,23 @@ public:
nValue = ReadShort();
return *this;
}
CDataStream& operator>>(int& nValue)
CDataStream& operator<<(short nValue)
{
WriteShort(nValue);
return *this;
}
CDataStream& operator>>(_INT32& nValue)
{
nValue = ReadLong();
return *this;
}
CDataStream& operator>>(long& nValue)
CDataStream& operator<<(_INT32 nValue)
{
nValue = ReadLong();
WriteLong(nValue);
return *this;
}
bool IsValid() const
{
if (NULL == pBuffer)
@ -255,7 +332,7 @@ public:
pCur = pBuffer;
}
unsigned int CanRead()
unsigned int CanReadWrite()
{
return (unsigned int)(pEnd - pCur);
}
@ -269,36 +346,55 @@ private:
};
struct LengthPrefixedAnsiString
{
_UINT32 size;
_UINT32 size = 0;
std::string val;
};
CDataStream & operator >> (CDataStream & strm, LengthPrefixedAnsiString & str)
static CDataStream & operator >> (CDataStream & strm, LengthPrefixedAnsiString & str)
{
strm >> str.size;
char *s = new char[str.size];
strm.ReadBytes(s, str.size);
str.val = std::string(s,str.size);
str.val = std::string(s, str.size);
delete []s;
return strm;
}
static CDataStream & operator << (CDataStream & strm, LengthPrefixedAnsiString str)
{
strm << str.size;
strm.WriteBytes((char*)str.val.c_str(), str.size - 1);
strm.WriteUChar(0);
return strm;
}
struct ObjectHeader
{
_UINT32 OLEVersion;
_UINT32 FormatID;
_UINT32 OLEVersion = 1281;
_UINT32 FormatID = 2;
LengthPrefixedAnsiString ClassName;
_UINT32 Width;
_UINT32 Height;
_UINT32 Width = 0;
_UINT32 Height = 0;
};
class Ole1FormatReader
class Ole1FormatReaderWriter
{
public:
Ole1FormatReader(BYTE *pData, int Size)
Ole1FormatReaderWriter() : NativeData(NULL), NativeDataSize(0), OtherData(NULL), OtherDataSize(0)
{
}
Ole1FormatReaderWriter(BYTE *pData, int Size) : NativeData(NULL), NativeDataSize(0), OtherData(NULL), OtherDataSize(0)
{
Read(pData, Size);
}
virtual ~Ole1FormatReaderWriter()
{
if (OtherData)
delete []OtherData;
OtherData = NULL;
}
void Read(BYTE *pData, int Size)
{
NativeDataSize = 0;
if (!pData || Size < 8) return;
@ -320,15 +416,57 @@ public:
NativeData = stream.GetCurPtr();
stream.Skip(NativeDataSize);
int sz = stream.CanRead();
if (stream.IsEof())
return;
// далее графическое представление
OtherDataSize = stream.CanReadWrite();
/// далее графическое представление
OtherData = new BYTE[OtherDataSize];
stream.ReadBytes(OtherData, OtherDataSize);
}
}
void Write(BYTE *pData, int &Size)
{
Size = 0;
if (!pData) return;
if (NativeDataSize < 1) return;
CDataStream stream(pData, NativeDataSize + 2048);
stream << Header.OLEVersion << Header.FormatID;
stream << Header.ClassName;
stream << Header.Width << Header.Height;
stream << NativeDataSize;
stream.WriteBytes(NativeData, NativeDataSize);
/// далее графическое представление
BYTE other[9] = {1, 5, 0, 0, 0, 0, 0, 0, 0};
Size = stream.Tell() - 1;
stream.WriteBytes(other, 9);
Size = stream.Tell() - 1;
//padding ???
char padding[8];
memset(padding, 0, 8);
stream.WriteBytes(padding, (Size / 8 + 1 ) * 8 - Size);
Size = stream.Tell() - 1;
}
ObjectHeader Header;
_UINT32 NativeDataSize;
BYTE *NativeData;
_UINT32 OtherDataSize;
BYTE *OtherData;
//PresentationObjectHeader PresentationHeader;
};

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