mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-16 04:45:56 +08:00
Compare commits
333 Commits
core-win-6
...
core-linux
| Author | SHA1 | Date | |
|---|---|---|---|
| b1d406b448 | |||
| ea37eab86e | |||
| d045609523 | |||
| 9336448ca9 | |||
| 5830e7824a | |||
| 821feb51b5 | |||
| 547979cd9b | |||
| c4481eb125 | |||
| ad0f2c89e0 | |||
| e15c75b6aa | |||
| b2fb7f0fe7 | |||
| 410e5ebd75 | |||
| 9c57088ef1 | |||
| 24230e12a3 | |||
| 2acef0d4a2 | |||
| aca5ffa36f | |||
| 4fc3726f37 | |||
| 2682e1fbac | |||
| f5c3ae779b | |||
| 068c60afa0 | |||
| 5b8ca5b417 | |||
| acfd12ea30 | |||
| a04b83cada | |||
| a7bf12c052 | |||
| 5c01b23dee | |||
| db11b75a2e | |||
| 2ba4c18cdf | |||
| b264f20f29 | |||
| 5e04ea62f7 | |||
| 3d1db63c0e | |||
| f124d18256 | |||
| 9bffb65dcb | |||
| 2fbcc3832f | |||
| 97b4311e95 | |||
| 228b3a52e9 | |||
| 2f2236646d | |||
| 30603d0561 | |||
| 933af771b7 | |||
| c04a537d69 | |||
| e49d78db47 | |||
| 99ec420ee5 | |||
| f764b034a1 | |||
| 73fe023460 | |||
| 242af3c80e | |||
| 7756e4b8bd | |||
| 56a1d1f627 | |||
| 11bd4ff61d | |||
| 93a06d7f86 | |||
| 76d2d429b7 | |||
| c6de37dbad | |||
| d022e669f0 | |||
| 184e79bae1 | |||
| e6581671c8 | |||
| e0a1c688bf | |||
| 9e0b301179 | |||
| 8680fb2e0e | |||
| c7c605a970 | |||
| 23d648d92d | |||
| b098c98dbb | |||
| b88726beaf | |||
| b2d3e5e194 | |||
| a8315efae0 | |||
| 3781cf6774 | |||
| 7e36d47991 | |||
| 419a01bd09 | |||
| 804a01cab3 | |||
| 931d6aa17c | |||
| 2861539949 | |||
| 281dad68fb | |||
| 04ba432cde | |||
| 61c943a3b2 | |||
| 9fdc7641b3 | |||
| 1029ee9101 | |||
| 9ef5bec2a5 | |||
| 93132eb8a0 | |||
| 9828c25e51 | |||
| db1204288b | |||
| 26c3d37be5 | |||
| 077ea08368 | |||
| 98eab74e97 | |||
| 2a7e88ca76 | |||
| 369596b860 | |||
| 15af8f561a | |||
| 58f8d13d71 | |||
| d6413057e2 | |||
| 008382213b | |||
| dd5b4a719b | |||
| 3d198bc211 | |||
| 05ff75eeb2 | |||
| 597414ea6b | |||
| 7f06ce7064 | |||
| adf39680b6 | |||
| ce77d478e3 | |||
| e1e14ae243 | |||
| 4f6e364225 | |||
| 26c02c5766 | |||
| 0d8c668f95 | |||
| 310cff0dfe | |||
| 7f6611ab21 | |||
| bb37e348f5 | |||
| 6b5e03df5e | |||
| d0e0109560 | |||
| dc33f7f197 | |||
| 85f4aa5679 | |||
| d2c5ea026f | |||
| 419ec7ed33 | |||
| 5f7d9eea02 | |||
| 709ee1942d | |||
| 5039cec847 | |||
| e59eff3a16 | |||
| 2206b3b366 | |||
| a2d37e8a22 | |||
| b13eba5f01 | |||
| a48058c7d5 | |||
| ab76aff379 | |||
| b8b8a14268 | |||
| e5ef749718 | |||
| 5d524369b8 | |||
| e78fc0befc | |||
| d9986d09cd | |||
| bd67f4bf1c | |||
| 475bfaf93d | |||
| 1a8af4d8ed | |||
| cdf8dc7a4c | |||
| d71552bddd | |||
| 548c5ab608 | |||
| 6a01384023 | |||
| d70f36e36d | |||
| f65984f079 | |||
| 5b48a7a330 | |||
| 1496aece57 | |||
| 60cf51ad0d | |||
| 8e7231b322 | |||
| 2b339b6842 | |||
| fb0dbfc231 | |||
| 756613e883 | |||
| ede03fafea | |||
| bdec91bfd5 | |||
| 260c2edd21 | |||
| 3eeec8fc67 | |||
| ba6c7e8151 | |||
| 41a213491e | |||
| b599a6bc43 | |||
| a0fd139027 | |||
| 48852bc618 | |||
| 20b781cb7e | |||
| 704b3b709f | |||
| e4674915c2 | |||
| 51fe936e5f | |||
| d8b177411f | |||
| 717b628055 | |||
| e4f94646b6 | |||
| dcec7447e4 | |||
| 5f12552f78 | |||
| d293769c1f | |||
| b45e772a50 | |||
| fdb7716abc | |||
| f72d6dfe0e | |||
| 23029a6a92 | |||
| eda8e4d13f | |||
| 64f578e59f | |||
| 16c57b50cc | |||
| 83c0ba9dab | |||
| a2443dadeb | |||
| 789bb1d4b3 | |||
| 4138ae5ce2 | |||
| 239b5dbf11 | |||
| c046776b9c | |||
| 055a02570b | |||
| e7bbbec0de | |||
| 1e2e5996f3 | |||
| 875717acd4 | |||
| 033feeaf9d | |||
| de336e5f96 | |||
| 82b3dbdae6 | |||
| d1227f7759 | |||
| 4d134387f9 | |||
| 3f8600dfb7 | |||
| 511f043d63 | |||
| 69a41343c2 | |||
| 578327bab6 | |||
| 52908908a5 | |||
| 24d9b99a44 | |||
| dce58b628f | |||
| f42cb4580c | |||
| 52777e36cb | |||
| 7b7e9f3e6e | |||
| d39fa156e7 | |||
| 48bf40919c | |||
| fd53a987be | |||
| b4d298542a | |||
| bae854027b | |||
| 9723c379dd | |||
| e8d8b2e56c | |||
| adb84b0f05 | |||
| a4ee30d031 | |||
| e05194b277 | |||
| 21f7f6ed5b | |||
| 80863ae25b | |||
| 07562a9582 | |||
| 6da196e426 | |||
| d220cc8c79 | |||
| f53c3d9f50 | |||
| fa98f22e3d | |||
| e01c09bcc9 | |||
| 069544bf6c | |||
| b0f0f656af | |||
| 99191e65b0 | |||
| fb41720817 | |||
| 406c290be4 | |||
| 5ae4d7f819 | |||
| e69c1677b2 | |||
| 4d836c180a | |||
| e08b6542d4 | |||
| e1340c63ec | |||
| 4b122c0b94 | |||
| 867438833b | |||
| 8b80aa94b7 | |||
| f960fc60bb | |||
| 64213746b0 | |||
| 09941c67ac | |||
| c2605bb582 | |||
| ab2703c825 | |||
| 08ce8cb3f5 | |||
| 5efe043ab3 | |||
| f2af1ccd36 | |||
| 113d5b4ca3 | |||
| d3461dd3cb | |||
| e95a0fb765 | |||
| c5ce1e27e4 | |||
| 7ecc7fa1df | |||
| c46cd9e6e5 | |||
| e299e59d11 | |||
| 1e0f4d6fdb | |||
| 4dae8f50fa | |||
| 9cc5ed1db0 | |||
| 6d1dd9c420 | |||
| a038e1562f | |||
| 549e3dc579 | |||
| 8440b18223 | |||
| 9c7a03fdc5 | |||
| 9272b27a69 | |||
| ef57330a79 | |||
| d35619eeae | |||
| b38c552cc5 | |||
| 1b91ee579c | |||
| 337c92e522 | |||
| 8fe1eb7525 | |||
| 1deb2a6905 | |||
| 470eddf2b1 | |||
| 69a787411c | |||
| 22f986295f | |||
| 86d2bde83b | |||
| 07041d60f6 | |||
| a5466ab740 | |||
| dfd54ff53f | |||
| 6ec7d77e19 | |||
| 3813be21c7 | |||
| 356ccba104 | |||
| 68c8c0cb29 | |||
| 3044d1122a | |||
| fb00ba7ecb | |||
| ab0c5703a5 | |||
| e22b63347f | |||
| 9dd115ec56 | |||
| 438ba3aded | |||
| 29b002ca80 | |||
| 34083d996b | |||
| 244d549cf8 | |||
| ef96571879 | |||
| 7a27150de6 | |||
| 2197fddb7b | |||
| d31344d7d3 | |||
| f7617b42cb | |||
| 8312cce2c3 | |||
| dc89e1d484 | |||
| 17f4903347 | |||
| ebdfb2f785 | |||
| ec2901bf48 | |||
| f9e87624c0 | |||
| 5f0e6349cc | |||
| 3bdf44b8c7 | |||
| d586698025 | |||
| eb6fb03ca5 | |||
| ad40f51dee | |||
| 5e60456fc1 | |||
| 1f9e3f4fd8 | |||
| 334620cd5a | |||
| 4a5fca5ccf | |||
| 828df16fe5 | |||
| 66dae03919 | |||
| 114a01f364 | |||
| 2ddaf33156 | |||
| 1af37af850 | |||
| b58026ea66 | |||
| 09a8a6794a | |||
| 941cbe4f9b | |||
| 668d0c2abf | |||
| 66db5b09e6 | |||
| e7dae4b381 | |||
| 7dbbacf336 | |||
| f43a0bbfe2 | |||
| 746c228261 | |||
| d8c7d41462 | |||
| 4a9abce180 | |||
| a78711a19c | |||
| b69051a5b4 | |||
| 04e4f1adae | |||
| 6e15370af2 | |||
| 57465b60bf | |||
| 24d58fe189 | |||
| 56bb39f716 | |||
| 60bcca0090 | |||
| 92ce863bdf | |||
| 48d4b72d4b | |||
| 85de7ec7a6 | |||
| 9e6d4950c2 | |||
| cb4befa078 | |||
| ac1292a17a | |||
| 007a984c36 | |||
| d3d3180402 | |||
| fa9c096f3c | |||
| e1ec9d942e | |||
| 4acaa75b06 | |||
| 431115ef48 | |||
| 2d66d9902e | |||
| 206dd12a47 | |||
| e8d3059fe8 | |||
| f624f731de | |||
| ed373b7e2d | |||
| a67eb5644d | |||
| 5040220d82 | |||
| 4f0b889f04 |
@ -501,7 +501,7 @@ namespace DocFileFormat
|
||||
|
||||
facet.widen((char*)bytes, (char*)bytes + size, &result[0]);
|
||||
|
||||
for (long i=0; i < result.length(); i++)
|
||||
for (size_t i=0; i < result.length(); i++)
|
||||
{
|
||||
STLCollection->push_back(result[i]);
|
||||
}
|
||||
@ -536,7 +536,7 @@ namespace DocFileFormat
|
||||
delete [] pStrUtf16;
|
||||
return GetSTLCollectionFromLocale(STLCollection, bytes,size);
|
||||
}
|
||||
for (long i=0; i < nLength; i++)
|
||||
for (unsigned int i = 0; i < nLength; i++)
|
||||
{
|
||||
STLCollection->push_back(pStrUtf16[i]);
|
||||
}
|
||||
@ -566,7 +566,7 @@ namespace DocFileFormat
|
||||
delete [] pStrUtf32;
|
||||
return GetSTLCollectionFromLocale(STLCollection, bytes, size);
|
||||
}
|
||||
for (long i=0; i < nLength; i++)
|
||||
for (unsigned int i = 0; i < nLength; i++)
|
||||
{
|
||||
STLCollection->push_back(pStrUtf32[i]);
|
||||
}
|
||||
@ -652,7 +652,7 @@ namespace DocFileFormat
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, size, sCodePage.c_str());
|
||||
|
||||
for (long i=0; i < unicode_string.size(); i++)
|
||||
for (size_t i = 0; i < unicode_string.size(); i++)
|
||||
{
|
||||
STLCollection->push_back(unicode_string[i]);
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ namespace XMLTools
|
||||
else
|
||||
{
|
||||
std::string s(m_str.begin(), m_str.end());
|
||||
file.WriteFile((unsigned char*)s.c_str(), s.length());
|
||||
file.WriteFile((unsigned char*)s.c_str(), (DWORD)s.length());
|
||||
}
|
||||
file.CloseFile();
|
||||
return true;
|
||||
|
||||
@ -321,7 +321,7 @@ namespace DocFileFormat
|
||||
|
||||
case sprmCFtcBi :
|
||||
{//default from FontTable
|
||||
SHORT nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
|
||||
size_t nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
|
||||
if( nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
|
||||
@ -373,7 +373,7 @@ namespace DocFileFormat
|
||||
case sprmOldCFtc:
|
||||
case sprmCRgFtc0:
|
||||
{ // font family
|
||||
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
if( nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
@ -388,7 +388,8 @@ namespace DocFileFormat
|
||||
|
||||
case sprmCRgFtc1:
|
||||
{
|
||||
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
if( nIndex >= 0 && nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute( L"w:eastAsia" );
|
||||
@ -403,7 +404,8 @@ namespace DocFileFormat
|
||||
|
||||
case sprmCRgFtc2:
|
||||
{
|
||||
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute( L"w:hAnsi" );
|
||||
|
||||
@ -69,8 +69,13 @@ namespace OpenXmlContentTypes
|
||||
static const wchar_t* Tiff = L"image/tiff";
|
||||
static const wchar_t* Wmf = L"image/x-wmf";
|
||||
static const wchar_t* Bmp = L"image/bmp";
|
||||
static const wchar_t* Pcz = L"image/x-pcz";
|
||||
}
|
||||
namespace DocPrContentTypes
|
||||
{
|
||||
static const wchar_t* App = L"application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
||||
static const wchar_t* Core = L"application/vnd.openxmlformats-package.core-properties+xml";
|
||||
}
|
||||
|
||||
namespace WordprocessingMLContentTypes
|
||||
{
|
||||
// WordprocessingML content types
|
||||
@ -136,7 +141,7 @@ namespace OpenXmlNamespaces
|
||||
|
||||
namespace OpenXmlRelationshipTypes
|
||||
{
|
||||
static const wchar_t* CoreProperties = L"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
||||
static const wchar_t* CoreProperties = L"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
|
||||
static const wchar_t* ExtendedProperties = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
|
||||
|
||||
static const wchar_t* Theme = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
||||
@ -157,6 +162,7 @@ namespace OpenXmlRelationshipTypes
|
||||
static const wchar_t* OleObject = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
||||
static const wchar_t* GlossaryDocument = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument";
|
||||
static const wchar_t* Package = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
||||
static const wchar_t* VbaProject = L"http://schemas.microsoft.com/office/2006/relationships/vbaProject";
|
||||
}
|
||||
|
||||
namespace MicrosoftWordRelationshipTypes
|
||||
|
||||
@ -47,30 +47,17 @@ namespace DocFileFormat
|
||||
|
||||
virtual ~ConversionContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Adds a new RSID to the set
|
||||
inline void AddRsid(const std::wstring& rsid)
|
||||
{
|
||||
if (AllRsids.find(rsid) == AllRsids.end())
|
||||
AllRsids.insert(rsid);
|
||||
}
|
||||
|
||||
inline WordDocument* GetDocument()
|
||||
{
|
||||
return _doc;
|
||||
}
|
||||
|
||||
inline WordprocessingDocument* GetXmlDocument()
|
||||
{
|
||||
return _docx;
|
||||
}
|
||||
|
||||
public:
|
||||
WordprocessingDocument* _docx;
|
||||
WordDocument* _doc;
|
||||
/// A set thta contains all revision ids.
|
||||
|
||||
std::set<std::wstring> AllRsids;
|
||||
};
|
||||
}
|
||||
@ -63,9 +63,17 @@ namespace DocFileFormat
|
||||
{
|
||||
long Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
|
||||
{
|
||||
if (!doc || !docx) return S_FALSE;
|
||||
|
||||
ConversionContext context( doc, docx );
|
||||
|
||||
//Write styles.xml
|
||||
//Write fontTable.xml
|
||||
if (doc->FontTable)
|
||||
{
|
||||
FontTableMapping fontTableMapping( &context );
|
||||
doc->FontTable->Convert( &fontTableMapping );
|
||||
}
|
||||
//Write styles.xml
|
||||
if (doc->Styles)
|
||||
{
|
||||
StyleSheetMapping styleSheetMapping( &context );
|
||||
@ -88,9 +96,7 @@ namespace DocFileFormat
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Write numbering.xml
|
||||
//Write numbering.xml
|
||||
if (doc->listTable)
|
||||
{
|
||||
NumberingMapping numberingMapping( &context );
|
||||
@ -109,14 +115,6 @@ namespace DocFileFormat
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//Write fontTable.xml
|
||||
if (doc->FontTable)
|
||||
{
|
||||
FontTableMapping fontTableMapping( &context );
|
||||
doc->FontTable->Convert( &fontTableMapping );
|
||||
}
|
||||
|
||||
if ( progress != NULL )
|
||||
{
|
||||
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 875000 );
|
||||
@ -130,7 +128,7 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
//write the footnotes
|
||||
//write the footnotes
|
||||
FootnotesMapping footnotesMapping( &context );
|
||||
doc->Convert( &footnotesMapping );
|
||||
|
||||
@ -147,7 +145,7 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
//write the endnotes
|
||||
//write the endnotes
|
||||
EndnotesMapping endnotesMapping( &context );
|
||||
doc->Convert( &endnotesMapping );
|
||||
|
||||
@ -164,7 +162,7 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
//write the comments
|
||||
//write the comments
|
||||
CommentsMapping commentsMapping( &context );
|
||||
doc->Convert( &commentsMapping );
|
||||
|
||||
@ -181,13 +179,13 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
//write settings.xml at last because of the rsid list
|
||||
//write settings.xml at last because of the rsid list
|
||||
if (doc->DocProperties)
|
||||
{
|
||||
SettingsMapping settingsMapping( &context );
|
||||
doc->DocProperties->Convert( &settingsMapping );
|
||||
}
|
||||
|
||||
|
||||
if ( progress != NULL )
|
||||
{
|
||||
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 975000 );
|
||||
@ -204,7 +202,7 @@ namespace DocFileFormat
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress)
|
||||
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
|
||||
{
|
||||
long result = S_FALSE;
|
||||
|
||||
@ -219,7 +217,7 @@ namespace DocFileFormat
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
docx.SaveDocument();
|
||||
docx.SaveDocument(bMacros);
|
||||
|
||||
if (progress)progress->OnProgress(progress->caller, DOC_ONPROGRESSEVENT_ID, 1000000);
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ namespace DocFileFormat
|
||||
|
||||
std::wstring m_sTempFolder;
|
||||
|
||||
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress);
|
||||
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress, bool &bMacros);
|
||||
|
||||
private:
|
||||
long Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);
|
||||
|
||||
@ -88,7 +88,7 @@ namespace DocFileFormat
|
||||
int DocumentMapping::getCurrentSection(int cp)
|
||||
{
|
||||
//if cp is the last char of a section, the next section will start at cp +1
|
||||
int current = 0;
|
||||
size_t current = 0;
|
||||
|
||||
for (std::vector<int>::iterator iter = m_document->SectionPlex->CharacterPositions.begin() + 1; iter != m_document->SectionPlex->CharacterPositions.end(); ++iter)
|
||||
{
|
||||
@ -107,7 +107,7 @@ namespace DocFileFormat
|
||||
{
|
||||
if ( !m_document->ListPlex ) return -1;
|
||||
|
||||
for (int i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
|
||||
for (size_t i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
|
||||
{
|
||||
if ((fc >= m_document->ListPlex->CharacterPositions[i-1]) && (fc_end <= m_document->ListPlex->CharacterPositions[i]))
|
||||
{
|
||||
@ -382,7 +382,7 @@ namespace DocFileFormat
|
||||
int DocumentMapping::writeRun (std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp)
|
||||
{
|
||||
int cp = initialCp;
|
||||
int result_cp = cp + chars->size();
|
||||
int result_cp = cp + (int)chars->size();
|
||||
|
||||
if ((_skipRuns <= 0) && (chars->size() > 0))
|
||||
{
|
||||
@ -559,12 +559,12 @@ namespace DocFileFormat
|
||||
m_pXmlWriter->WriteString(elem.GetXMLString());
|
||||
}
|
||||
else if (TextMark::FieldBeginMark == code)
|
||||
{
|
||||
{//todooo в отдельный mapping
|
||||
int cpFieldStart = initialCp + i;
|
||||
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
|
||||
|
||||
std::wstring f;
|
||||
if (cpFieldEnd < m_document->Text->size())
|
||||
if (cpFieldEnd < (int)m_document->Text->size())
|
||||
f = std::wstring( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) );
|
||||
|
||||
std::wstring EMBED ( L" EMBED" );
|
||||
@ -599,20 +599,38 @@ namespace DocFileFormat
|
||||
|
||||
if ( bFORM )
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
|
||||
std::wstring FORMTEXT ( L" FORMTEXT" );
|
||||
std::wstring FORMCHECKBOX ( L" FORMCHECKBOX" );
|
||||
std::wstring FORMDROPDOWN ( L" FORMDROPDOWN" );
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
|
||||
m_pXmlWriter->WriteAttribute( L"w:fldCharType" , L"begin" );
|
||||
m_pXmlWriter->WriteNodeEnd( L"", true, false );
|
||||
|
||||
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
|
||||
bool bFORMTEXT = search( f.begin(), f.end(), FORMTEXT.begin(), FORMTEXT.end()) != f.end();
|
||||
bool bFORMCHECKBOX = search( f.begin(), f.end(), FORMCHECKBOX.begin(), FORMCHECKBOX.end()) != f.end();
|
||||
bool bFORMDROPDOWN = search( f.begin(), f.end(), FORMDROPDOWN.begin(), FORMDROPDOWN.end()) != f.end();
|
||||
|
||||
/*if (cpPic < cpFieldEnd)
|
||||
if (bFORMTEXT || bFORMCHECKBOX || bFORMDROPDOWN)
|
||||
{
|
||||
int fcPic = _doc.PieceTable.FileCharacterPositions[cpPic];
|
||||
CharacterPropertyExceptions chpxPic = _doc.GetCharacterPropertyExceptions(fcPic, fcPic + 1)[0];
|
||||
NilPicfAndBinData npbd = new NilPicfAndBinData(chpxPic, _doc.DataStream);
|
||||
FormFieldData ffdata = new FormFieldData(npbd.binData);
|
||||
ffdata.Convert(new FormFieldDataMapping(m_pXmlWriter));
|
||||
}*/
|
||||
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
|
||||
if (cpPic < cpFieldEnd)
|
||||
{
|
||||
int fcPic = m_document->FindFileCharPos( cpPic );
|
||||
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
|
||||
|
||||
if (chpxs)
|
||||
{
|
||||
CharacterPropertyExceptions* chpxSep = chpxs->front();
|
||||
|
||||
FormFieldData ffdata (2, chpxSep, m_document->DataStream, false);
|
||||
FormFieldDataMapping data_mapping(m_pXmlWriter, m_context, _caller);
|
||||
ffdata.Convert(&data_mapping);
|
||||
|
||||
RELEASEOBJECT( chpxs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
|
||||
|
||||
@ -660,11 +678,11 @@ namespace DocFileFormat
|
||||
|
||||
if (search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end())
|
||||
{
|
||||
int d = f1.find(PAGEREF);
|
||||
int d = (int)f1.find(PAGEREF);
|
||||
|
||||
_writeWebHidden = true;
|
||||
std::wstring _writeTocLink =f1.substr(d + 9);
|
||||
d = _writeTocLink.find(L" ");
|
||||
d = (int)_writeTocLink.find(L" ");
|
||||
_writeTocLink = _writeTocLink.substr(0, d);
|
||||
|
||||
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
|
||||
@ -809,6 +827,13 @@ namespace DocFileFormat
|
||||
{
|
||||
if (_fldCharCounter > 0)
|
||||
{
|
||||
if (_writeInstrText == true && !text.empty())
|
||||
{
|
||||
writeTextElement(text, textType);
|
||||
text.clear();
|
||||
}
|
||||
_writeInstrText = false;
|
||||
|
||||
XMLTools::XMLElement elem( L"w:fldChar" );
|
||||
elem.AppendAttribute( L"w:fldCharType", L"end" );
|
||||
|
||||
@ -902,7 +927,7 @@ namespace DocFileFormat
|
||||
{
|
||||
int shape_type = oPicture.shapeContainer->getShapeType();
|
||||
|
||||
if (shape_type != msosptPictureFrame) picture = false;
|
||||
if (shape_type != msosptPictureFrame) picture = false;//шаблон 1.doc картинка в колонтитуле
|
||||
}
|
||||
|
||||
if (picture)
|
||||
@ -1176,7 +1201,8 @@ namespace DocFileFormat
|
||||
TableInfo tai( papx );
|
||||
|
||||
//build the table grid
|
||||
std::vector<short>* grid = buildTableGrid( cp, nestingLevel );
|
||||
std::vector<short> grid, grid_write;
|
||||
buildTableGrid( cp, nestingLevel, grid, grid_write );
|
||||
|
||||
//find first row end
|
||||
int fcRowEnd = findRowEndFc( cp, nestingLevel );
|
||||
@ -1187,7 +1213,7 @@ namespace DocFileFormat
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:tbl" );
|
||||
|
||||
//Convert it
|
||||
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, grid );
|
||||
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid, &grid_write );
|
||||
|
||||
row1Tapx.Convert( tpMapping );
|
||||
|
||||
@ -1200,7 +1226,7 @@ namespace DocFileFormat
|
||||
//only convert the cells with the given nesting level
|
||||
while ( tai.iTap == nestingLevel )
|
||||
{
|
||||
cp = writeTableRow( cp, grid, nestingLevel );
|
||||
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
|
||||
//?fc = m_document->FindFileCharPos(cp );
|
||||
fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
|
||||
papx = findValidPapx( fc );
|
||||
@ -1213,7 +1239,7 @@ namespace DocFileFormat
|
||||
//convert until the end of table is reached
|
||||
while ( tai.fInTable )
|
||||
{
|
||||
cp = writeTableRow( cp, grid, nestingLevel );
|
||||
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
|
||||
fc = m_document->FindFileCharPos( cp );
|
||||
|
||||
papx = findValidPapx( fc );
|
||||
@ -1224,18 +1250,16 @@ namespace DocFileFormat
|
||||
//close w:tbl
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:tbl" );
|
||||
|
||||
RELEASEOBJECT( grid );
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
// Builds a list that contains the width of the several columns of the table.
|
||||
std::vector<short>* DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel)
|
||||
bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write)
|
||||
{
|
||||
ParagraphPropertyExceptions* backup = _lastValidPapx;
|
||||
|
||||
std::vector<short> boundaries;
|
||||
std::vector<short>* grid = new std::vector<short>();
|
||||
std::vector<short> boundaries_all;
|
||||
|
||||
int cp = initialCp;
|
||||
int fc = m_document->FindFileCharPos( cp );
|
||||
@ -1252,25 +1276,43 @@ namespace DocFileFormat
|
||||
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
|
||||
{
|
||||
//find the tDef SPRM
|
||||
if ( iter->OpCode == sprmTDefTable || iter->OpCode == sprmOldTDefTable)
|
||||
DWORD code = iter->OpCode;
|
||||
|
||||
switch(iter->OpCode)
|
||||
{
|
||||
case sprmTDefTable:
|
||||
case sprmOldTDefTable:
|
||||
{
|
||||
unsigned char itcMac = iter->Arguments[0];
|
||||
|
||||
for (int i = 0; i < itcMac; i++)
|
||||
while(boundaries.size() < itcMac + 1)
|
||||
boundaries.push_back(-0x7fff);
|
||||
|
||||
short boundary0 = -0x7fff;
|
||||
for (unsigned char i = 0; i < itcMac; i++)
|
||||
{
|
||||
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
|
||||
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
|
||||
|
||||
if ( find( boundaries.begin(), boundaries.end(), boundary1 ) == boundaries.end() )
|
||||
if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1)
|
||||
{
|
||||
boundaries.push_back( boundary1 );
|
||||
if ( boundaries[i] == -0x7fff || boundaries[i+1] == -0x7fff)
|
||||
{
|
||||
boundaries[i] = boundary1;
|
||||
boundaries[i+1] = boundary2;
|
||||
}
|
||||
}
|
||||
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary1 ) == boundaries_all.end() )
|
||||
{
|
||||
boundaries_all.push_back( boundary1 );
|
||||
}
|
||||
|
||||
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
|
||||
|
||||
if ( find( boundaries.begin(), boundaries.end(), boundary2 ) == boundaries.end() )
|
||||
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() )
|
||||
{
|
||||
boundaries.push_back( boundary2 );
|
||||
boundaries_all.push_back( boundary2 );
|
||||
}
|
||||
boundary0 = boundary1;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1286,19 +1328,25 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
//build the grid based on the boundaries
|
||||
sort( boundaries.begin(), boundaries.end() );
|
||||
sort( boundaries_all.begin(), boundaries_all.end() );
|
||||
|
||||
if ( !boundaries.empty() )
|
||||
{
|
||||
for ( unsigned int i = 0; i < ( boundaries.size() - 1 ); i++ )
|
||||
for ( size_t i = 0; i < ( boundaries.size() - 1 ); i++ )
|
||||
{
|
||||
grid->push_back( boundaries[i + 1] - boundaries[i] );
|
||||
grid_write.push_back( boundaries[i + 1] - boundaries[i] );
|
||||
}
|
||||
}
|
||||
if ( !boundaries_all.empty() )
|
||||
{
|
||||
for ( size_t i = 0; i < ( boundaries_all.size() - 1 ); i++ )
|
||||
{
|
||||
grid.push_back( boundaries_all[i + 1] - boundaries_all[i] );
|
||||
}
|
||||
}
|
||||
|
||||
_lastValidPapx = backup;
|
||||
|
||||
return grid;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Finds the FC of the next row end mark.
|
||||
@ -1418,7 +1466,7 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
/// Writes the table row that starts at the given cp value and ends at the next row end mark
|
||||
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, unsigned int nestingLevel)
|
||||
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel)
|
||||
{
|
||||
int cp = initialCp;
|
||||
int fc = m_document->FindFileCharPos( cp );
|
||||
@ -1448,7 +1496,7 @@ namespace DocFileFormat
|
||||
//Write until the first "inner trailer paragraph" is reached
|
||||
while ( !( ( m_document->Text->at( cp ) == TextMark::ParagraphEnd ) && ( tai.fInnerTtp ) ) && tai.fInTable )
|
||||
{
|
||||
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
|
||||
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
|
||||
cellIndex++;
|
||||
|
||||
//each cell has it's own PAPX
|
||||
@ -1465,7 +1513,7 @@ namespace DocFileFormat
|
||||
while ( !( ( m_document->Text->at( cp ) == TextMark::CellOrRowMark ) && ( tai.fTtp ) )
|
||||
&& tai.fInTable )
|
||||
{
|
||||
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
|
||||
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
|
||||
cellIndex++;
|
||||
|
||||
//each cell has it's own PAPX
|
||||
@ -1488,18 +1536,15 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
/// Writes the table cell that starts at the given cp value and ends at the next cell end mark
|
||||
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel )
|
||||
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel )
|
||||
{
|
||||
int cp = initialCp;
|
||||
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
|
||||
|
||||
//start w:tc
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
//find cell end
|
||||
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
|
||||
|
||||
//convert the properties
|
||||
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex );
|
||||
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex );
|
||||
|
||||
if ( tapx != NULL )
|
||||
{
|
||||
|
||||
@ -48,6 +48,8 @@
|
||||
#include "OleObjectMapping.h"
|
||||
#include "ConversionContext.h"
|
||||
#include "IMapping.h"
|
||||
#include "FormFieldData.h"
|
||||
#include "FormFieldDataMapping.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
@ -108,15 +110,15 @@ namespace DocFileFormat
|
||||
// Writes the table starts at the given cp value
|
||||
int writeTable ( int initialCp, unsigned int nestingLevel );
|
||||
// Builds a list that contains the width of the several columns of the table.
|
||||
std::vector<short>* buildTableGrid( int initialCp, unsigned int nestingLevel );
|
||||
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write );
|
||||
// Finds the FC of the next row end mark.
|
||||
int findRowEndFc ( int initialCp, int& rowEndCp, unsigned int nestingLevel );
|
||||
// Finds the FC of the next row end mark.
|
||||
int findRowEndFc ( int initialCp, unsigned int nestingLevel );
|
||||
// Writes the table row that starts at the given cp value and ends at the next row end mark
|
||||
int writeTableRow ( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
|
||||
int writeTableRow ( int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel );
|
||||
// Writes the table cell that starts at the given cp value and ends at the next cell end mark
|
||||
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
|
||||
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel );
|
||||
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
|
||||
|
||||
bool writeBookmarks ( int cp );
|
||||
|
||||
@ -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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -48,7 +48,8 @@ namespace DocFileFormat
|
||||
|
||||
class FontFamilyName: public ByteStructure
|
||||
{
|
||||
friend class CharacterPropertiesMapping;
|
||||
friend class WordDocument;
|
||||
friend class CharacterPropertiesMapping;
|
||||
friend class DocumentMapping;
|
||||
friend class FontTableMapping;
|
||||
friend class StyleSheetMapping;
|
||||
|
||||
@ -34,32 +34,30 @@
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
FontTableMapping::FontTableMapping( ConversionContext* ctx ): AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
|
||||
FontTableMapping::FontTableMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
|
||||
{
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
FontTableMapping::~FontTableMapping()
|
||||
{
|
||||
RELEASEOBJECT (m_pXmlWriter);
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
void FontTableMapping::Apply( IVisitable* visited )
|
||||
{
|
||||
StringTable<FontFamilyName>* table = static_cast<StringTable<FontFamilyName>*>( visited );
|
||||
|
||||
this->_ctx->_docx->RegisterFontTable();
|
||||
_ctx->_docx->RegisterFontTable();
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fonts", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
|
||||
|
||||
int sz_fonts = table->Data.size();
|
||||
int sz_fonts = table->Data.size();
|
||||
int users_fonts = 0;
|
||||
|
||||
for ( std::vector<ByteStructure*>::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ )
|
||||
@ -140,6 +138,6 @@ namespace DocFileFormat
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:fonts");
|
||||
|
||||
this->_ctx->_docx->FontTableXML = std::wstring( m_pXmlWriter->GetXmlString() );
|
||||
_ctx->_docx->FontTableXML = m_pXmlWriter->GetXmlString() ;
|
||||
}
|
||||
}
|
||||
|
||||
170
ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp
Normal file
170
ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "FormFieldData.h"
|
||||
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
std::wstring readXstz(VirtualStreamReader *reader)
|
||||
{
|
||||
if (!reader) return L"";
|
||||
|
||||
unsigned short flags, cch, chTerm;
|
||||
|
||||
cch = reader->ReadUInt16();
|
||||
|
||||
std::wstring ret;
|
||||
|
||||
if (cch > 0)
|
||||
{
|
||||
std::shared_ptr<unsigned char>data = std::shared_ptr<unsigned char>(reader->ReadBytes(cch * 2, true));
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
ret = std::wstring((wchar_t*)data.get(), cch );
|
||||
#else
|
||||
ret = convertUtf16ToWString((UTF16*)data.get(), cch );
|
||||
#endif
|
||||
}
|
||||
chTerm = reader->ReadUInt16();
|
||||
|
||||
return ret;
|
||||
};
|
||||
void FormFieldData::_HFD::read(VirtualStreamReader *reader)
|
||||
{
|
||||
if (!reader) return;
|
||||
}
|
||||
void FormFieldData::_FFData::read(VirtualStreamReader *reader)
|
||||
{
|
||||
if (!reader) return;
|
||||
|
||||
bExist = true;
|
||||
|
||||
unsigned short flags;
|
||||
|
||||
version = reader->ReadUInt32();
|
||||
flags = reader->ReadUInt16();
|
||||
|
||||
iType = GETBITS(flags, 0, 1);
|
||||
iRes = GETBITS(flags, 2, 6);
|
||||
fOwnHelp = GETBIT(flags, 7);
|
||||
fOwnStat = GETBIT(flags, 8);
|
||||
fProt = GETBIT(flags, 9);
|
||||
iSize = GETBIT(flags, 10);
|
||||
iTypeTxt = GETBITS(flags, 11, 13);
|
||||
fRecalc = GETBIT(flags, 14);
|
||||
fHasListBox = GETBIT(flags, 15);
|
||||
|
||||
cch_field = reader->ReadUInt16();
|
||||
hps = reader->ReadUInt16();
|
||||
|
||||
xstzName = readXstz(reader);
|
||||
xstzTextDef = readXstz(reader);
|
||||
|
||||
wDef = reader->ReadUInt16();
|
||||
|
||||
xstzTextFormat = readXstz(reader);
|
||||
xstzHelpText = readXstz(reader);
|
||||
xstzStatText = readXstz(reader);
|
||||
xstzEntryMcr = readXstz(reader);
|
||||
xstzExitMcr = readXstz(reader);
|
||||
}
|
||||
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion_ )
|
||||
{
|
||||
binary_data_size = 0;
|
||||
|
||||
if (!chpx) return;
|
||||
|
||||
int fc = -1;
|
||||
bool bNilPICFAndBinData = false;
|
||||
|
||||
for ( std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
|
||||
{
|
||||
switch ( iter->OpCode)
|
||||
{
|
||||
case sprmCFSpec:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case sprmCFFldVanish:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case sprmCPicLocation:
|
||||
{
|
||||
fc = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
|
||||
}
|
||||
break;
|
||||
case sprmCRsidText:
|
||||
{
|
||||
rsid = FormatUtils::IntToFormattedWideString(FormatUtils::BytesToInt32(iter->Arguments, 0, iter->argumentsSize), L"%08x");
|
||||
}
|
||||
break;
|
||||
case sprmCFData:
|
||||
{
|
||||
bNilPICFAndBinData = true; // or bPICFAndOfficeArtData - shape, pic, ole
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fc >= 0 && bNilPICFAndBinData)
|
||||
{
|
||||
VirtualStreamReader reader(stream, fc, bOlderVersion_);
|
||||
|
||||
int sz_stream = reader.GetSize();
|
||||
|
||||
int lcb = reader.ReadUInt32();
|
||||
int cbHeader = reader.ReadUInt16();
|
||||
|
||||
if (cbHeader != 0x44) return;
|
||||
|
||||
//ignored
|
||||
reader.ReadBytes(62, false);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 1:
|
||||
HFD.read(&reader);
|
||||
case 2:
|
||||
FFData.read(&reader);
|
||||
break;
|
||||
default:
|
||||
binary_data_size = lcb - cbHeader;
|
||||
binary_data = std::shared_ptr<unsigned char>(reader.ReadBytes(binary_data_size, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
126
ASCOfficeDocFile/DocDocxConverter/FormFieldData.h
Normal file
126
ASCOfficeDocFile/DocDocxConverter/FormFieldData.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "IVisitable.h"
|
||||
#include "CharacterPropertyExceptions.h"
|
||||
#include "StructuredStorageReader.h"
|
||||
#include "VirtualStreamReader.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
class FormFieldData : public IVisitable
|
||||
{
|
||||
public:
|
||||
|
||||
struct _HFD
|
||||
{
|
||||
bool bExist = false;
|
||||
|
||||
bool fNew = false;
|
||||
bool fNoHist = false;
|
||||
bool fImageMap = false;
|
||||
bool fLocation = false;
|
||||
bool fTooltip = false;
|
||||
|
||||
std::wstring clsid;
|
||||
|
||||
_UINT32 streamVersion = 0;
|
||||
bool hlstmfHasMoniker = false;
|
||||
bool hlstmfIsAbsolute = false;
|
||||
bool hlstmfSiteGaveDisplayName = false;
|
||||
bool hlstmfHasLocationStr = false;
|
||||
bool hlstmfHasDisplayName = false;
|
||||
bool hlstmfHasGUID = false;
|
||||
bool hlstmfHasCreationTime = false;
|
||||
bool hlstmfHasFrameName = false;
|
||||
bool hlstmfMonikerSavedAsStr = false;
|
||||
bool hlstmfAbsFromGetdataRel = false;
|
||||
|
||||
std::wstring displayName;
|
||||
std::wstring targetFrameName;
|
||||
std::wstring moniker;
|
||||
|
||||
std::wstring oleMoniker_clsid;
|
||||
std::wstring oleMoniker_data;
|
||||
std::wstring location;
|
||||
|
||||
std::wstring guid;
|
||||
_UINT64 fileTime = 0;
|
||||
|
||||
void read(VirtualStreamReader* reader);
|
||||
};
|
||||
struct _FFData
|
||||
{
|
||||
bool bExist = false;
|
||||
_UINT32 version = 0;
|
||||
|
||||
unsigned char iType = 0;
|
||||
unsigned char iRes = 0;
|
||||
bool fOwnHelp = false;
|
||||
bool fOwnStat = false;
|
||||
bool fProt = false;
|
||||
bool iSize = false;
|
||||
unsigned char iTypeTxt = 0;
|
||||
bool fRecalc = false;
|
||||
bool fHasListBox = false;
|
||||
|
||||
unsigned short cch_field = 0;
|
||||
unsigned short hps = 0;
|
||||
std::wstring xstzName;
|
||||
std::wstring xstzTextDef;
|
||||
unsigned short wDef = 0;
|
||||
std::wstring xstzTextFormat;
|
||||
std::wstring xstzHelpText;
|
||||
std::wstring xstzStatText;
|
||||
std::wstring xstzEntryMcr;
|
||||
std::wstring xstzExitMcr;
|
||||
|
||||
//STTB hsttbDropList;
|
||||
void read(VirtualStreamReader* reader);
|
||||
};
|
||||
FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion );
|
||||
virtual ~FormFieldData() {}
|
||||
private:
|
||||
friend class FormFieldDataMapping;
|
||||
|
||||
std::wstring name;
|
||||
std::wstring rsid;
|
||||
|
||||
_FFData FFData;
|
||||
_HFD HFD;
|
||||
|
||||
std::shared_ptr<unsigned char> binary_data;
|
||||
int binary_data_size;
|
||||
|
||||
};
|
||||
}
|
||||
87
ASCOfficeDocFile/DocDocxConverter/FormFieldDataMapping.h
Normal file
87
ASCOfficeDocFile/DocDocxConverter/FormFieldDataMapping.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ConversionContext.h"
|
||||
#include "FormFieldData.h"
|
||||
|
||||
#include "AbstractOpenXmlMapping.h"
|
||||
#include "IMapping.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
class FormFieldDataMapping: public AbstractOpenXmlMapping, public IMapping
|
||||
{
|
||||
public:
|
||||
FormFieldDataMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, IMapping* caller)
|
||||
: AbstractOpenXmlMapping(writer), m_context(NULL),_caller(NULL)
|
||||
{
|
||||
m_context = context;
|
||||
_caller = caller;
|
||||
}
|
||||
|
||||
virtual void Apply(IVisitable* visited)
|
||||
{
|
||||
FormFieldData* ffData = static_cast<FormFieldData*>(visited);
|
||||
|
||||
if ( ffData == NULL ) return;
|
||||
|
||||
if (ffData->FFData.bExist)
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:ffData");
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:name", true);
|
||||
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.xstzName);
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:name", true, true );
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:calcOnExit", true);
|
||||
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.fRecalc);
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:calcOnExit", true, true );
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:textInput");
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:maxLength", true);
|
||||
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.cch_field);
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:maxLength", true, true );
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:textInput" );
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:ffData" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
ConversionContext* m_context;
|
||||
IMapping* _caller;
|
||||
};
|
||||
}
|
||||
@ -33,6 +33,9 @@
|
||||
|
||||
#include "IMapping.h"
|
||||
|
||||
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
|
||||
#define GETBIT(from, num) ((from & (1 << num)) != 0)
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
class IVisitable
|
||||
|
||||
@ -50,8 +50,7 @@ namespace DocFileFormat
|
||||
void MainDocumentMapping::Apply(IVisitable* visited)
|
||||
{
|
||||
m_document = static_cast<WordDocument*>(visited);
|
||||
m_context->_docx->RegisterDocument();
|
||||
|
||||
|
||||
// Header
|
||||
m_pXmlWriter->WriteNodeBegin(L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
|
||||
m_pXmlWriter->WriteNodeBegin(L"w:document", TRUE );
|
||||
|
||||
@ -38,8 +38,8 @@ namespace DocFileFormat
|
||||
{
|
||||
if (m_context)
|
||||
{
|
||||
m_document = m_context->GetDocument();
|
||||
m_xmldocument = m_context->GetXmlDocument();
|
||||
m_document = m_context->_doc;
|
||||
m_xmldocument = m_context->_docx;
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,7 +582,7 @@ namespace DocFileFormat
|
||||
// The style id is used for a reverse reference.
|
||||
// It can happen that the reference points to the wrong style.
|
||||
|
||||
if (styleIndex != ListData::ISTD_NIL)
|
||||
if (styleIndex != ListData::ISTD_NIL && styleIndex < m_document->Styles->Styles->size())
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:pStyle", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId(m_document->Styles->Styles->at(styleIndex))));
|
||||
|
||||
@ -110,6 +110,11 @@ namespace DocFileFormat
|
||||
unused2 = Reader->ReadByte();
|
||||
unused3 = Reader->ReadByte();
|
||||
|
||||
if (btMacOS != btWin32)
|
||||
{
|
||||
btWin32 = btMacOS = (Global::BlipType)this->Instance;
|
||||
}
|
||||
|
||||
if (BodySize > 0x24)
|
||||
{
|
||||
Blip = RecordFactory::ReadRecord(Reader, 0);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -192,14 +192,14 @@ public:
|
||||
{
|
||||
if (!bIsCompressed)
|
||||
{
|
||||
m_pMetaFile = pCompress;
|
||||
m_lMetaFileSize = lUncompressSize;
|
||||
m_pMetaFile = new BYTE[lCompressSize];
|
||||
m_lMetaFileSize = lCompressSize;
|
||||
memcpy(m_pMetaFile, pCompress, lCompressSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG lSize = lUncompressSize;
|
||||
m_pMetaFile = new BYTE[lUncompressSize];
|
||||
//bool bRes = NSZLib::Decompress(pCompress, (ULONG)lCompressSize, m_pMetaFile, lSize);
|
||||
|
||||
HRESULT res = S_OK;
|
||||
COfficeUtils* pOfficeUtils = new COfficeUtils(NULL);
|
||||
@ -340,6 +340,8 @@ typedef enum _BlipCompression
|
||||
|
||||
if (typeCode == 0xf01b)
|
||||
{
|
||||
oMetaFile.m_sExtension = L".wmf";
|
||||
|
||||
WmfPlaceableFileHeader oWmfHeader = {};
|
||||
oMetaHeader.ToWMFHeader(&oWmfHeader);
|
||||
|
||||
@ -349,24 +351,12 @@ typedef enum _BlipCompression
|
||||
|
||||
oMetaFile.SetHeader(pMetaHeader, lLenHeader);
|
||||
}
|
||||
|
||||
if (typeCode == 0xf01c)
|
||||
{
|
||||
oMetaFile.m_sExtension = L".pcz";
|
||||
//decompress???
|
||||
}
|
||||
oMetaFile.SetData(m_pvBits, oMetaHeader.cbSave, oMetaHeader.cbSize, 0 == oMetaHeader.compression);
|
||||
|
||||
//if (pos < sz)
|
||||
//{
|
||||
// NSFile::CFileBinary oFile;
|
||||
|
||||
// if (oFile.CreateFile(L"d:\\blop.dat"))
|
||||
// {
|
||||
// BYTE * d = Reader->ReadBytes( sz - pos, true );
|
||||
// if (d)
|
||||
// {
|
||||
// oFile.WriteFile (d, sz - pos);
|
||||
// delete []d;
|
||||
// oFile.CloseFile();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
virtual ~MetafilePictBlip()
|
||||
|
||||
@ -53,62 +53,31 @@ namespace DocFileFormat
|
||||
|
||||
PathParser (const unsigned char* pSegmentInfo, unsigned int pSegmentInfoSize, const unsigned char* pVertices, unsigned int pVerticesSize, std::vector<_guides> & guides)
|
||||
{
|
||||
|
||||
if ((pSegmentInfo != NULL) && (pSegmentInfoSize > 0))
|
||||
{
|
||||
int offset = 6;
|
||||
|
||||
unsigned short nElems = FormatUtils::BytesToUInt16(pSegmentInfo, 0, pSegmentInfoSize);
|
||||
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pSegmentInfo, 2, pSegmentInfoSize);
|
||||
unsigned short cb = FormatUtils::BytesToUInt16(pSegmentInfo, 4, pSegmentInfoSize);
|
||||
|
||||
// видимо без шапки сразу пишутся все элементы
|
||||
bool headerIs = ((0xfff0 != cb) && (cb > 8) || nElems > nElemsAlloc);
|
||||
if (headerIs)
|
||||
{
|
||||
cb = 2;
|
||||
offset = 0;
|
||||
nElems = pSegmentInfoSize / 2;
|
||||
unsigned short cbElement = 4;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToUInt16(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
}
|
||||
else
|
||||
int offset = 6;
|
||||
if (cb == 0xfff0)
|
||||
cbElement = 2;
|
||||
|
||||
if (nElems == 0)
|
||||
{
|
||||
if ((0xfff0 != cb) && (8 != cb) && (4 != cb) && (2 != cb))
|
||||
{
|
||||
cb = 0xfff0;
|
||||
offset = 0;
|
||||
nElems = pSegmentInfoSize / 2;
|
||||
}
|
||||
|
||||
if (0xfff0 == cb)
|
||||
{
|
||||
cb = 4;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToUInt16(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((2 != cb) && (1 != cb))
|
||||
cb = 8;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToInt32(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
|
||||
if ((long)pSegmentInfoSize < (long)(cb*nElems)) // Есть несколько файлов с мусором вместо данных
|
||||
m_arSegments.clear();
|
||||
}
|
||||
nElems = (pSegmentInfoSize - offset) / cbElement;
|
||||
}
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToInt32(pSegmentInfo + offset, (i * cbElement), pSegmentInfoSize - offset));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
|
||||
if ((long)pSegmentInfoSize < (long)(cb * nElems)) // Есть несколько файлов с мусором вместо данных
|
||||
m_arSegments.clear();
|
||||
}
|
||||
|
||||
if ((NULL != pVertices) && (pVerticesSize > 0))
|
||||
@ -117,20 +86,27 @@ namespace DocFileFormat
|
||||
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pVertices, 2, pVerticesSize);
|
||||
unsigned short cb = FormatUtils::BytesToUInt16(pVertices, 4, pVerticesSize);
|
||||
|
||||
unsigned short cbElement = 4;
|
||||
|
||||
if (cb == 0xfff0)
|
||||
cbElement = 2;
|
||||
|
||||
int offset = 6;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
POINT point;
|
||||
if (0xfff0 == cb)
|
||||
if (cbElement == 4)
|
||||
{
|
||||
cb = 4;
|
||||
point.x = FormatUtils::BytesToInt16(pVertices + 6, (i * cb), pVerticesSize);
|
||||
point.y = FormatUtils::BytesToInt16(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
|
||||
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 + 6, (i * cb), pVerticesSize);
|
||||
point.y = FormatUtils::BytesToInt32(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
|
||||
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)
|
||||
@ -149,7 +125,14 @@ namespace DocFileFormat
|
||||
point.y = guides[index].param3;
|
||||
}
|
||||
}
|
||||
|
||||
if ((size_t)point.y > 0xffff)
|
||||
{
|
||||
point.y &= 0xffff;
|
||||
}
|
||||
if ((size_t)point.x > 0xffff)
|
||||
{
|
||||
point.x &= 0xffff;
|
||||
}
|
||||
m_arPoints.push_back(point);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,6 @@ namespace DocFileFormat
|
||||
fUsefLockAgainstUngrouping = FormatUtils::BitmaskToBool(op,0x2000000);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
bool fLockAgainstGrouping;
|
||||
bool fLockAdjustHandles;
|
||||
|
||||
@ -63,8 +63,25 @@ namespace DocFileFormat
|
||||
Shape* sh = dynamic_cast<Shape*>( *iter );
|
||||
if (sh)
|
||||
{
|
||||
if (sh->shapeType) return sh->shapeType->GetTypeCode();
|
||||
else return 0;
|
||||
if (sh->shapeType)
|
||||
{
|
||||
return sh->shapeType->GetTypeCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( std::vector<Record*>::const_iterator iter1 = this->Children.begin(); iter1 != this->Children.end(); iter1++ )
|
||||
{
|
||||
ShapeOptions* sh_options = dynamic_cast<ShapeOptions*>( *iter1 );
|
||||
if (sh_options)
|
||||
{
|
||||
if (sh_options->OptionsByID.end() != sh_options->OptionsByID.find(Pib))
|
||||
{
|
||||
return msosptPictureFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -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
|
||||
@ -597,16 +557,12 @@ namespace DocFileFormat
|
||||
|
||||
virtual ~ShapeOptions()
|
||||
{
|
||||
//for (std::vector<OptionEntry>::iterator iter = Options.begin(); iter != Options.end(); ++iter)
|
||||
// RELEASEARRAYOBJECTS( iter->opComplex );
|
||||
}
|
||||
|
||||
ShapeOptions (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance)
|
||||
{
|
||||
long pos = Reader->GetPosition();
|
||||
|
||||
//instance is the count of properties stored in this record
|
||||
|
||||
//parse the flags and the simple values
|
||||
for (unsigned int i = 0; i < instance; ++i)
|
||||
{
|
||||
@ -621,14 +577,24 @@ namespace DocFileFormat
|
||||
Options.push_back( entry );
|
||||
}
|
||||
|
||||
//parse the complex values
|
||||
//these values are stored directly at the end
|
||||
//of the OptionEntry arry, sorted by pid
|
||||
//parse the complex values & sorted by pid
|
||||
for (unsigned int i = 0; i < instance; ++i)
|
||||
{
|
||||
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]));
|
||||
|
||||
@ -0,0 +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
|
||||
*
|
||||
*/
|
||||
#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;
|
||||
};
|
||||
}
|
||||
@ -46,35 +46,35 @@ OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorage
|
||||
|
||||
HRESULT res = S_OK;
|
||||
|
||||
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, "ObjectPool");
|
||||
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, L"ObjectPool");
|
||||
|
||||
if (ObjectPoolStorage)
|
||||
{
|
||||
ObjectId = getOleEntryName( chpx );
|
||||
|
||||
std::string sObjectId( ObjectId.begin(), ObjectId.end() );
|
||||
std::wstring sObjectId( ObjectId.begin(), ObjectId.end() );
|
||||
{
|
||||
std::string name = "ObjectPool/" + sObjectId + "/";
|
||||
processOleStream( name + "Ole" );
|
||||
std::wstring name = L"ObjectPool/" + sObjectId + L"/";
|
||||
processOleStream( name + L"Ole" );
|
||||
|
||||
if ( bLinked )
|
||||
{
|
||||
processLinkInfoStream( name + "LinkInfo" );
|
||||
processLinkInfoStream( name + L"LinkInfo" );
|
||||
}
|
||||
else
|
||||
{
|
||||
processCompObjStream( name + "CompObj" );
|
||||
processCompObjStream( name + L"CompObj" );
|
||||
}
|
||||
|
||||
processPICStream( name + "PIC" );
|
||||
processPICStream( name + L"PIC" );
|
||||
|
||||
processEquationNativeStream( name + "Equation Native" );
|
||||
processEquationNativeStream( name + L"Equation Native" );
|
||||
}
|
||||
delete ObjectPoolStorage;
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processLinkInfoStream( const std::string& linkStream )
|
||||
void OleObject::processLinkInfoStream( const std::wstring& linkStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -125,7 +125,7 @@ void OleObject::processLinkInfoStream( const std::string& linkStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processEquationNativeStream( const std::string& eqStream )
|
||||
void OleObject::processEquationNativeStream( const std::wstring& eqStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -156,7 +156,7 @@ void OleObject::processEquationNativeStream( const std::string& eqStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processPICStream( const std::string& picStream )
|
||||
void OleObject::processPICStream( const std::wstring& picStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -191,7 +191,7 @@ void OleObject::processPICStream( const std::string& picStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processCompObjStream( const std::string& compStream )
|
||||
void OleObject::processCompObjStream( const std::wstring& compStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -206,11 +206,11 @@ void OleObject::processCompObjStream( const std::string& compStream )
|
||||
//skip the CompObjHeader
|
||||
reader.ReadBytes( 28, false );
|
||||
|
||||
int sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
unsigned int sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
|
||||
if (sz_obj > 4)
|
||||
{
|
||||
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
|
||||
sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
if (sz_obj > 4)
|
||||
@ -218,7 +218,7 @@ void OleObject::processCompObjStream( const std::string& compStream )
|
||||
|
||||
sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
if (sz_obj > 4)
|
||||
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
}
|
||||
delete pCompStream;
|
||||
}
|
||||
@ -228,7 +228,7 @@ void OleObject::processCompObjStream( const std::string& compStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processOleStream( const std::string& oleStreamName )
|
||||
void OleObject::processOleStream( const std::wstring& oleStreamName )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -74,11 +74,11 @@ namespace DocFileFormat
|
||||
private:
|
||||
POLE::Storage *oleStorage;
|
||||
|
||||
void processLinkInfoStream ( const std::string& linkStream );
|
||||
void processEquationNativeStream( const std::string& eqStream );
|
||||
void processPICStream ( const std::string& picStream );
|
||||
void processCompObjStream ( const std::string& compStream );
|
||||
void processOleStream ( const std::string& oleStreamName );
|
||||
void processLinkInfoStream ( const std::wstring& linkStream );
|
||||
void processEquationNativeStream( const std::wstring& eqStream );
|
||||
void processPICStream ( const std::wstring& picStream );
|
||||
void processCompObjStream ( const std::wstring& compStream );
|
||||
void processOleStream ( const std::wstring& oleStreamName );
|
||||
|
||||
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
|
||||
};
|
||||
|
||||
@ -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" );
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include "MainDocumentMapping.h"
|
||||
#include "OleObjectMapping.h"
|
||||
#include "VMLPictureMapping.h"
|
||||
#include "FormFieldDataMapping.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
@ -63,6 +64,8 @@ namespace DocFileFormat
|
||||
DocumentContentTypesFile._defaultTypes.insert( make_pair( L"xml", std::wstring( OpenXmlContentTypes::Xml ) ) );
|
||||
|
||||
MainRelationshipsFile.Relationships.push_back( Relationship( std::wstring( L"rId1"), OpenXmlRelationshipTypes::OfficeDocument, L"word/document.xml") );
|
||||
MainRelationshipsFile.Relationships.push_back( Relationship( std::wstring( L"rId2"), OpenXmlRelationshipTypes::CoreProperties, L"docProps/core.xml") );
|
||||
MainRelationshipsFile.Relationships.push_back( Relationship( std::wstring( L"rId3"), OpenXmlRelationshipTypes::ExtendedProperties, L"docProps/app.xml") );
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +76,6 @@ namespace DocFileFormat
|
||||
|
||||
NSDirectory::CreateDirectory( m_strOutputPath + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"_rels" );
|
||||
|
||||
|
||||
WriteRelsFile( DocumentRelationshipsFile );
|
||||
|
||||
WriteRelsFile( FootnotesRelationshipsFile );
|
||||
@ -137,15 +139,17 @@ namespace DocFileFormat
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
file.CreateFileW(fileName);
|
||||
file.WriteFile((BYTE*)data.c_str(), data.size());
|
||||
file.WriteFile((BYTE*)data.c_str(), (_UINT32)data.size());
|
||||
file.CloseFile();
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure )
|
||||
{
|
||||
if (docFile == NULL) return S_FALSE;
|
||||
|
||||
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
|
||||
if (storageOut == NULL) return S_FALSE;
|
||||
|
||||
if (storageOut == NULL || docFile == NULL) return S_FALSE;
|
||||
if (storageOut->open(true, true)==false)
|
||||
{
|
||||
delete storageOut;
|
||||
@ -155,22 +159,27 @@ namespace DocFileFormat
|
||||
POLE::Storage *storageInp = docFile->GetStorage()->GetStorage();
|
||||
|
||||
{
|
||||
std::string id(oleObjectFileStructure.objectID.begin(),oleObjectFileStructure.objectID.end());
|
||||
|
||||
POLE::Stream* oleStorage = new POLE::Stream(storageInp, id);
|
||||
POLE::Stream* oleStorage = new POLE::Stream(storageInp, oleObjectFileStructure.objectID);
|
||||
|
||||
if (oleStorage)
|
||||
{
|
||||
std::string path = "ObjectPool/" + id;
|
||||
std::list<std::string> entries = storageInp->entries(path);
|
||||
for (std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++)
|
||||
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
|
||||
|
||||
std::list<std::wstring> entries = storageInp->entries_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 + "/"+ (*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;
|
||||
|
||||
int size = stream_inp->size();
|
||||
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)
|
||||
{
|
||||
@ -194,12 +203,23 @@ namespace DocFileFormat
|
||||
delete storageOut;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int OpenXmlPackage::RegisterDocument()
|
||||
void OpenXmlPackage::RegisterDocPr()
|
||||
{
|
||||
return AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocument, L"");
|
||||
AddPart( L"docProps", L"app.xml", DocPrContentTypes::App, L"");
|
||||
AddPart( L"docProps", L"core.xml", DocPrContentTypes::Core, L"");
|
||||
}
|
||||
void OpenXmlPackage::RegisterDocument()
|
||||
{
|
||||
AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocument, L"");
|
||||
}
|
||||
void OpenXmlPackage::RegisterDocumentMacros()
|
||||
{
|
||||
AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocumentMacro, L"");
|
||||
}
|
||||
int OpenXmlPackage::RegisterVbaProject()
|
||||
{
|
||||
return AddPart( L"word", L"vbaProject.bin", MicrosoftWordContentTypes::VbaProject, OpenXmlRelationshipTypes::VbaProject );
|
||||
}
|
||||
|
||||
int OpenXmlPackage::RegisterFontTable()
|
||||
{
|
||||
return AddPart( L"word", L"fontTable.xml", WordprocessingMLContentTypes::FontTable, OpenXmlRelationshipTypes::FontTable );
|
||||
|
||||
@ -118,6 +118,8 @@ namespace DocFileFormat
|
||||
|
||||
class OpenXmlPackage
|
||||
{
|
||||
public:
|
||||
const WordDocument* docFile;
|
||||
private:
|
||||
ContentTypesFile DocumentContentTypesFile;
|
||||
RelationshipsFile MainRelationshipsFile;
|
||||
@ -137,8 +139,6 @@ namespace DocFileFormat
|
||||
int _footerCounter;
|
||||
int _oleCounter;
|
||||
|
||||
const WordDocument* docFile;
|
||||
|
||||
int AddHeaderPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
|
||||
int AddFooterPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
|
||||
int AddFootnotesPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
|
||||
@ -165,7 +165,9 @@ namespace DocFileFormat
|
||||
HRESULT SaveOLEObject ( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
|
||||
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
|
||||
|
||||
int RegisterDocument();
|
||||
void RegisterDocPr();
|
||||
void RegisterDocument();
|
||||
void RegisterDocumentMacros();
|
||||
int RegisterFontTable();
|
||||
int RegisterNumbering();
|
||||
int RegisterSettings();
|
||||
@ -179,5 +181,6 @@ namespace DocFileFormat
|
||||
int RegisterOLEObject ( const IMapping* mapping, const std::wstring& objectType );
|
||||
int RegisterPackage ( const IMapping* mapping, const std::wstring& objectType);
|
||||
int RegisterExternalOLEObject( const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri );
|
||||
int RegisterVbaProject();
|
||||
};
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ namespace DocFileFormat
|
||||
|
||||
case sprmPFBiDi:
|
||||
{
|
||||
bool val = iter->argumentsSize > 0 ? iter->Arguments[0] : true;
|
||||
bool val = iter->argumentsSize > 0 ? (iter->Arguments[0] != 0) : true;
|
||||
appendFlagElement( _pPr, *iter, L"bidi", val);
|
||||
_isBidi = val;
|
||||
}break;
|
||||
@ -427,7 +427,7 @@ namespace DocFileFormat
|
||||
if (m_document->listTable)
|
||||
{
|
||||
m_document->listTable->appendNumbering( desc );
|
||||
short numId = m_document->listTable->listNumbering.size();
|
||||
short numId = static_cast<short>(m_document->listTable->listNumbering.size());
|
||||
appendValueElement( &numPr, L"numId", numId, true );
|
||||
}
|
||||
}break;
|
||||
@ -485,7 +485,7 @@ namespace DocFileFormat
|
||||
{
|
||||
XMLTools::XMLElement tabs( L"w:tabs" );
|
||||
|
||||
int pos = 0;
|
||||
unsigned int pos = 0;
|
||||
|
||||
//read the removed tabs
|
||||
unsigned char itbdDelMax = iter->Arguments[pos];
|
||||
|
||||
@ -462,57 +462,60 @@ namespace DocFileFormat
|
||||
|
||||
void PropertiesMapping::appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc )
|
||||
{
|
||||
std::wstring pattern = getShadingPattern( desc );
|
||||
if ( ( parent != NULL ) && ( desc.shadingSpecialValue == shadingSpecialValueNormal ))
|
||||
{
|
||||
XMLTools::XMLElement shd( L"w:shd" );
|
||||
|
||||
//fill color
|
||||
XMLTools::XMLAttribute fill( L"w:fill" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvBackAuto )
|
||||
{
|
||||
fill.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( fill );
|
||||
|
||||
//foreground color
|
||||
XMLTools::XMLAttribute color( L"w:color" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvForeAuto )
|
||||
{
|
||||
color.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( color );
|
||||
|
||||
//pattern
|
||||
XMLTools::XMLAttribute val( L"w:val" );
|
||||
val.SetValue( getShadingPattern( desc ));
|
||||
val.SetValue( pattern);
|
||||
shd.AppendAttribute( val );
|
||||
|
||||
if (pattern != L"nil")
|
||||
{
|
||||
//fill color
|
||||
XMLTools::XMLAttribute fill( L"w:fill" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvBackAuto )
|
||||
{
|
||||
fill.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( fill );
|
||||
|
||||
//foreground color
|
||||
XMLTools::XMLAttribute color( L"w:color" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvForeAuto )
|
||||
{
|
||||
color.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( color );
|
||||
}
|
||||
parent->RemoveChildByName( L"w:shd" );
|
||||
parent->AppendChild( shd );
|
||||
}
|
||||
|
||||
@ -40,19 +40,13 @@ namespace DocFileFormat
|
||||
RELEASEOBJECT( Changes );
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
RevisionData::RevisionData():
|
||||
Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
|
||||
{
|
||||
this->Changes = new std::list<SinglePropertyModifier>();
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
/// Collects the revision data of a CHPX
|
||||
RevisionData::RevisionData( CharacterPropertyExceptions* chpx ):
|
||||
Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
|
||||
RevisionData::RevisionData( CharacterPropertyExceptions* chpx ) : Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
|
||||
{
|
||||
bool collectRevisionData = true;
|
||||
this->Changes = new std::list<SinglePropertyModifier>();
|
||||
|
||||
@ -174,9 +174,9 @@ namespace DocFileFormat
|
||||
//it's a Word 97 SPRM
|
||||
short val = FormatUtils::BytesToInt16(bytes, 0, size);
|
||||
|
||||
icoFore = (val & 0x1F);
|
||||
icoBack = ((val >> 5) & 0x1F);
|
||||
ipat = (ShadingPattern) ((val >> 10) & 0x3F);
|
||||
icoFore = GETBITS(val, 0, 4);
|
||||
icoBack = GETBITS(val, 5, 9);
|
||||
ipat = (ShadingPattern) GETBITS(val, 10, 15);
|
||||
|
||||
shadingType = shadingTypeShd80;
|
||||
|
||||
@ -209,7 +209,7 @@ namespace DocFileFormat
|
||||
else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); }
|
||||
else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); }
|
||||
|
||||
if (0x00 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); cvBackAuto = true; }
|
||||
if (0x00 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); cvBackAuto = true; }
|
||||
else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); }
|
||||
else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); }
|
||||
else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); }
|
||||
|
||||
@ -41,7 +41,7 @@ namespace DocFileFormat
|
||||
{
|
||||
TC80()
|
||||
{
|
||||
horzMerge = wWidth = 0;
|
||||
wWidth = horzMerge =0;
|
||||
|
||||
textFlow = Global::lrTb;
|
||||
vertMerge = Global::fvmClear;
|
||||
@ -95,13 +95,14 @@ namespace DocFileFormat
|
||||
int pointer = 1;
|
||||
|
||||
// rgdxaCenter
|
||||
|
||||
for (int i = 0; i < numberOfColumns + 1; ++i)
|
||||
{
|
||||
rgdxaCenter.push_back(FormatUtils::BytesToInt16(bytes, pointer, size));
|
||||
int pos = FormatUtils::BytesToInt16(bytes, pointer, size);
|
||||
rgdxaCenter.push_back(pos);
|
||||
pointer += 2;
|
||||
}
|
||||
|
||||
|
||||
// rgTc80
|
||||
|
||||
for (int i = 0; i < numberOfColumns; ++i)
|
||||
|
||||
@ -41,6 +41,7 @@ namespace DocFileFormat
|
||||
{
|
||||
template<class T> class StringTable: public IVisitable
|
||||
{
|
||||
friend class WordDocument;
|
||||
friend class CharacterPropertiesMapping;
|
||||
friend class FontTableMapping;
|
||||
friend class StyleSheetMapping;
|
||||
@ -81,7 +82,7 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
ByteStructure* operator [] ( unsigned int index ) const
|
||||
ByteStructure* operator [] ( size_t index ) const
|
||||
{
|
||||
if ( index < this->Data.size() )
|
||||
{
|
||||
|
||||
@ -42,7 +42,6 @@ namespace DocFileFormat
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~StructuredStorageReader()
|
||||
{
|
||||
if(m_pStorage)
|
||||
@ -62,12 +61,18 @@ namespace DocFileFormat
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetStream (const char *path, POLE::Stream** ppStream)
|
||||
bool isDirectory( const std::wstring& name )
|
||||
{
|
||||
if (( m_pStorage != NULL ) && ( path != NULL ))
|
||||
if (!m_pStorage) return false;
|
||||
|
||||
return m_pStorage->isDirectory(name);
|
||||
}
|
||||
|
||||
bool GetStream (const std::wstring & path, POLE::Stream** ppStream)
|
||||
{
|
||||
if (( m_pStorage != NULL ) && ( !path.empty() ))
|
||||
{
|
||||
*ppStream = new POLE::Stream(m_pStorage, path);
|
||||
*ppStream = new POLE::Stream(m_pStorage, path.c_str());
|
||||
}
|
||||
if ((*ppStream) && ((*ppStream)->size() > 0))
|
||||
return true;
|
||||
@ -79,8 +84,78 @@ namespace DocFileFormat
|
||||
{
|
||||
return m_pStorage;
|
||||
}
|
||||
|
||||
void copy( int indent, std::wstring path, POLE::Storage * storageOut, bool withRoot = true)
|
||||
{
|
||||
std::list<std::wstring> entries, entries_sort;
|
||||
entries = m_pStorage->entries_with_prefix( path );
|
||||
|
||||
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it )
|
||||
{
|
||||
std::wstring name = *it;
|
||||
std::wstring fullname = path + name;
|
||||
|
||||
if( m_pStorage->isDirectory( fullname ) )
|
||||
{
|
||||
entries_sort.push_back(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries_sort.push_front(name);
|
||||
}
|
||||
}
|
||||
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); ++it )
|
||||
for( std::list<std::wstring>::iterator it = entries_sort.begin(); it != entries_sort.end(); ++it )
|
||||
{
|
||||
std::wstring name = *it;
|
||||
std::wstring fullname = path + name;
|
||||
|
||||
if( m_pStorage->isDirectory( fullname ) )
|
||||
{
|
||||
copy( indent + 1, fullname + L"/", storageOut, withRoot );
|
||||
}
|
||||
else
|
||||
{
|
||||
copy_stream(fullname, storageOut, withRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void copy_stream(std::wstring streamName, POLE::Storage * storageOut, bool withRoot = true)
|
||||
{
|
||||
POLE::Stream *stream = new POLE::Stream(m_pStorage, streamName);
|
||||
if (!stream) return;
|
||||
|
||||
stream->seek(0);
|
||||
POLE::int64 size_stream = stream->size();
|
||||
|
||||
if (withRoot == false)
|
||||
{
|
||||
int pos = (int)streamName.find(L"/");
|
||||
if (pos >= 0)
|
||||
streamName = streamName.substr(pos + 1);
|
||||
}
|
||||
|
||||
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
|
||||
if (!streamNew) return;
|
||||
|
||||
unsigned char* data_stream = new unsigned char[size_stream];
|
||||
if (data_stream)
|
||||
{
|
||||
stream->read(data_stream, size_stream);
|
||||
|
||||
streamNew->write(data_stream, size_stream);
|
||||
|
||||
delete []data_stream;
|
||||
data_stream = NULL;
|
||||
}
|
||||
|
||||
streamNew->flush();
|
||||
|
||||
delete streamNew;
|
||||
delete stream;
|
||||
}
|
||||
|
||||
POLE::Storage* m_pStorage;
|
||||
};
|
||||
|
||||
@ -35,13 +35,13 @@
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex) :
|
||||
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex) :
|
||||
PropertiesMapping(pWriter)
|
||||
{
|
||||
_width = 0;
|
||||
|
||||
_gridIndex = gridIndex;
|
||||
_grid = tableGrid;
|
||||
_grid = grid;
|
||||
_cellIndex = cellIndex;
|
||||
|
||||
_brcTop = NULL;
|
||||
@ -75,6 +75,8 @@ namespace DocFileFormat
|
||||
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>(visited);
|
||||
int nComputedCellWidth = 0;
|
||||
|
||||
_gridSpan = 1;
|
||||
|
||||
std::list<SinglePropertyModifier>::const_reverse_iterator rend = tapx->grpprl->rend();
|
||||
for (std::list<SinglePropertyModifier>::const_reverse_iterator iter = tapx->grpprl->rbegin(); iter != rend; ++iter)
|
||||
{
|
||||
@ -87,7 +89,7 @@ namespace DocFileFormat
|
||||
int cc = tdef.numberOfColumns;
|
||||
|
||||
_tGrid = tdef.rgdxaCenter;
|
||||
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)]; // NOTE: fix for crash
|
||||
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)];
|
||||
|
||||
appendValueElement( _tcPr, L"textDirection", FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ), false );
|
||||
|
||||
@ -111,13 +113,19 @@ namespace DocFileFormat
|
||||
{
|
||||
appendValueElement( _tcPr, L"noWrap", L"", true );
|
||||
}
|
||||
|
||||
nComputedCellWidth = (short)( tdef.rgdxaCenter[(size_t)(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1) + 1] -
|
||||
tdef.rgdxaCenter[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)] ); // NOTE: fix for crash
|
||||
int ind = (std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1);
|
||||
int ind1 = ind;
|
||||
while (ind1 < tdef.rgdxaCenter.size() - 1)
|
||||
{
|
||||
int sz = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind1 ] ;
|
||||
if (sz > 1)
|
||||
break;
|
||||
ind1++;
|
||||
}
|
||||
nComputedCellWidth = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind ] ;
|
||||
|
||||
if (!IsTableBordersDefined(tapx->grpprl))
|
||||
{ //borders
|
||||
|
||||
{
|
||||
RELEASEOBJECT(_brcTop);
|
||||
_brcTop = new BorderCode(*_tcDef.brcTop);
|
||||
|
||||
@ -134,8 +142,7 @@ namespace DocFileFormat
|
||||
break;
|
||||
|
||||
case sprmTCellPadding:
|
||||
{ //margins
|
||||
|
||||
{
|
||||
unsigned char first = iter->Arguments[0];
|
||||
unsigned char lim = iter->Arguments[1];
|
||||
unsigned char ftsMargin = iter->Arguments[3];
|
||||
@ -165,7 +172,6 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case sprmTDefTableShd80:
|
||||
{
|
||||
if (!tapx->IsSkipShading97()) // если такой операнд единственный то учитываем его, иначе скипаем его
|
||||
@ -270,24 +276,23 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
//width
|
||||
XMLTools::XMLElement tcW ( L"w:tcW" );
|
||||
XMLTools::XMLAttribute tcWType ( L"w:type", FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) );
|
||||
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width ) );
|
||||
XMLTools::XMLElement tcW ( L"w:tcW" );
|
||||
|
||||
|
||||
tcW.AppendAttribute( tcWType );
|
||||
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width > 1 ? _width : nComputedCellWidth) );
|
||||
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) : L"dxa" );
|
||||
|
||||
tcW.AppendAttribute( tcWType );
|
||||
tcW.AppendAttribute( tcWVal );
|
||||
_tcPr->AppendChild( tcW );
|
||||
|
||||
//grid span
|
||||
_gridSpan = 1;
|
||||
|
||||
if ( ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) )
|
||||
{
|
||||
//check the number of merged cells
|
||||
int w = _grid->at( _gridIndex );
|
||||
|
||||
for ( unsigned int i = _gridIndex + 1; i < _grid->size(); i++ )
|
||||
for ( size_t i = _gridIndex + 1; i < _grid->size(); i++ )
|
||||
{
|
||||
_gridSpan++;
|
||||
|
||||
@ -349,7 +354,7 @@ namespace DocFileFormat
|
||||
|
||||
void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex)
|
||||
{
|
||||
if (sprmArg)
|
||||
if (sprmArg && cellIndex >= 0)
|
||||
{
|
||||
//shading descriptor can have 10 bytes (Word 2000) or 2 bytes (Word 97)
|
||||
int shdLength = 2;
|
||||
|
||||
@ -58,7 +58,7 @@ namespace DocFileFormat
|
||||
public:
|
||||
|
||||
virtual ~TableCellPropertiesMapping();
|
||||
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex);
|
||||
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex);
|
||||
virtual void Apply( IVisitable* visited );
|
||||
|
||||
inline int GetGridSpan() const
|
||||
@ -71,9 +71,7 @@ namespace DocFileFormat
|
||||
void apppendCellShading (unsigned char* sprmArg, int size, int cellIndex);
|
||||
bool IsTableBordersDefined (const std::list<SinglePropertyModifier>* grpprl) const;
|
||||
bool IsTableCellWidthDefined (const std::list<SinglePropertyModifier>* grpprl) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int _gridIndex;
|
||||
int _cellIndex;
|
||||
|
||||
@ -93,7 +91,6 @@ namespace DocFileFormat
|
||||
BorderCode* _brcRight;
|
||||
BorderCode* _brcBottom;
|
||||
|
||||
/// The grind span of this cell
|
||||
int _gridSpan;
|
||||
int _gridSpan;
|
||||
};
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ namespace DocFileFormat
|
||||
cellElements.clear();
|
||||
}
|
||||
|
||||
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int nCellIndex)
|
||||
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int nCellIndex)
|
||||
{
|
||||
if (NULL != mapping)
|
||||
{
|
||||
@ -116,14 +116,14 @@ namespace DocFileFormat
|
||||
ParagraphPropertyExceptions* papxBackup = documentMapping->_lastValidPapx;
|
||||
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
|
||||
|
||||
//start w:tc
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
//find cell end
|
||||
//find cell end
|
||||
int cpCellEnd = documentMapping->findCellEndCp(cp, depth);
|
||||
|
||||
//convert the properties
|
||||
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, gridIndex, nCellIndex);
|
||||
//start w:tc
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
//convert the properties
|
||||
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, grid_write, gridIndex, nCellIndex);
|
||||
|
||||
if ( tapx != NULL )
|
||||
{
|
||||
@ -140,7 +140,7 @@ namespace DocFileFormat
|
||||
(*iter)->Convert( mapping );
|
||||
}
|
||||
|
||||
//end w:tc
|
||||
//end w:tc
|
||||
documentMapping->GetXMLWriter()->WriteNodeEnd( L"w:tc" );
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ namespace DocFileFormat
|
||||
cells.clear();
|
||||
}
|
||||
|
||||
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid)
|
||||
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write)
|
||||
{
|
||||
if ( mapping != NULL )
|
||||
{
|
||||
@ -234,7 +234,7 @@ namespace DocFileFormat
|
||||
{
|
||||
for ( std::list<TableCell>::iterator iter = cells.begin(); iter != cells.end(); iter++ )
|
||||
{
|
||||
iter->Convert( mapping, &tapx, grid, gridIndex, nCellIndex++ );
|
||||
iter->Convert( mapping, &tapx, grid, grid_write, gridIndex, nCellIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,7 +516,8 @@ namespace DocFileFormat
|
||||
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
|
||||
|
||||
//build the table grid
|
||||
std::vector<short>* grid = documentMapping->buildTableGrid( cpStart, depth );
|
||||
std::vector<short> grid, grid_write;
|
||||
documentMapping->buildTableGrid( cpStart, depth, grid, grid_write );
|
||||
|
||||
//find first row end
|
||||
int fcRowEnd = documentMapping->findRowEndFc( cpStart, depth );
|
||||
@ -529,7 +530,7 @@ namespace DocFileFormat
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" );
|
||||
|
||||
//Convert it
|
||||
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, grid );
|
||||
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid, &grid_write );
|
||||
|
||||
row1Tapx.Convert( &tpMapping );
|
||||
|
||||
@ -538,13 +539,12 @@ namespace DocFileFormat
|
||||
|
||||
for ( std::list<TableRow>::iterator iter = rows.begin(); iter != rows.end(); iter++ )
|
||||
{
|
||||
iter->Convert( mapping, grid );
|
||||
iter->Convert( mapping, &grid, &grid_write );
|
||||
}
|
||||
|
||||
//close w:tbl
|
||||
documentMapping->GetXMLWriter()->WriteNodeEnd( L"w:tbl" );
|
||||
|
||||
RELEASEOBJECT( grid );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ namespace DocFileFormat
|
||||
void AddItem( const ITableCellElement& _tableCellElement );
|
||||
bool IsEmpty() const;
|
||||
void Clear();
|
||||
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int cellIndex );
|
||||
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int cellIndex );
|
||||
~TableCell();
|
||||
|
||||
private:
|
||||
@ -81,7 +81,7 @@ namespace DocFileFormat
|
||||
void AddCell( const TableCell& _tableCell );
|
||||
bool IsEmpty() const;
|
||||
void Clear();
|
||||
void Convert( IMapping* mapping, const std::vector<short>* grid );
|
||||
void Convert( IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write );
|
||||
~TableRow();
|
||||
|
||||
private:
|
||||
|
||||
@ -34,15 +34,13 @@
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
|
||||
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(NULL),
|
||||
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(NULL),
|
||||
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded ):
|
||||
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid), _grid_write(grid_write),
|
||||
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(styles),
|
||||
_isTableStyleNeeded(isTableStyleNeeded)
|
||||
{
|
||||
_styles = styles;
|
||||
_tblPr = new XMLTools::XMLElement( L"w:tblPr");
|
||||
_tblBorders = new XMLTools::XMLElement( L"w:tblBorders");
|
||||
_grid = grid;
|
||||
}
|
||||
TablePropertiesMapping::~TablePropertiesMapping()
|
||||
{
|
||||
@ -74,6 +72,9 @@ namespace DocFileFormat
|
||||
short marginLeft = 0;
|
||||
short marginRight = 0;
|
||||
|
||||
BYTE itcFirst = 0;
|
||||
BYTE itcLim = 0;
|
||||
|
||||
for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ )
|
||||
{
|
||||
switch( iter->OpCode )
|
||||
@ -120,7 +121,15 @@ namespace DocFileFormat
|
||||
_tblPr->AppendChild( tblW );
|
||||
}
|
||||
break;
|
||||
case sprmTMerge:
|
||||
{
|
||||
itcFirst = iter->Arguments[0];
|
||||
itcLim = iter->Arguments[1];
|
||||
}break;
|
||||
case sprmTSplit:
|
||||
{
|
||||
|
||||
}break;
|
||||
case sprmOldTJc:
|
||||
case sprmTJc:
|
||||
case sprmTJcRow:
|
||||
@ -144,7 +153,7 @@ namespace DocFileFormat
|
||||
|
||||
if ( _isTableStyleNeeded )
|
||||
{
|
||||
int ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
std::wstring id = ind < _styles->Styles->size() ? StyleSheetMapping::MakeStyleId( _styles->Styles->at( ind ) ) : L"";
|
||||
|
||||
@ -486,7 +495,7 @@ namespace DocFileFormat
|
||||
bWriteGridCol = true;
|
||||
else
|
||||
{
|
||||
for ( unsigned int i = 0, nSize = _grid->size(); i < nSize; i++ )
|
||||
for ( size_t i = 0, nSize = _grid_write->size(); i < nSize; i++ )
|
||||
{
|
||||
if(_grid->at(i) % DocFileFormat::gc_nZeroWidth != 0)
|
||||
{
|
||||
@ -497,10 +506,10 @@ namespace DocFileFormat
|
||||
}
|
||||
if(true == bWriteGridCol)
|
||||
{
|
||||
for ( unsigned int i = 0; i < _grid->size(); i++ )
|
||||
for ( size_t i = 0; i < _grid_write->size(); i++ )
|
||||
{
|
||||
XMLTools::XMLElement gridCol( L"w:gridCol");
|
||||
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid->at( i ) ) );
|
||||
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid_write->at( i ) ) );
|
||||
gridCol.AppendAttribute( gridColW );
|
||||
_tblGrid->AppendChild( gridCol );
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ namespace DocFileFormat
|
||||
class TablePropertiesMapping: public PropertiesMapping, public IMapping
|
||||
{
|
||||
public:
|
||||
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded = true );
|
||||
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded = true );
|
||||
virtual ~TablePropertiesMapping();
|
||||
void Apply( IVisitable* visited );
|
||||
|
||||
@ -83,6 +83,7 @@ namespace DocFileFormat
|
||||
|
||||
StyleSheet* _styles;
|
||||
std::vector<short>* _grid;
|
||||
std::vector<short>* _grid_write;
|
||||
|
||||
BorderCode* brcLeft;
|
||||
BorderCode* brcTop;
|
||||
|
||||
@ -62,8 +62,9 @@ namespace DocFileFormat
|
||||
|
||||
for (std::list<SinglePropertyModifier>::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter)
|
||||
{
|
||||
if (oSpmIter->OpCode == sprmTDefTableShd || oSpmIter->OpCode == sprmTDefTableShd2nd ||
|
||||
oSpmIter->OpCode == sprmTDefTableShd2nd || oSpmIter->OpCode == sprmTDefTableShd3rd)
|
||||
if (oSpmIter->OpCode == sprmTDefTableShd ||
|
||||
oSpmIter->OpCode == sprmTDefTableShd2nd ||
|
||||
oSpmIter->OpCode == sprmTDefTableShd3rd)
|
||||
{
|
||||
m_bSkipShading97 = TRUE;
|
||||
}
|
||||
|
||||
@ -156,33 +156,35 @@ namespace DocFileFormat
|
||||
file.CloseFile();
|
||||
|
||||
OOX::CPath path(sTempXmlFile);
|
||||
OOX::CDocument docEmbedded(path, path);
|
||||
OOX::CDocument docEmbedded(NULL, path, path);
|
||||
|
||||
bool res = false;
|
||||
for (int i = 0 ; i < docEmbedded.m_arrItems.size(); i++)
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = docEmbedded.m_arrItems.begin(); it != docEmbedded.m_arrItems.end(); ++it)
|
||||
{
|
||||
if (docEmbedded.m_arrItems[i]->getType() == OOX::et_w_p)
|
||||
if ((*it)->getType() == OOX::et_w_p)
|
||||
{
|
||||
OOX::Logic::CParagraph *paragraph = dynamic_cast<OOX::Logic::CParagraph *>(docEmbedded.m_arrItems[i]);
|
||||
OOX::Logic::CParagraph *paragraph = dynamic_cast<OOX::Logic::CParagraph *>(*it);
|
||||
|
||||
for (int j = 0; (paragraph) && (j < paragraph->m_arrItems.size()); j++)
|
||||
for (std::vector<OOX::WritingElement*>::iterator jt = paragraph->m_arrItems.begin();
|
||||
(paragraph) && (jt != paragraph->m_arrItems.end()); jt++)
|
||||
{
|
||||
if (paragraph->m_arrItems[j]->getType() == OOX::et_m_oMath)
|
||||
if ((*jt)->getType() == OOX::et_m_oMath)
|
||||
{
|
||||
res = true;
|
||||
newXmlString = paragraph->m_arrItems[j]->toXML();
|
||||
newXmlString = (*jt)->toXML();
|
||||
break;
|
||||
}
|
||||
else if (paragraph->m_arrItems[j]->getType() == OOX::et_m_oMathPara)
|
||||
else if ((*jt)->getType() == OOX::et_m_oMathPara)
|
||||
{
|
||||
OOX::Logic::COMathPara *mathPara = dynamic_cast<OOX::Logic::COMathPara *>(paragraph->m_arrItems[j]);
|
||||
OOX::Logic::COMathPara *mathPara = dynamic_cast<OOX::Logic::COMathPara *>(*jt);
|
||||
|
||||
for (int k = 0; (mathPara) && (k < mathPara->m_arrItems.size()); k++)
|
||||
for (std::vector<OOX::WritingElement*>::iterator kt = mathPara->m_arrItems.begin();
|
||||
(mathPara) && (kt != mathPara->m_arrItems.end()); kt++)
|
||||
{
|
||||
if (mathPara->m_arrItems[k]->getType() == OOX::et_m_oMath)
|
||||
if ((*kt)->getType() == OOX::et_m_oMath)
|
||||
{
|
||||
res = true;
|
||||
newXmlString = mathPara->m_arrItems[k]->toXML();
|
||||
newXmlString = (*kt)->toXML();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -265,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++;
|
||||
|
||||
@ -273,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++)
|
||||
@ -421,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))
|
||||
@ -498,6 +502,7 @@ namespace DocFileFormat
|
||||
{
|
||||
case Global::msoblipEMF:
|
||||
case Global::msoblipWMF:
|
||||
case Global::msoblipPICT:
|
||||
{
|
||||
MetafilePictBlip* metaBlip = static_cast<MetafilePictBlip*>(oBlipEntry->Blip);
|
||||
if (metaBlip)
|
||||
@ -565,6 +570,9 @@ namespace DocFileFormat
|
||||
case Global::msoblipWMF:
|
||||
return std::wstring(L".wmf");
|
||||
|
||||
case Global::msoblipPICT:
|
||||
return std::wstring(L".pcz");
|
||||
|
||||
default:
|
||||
return std::wstring(L".png");
|
||||
}
|
||||
@ -599,6 +607,9 @@ namespace DocFileFormat
|
||||
case Global::msoblipWMF:
|
||||
return std::wstring(OpenXmlContentTypes::Wmf);
|
||||
|
||||
case Global::msoblipPICT:
|
||||
return std::wstring(OpenXmlContentTypes::Pcz);
|
||||
|
||||
case Global::msoblipDIB:
|
||||
return std::wstring(OpenXmlContentTypes::Bmp);
|
||||
|
||||
|
||||
@ -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;
|
||||
@ -288,19 +292,20 @@ namespace DocFileFormat
|
||||
int ndyTextBottom = -1;
|
||||
|
||||
bool bHavePath = false;
|
||||
int nShapePath = -1;
|
||||
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];
|
||||
@ -312,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;
|
||||
@ -326,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:
|
||||
@ -334,7 +351,7 @@ namespace DocFileFormat
|
||||
LineStyleBooleanProperties booleans(iter->op);
|
||||
if (booleans.fUsefLine && !booleans.fLine)
|
||||
{
|
||||
stroked = false;
|
||||
bStroked = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -361,6 +378,7 @@ namespace DocFileFormat
|
||||
case shapePath :
|
||||
{
|
||||
bHavePath = true;
|
||||
nShapePath = iter->op;
|
||||
}break;
|
||||
case pVertices:
|
||||
{
|
||||
@ -534,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:
|
||||
{
|
||||
@ -573,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:
|
||||
@ -618,7 +637,8 @@ namespace DocFileFormat
|
||||
}break;
|
||||
case shadowStyleBooleanProperties:
|
||||
{
|
||||
shadowBoolean = ShadowStyleBooleanProperties(iter->op);
|
||||
ShadowStyleBooleanProperties props(iter->op);
|
||||
|
||||
}break;
|
||||
// OLE
|
||||
case pictureId:
|
||||
@ -647,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 );
|
||||
@ -684,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 );
|
||||
@ -744,7 +778,7 @@ namespace DocFileFormat
|
||||
|
||||
text = FormatUtils::XmlEncode(text);
|
||||
|
||||
if (0 <= text.find(L"\n"))
|
||||
if (std::wstring::npos != text.find(L"\n"))
|
||||
{
|
||||
m_textpath.AppendText(text);
|
||||
}
|
||||
@ -754,7 +788,7 @@ namespace DocFileFormat
|
||||
case gtextFont:
|
||||
{
|
||||
std::wstring font = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex.get(), (iter->op)/2);
|
||||
int i = font.size();
|
||||
size_t i = font.size();
|
||||
while (i > 0)
|
||||
{
|
||||
if (font[i-1] != 0) break;
|
||||
@ -829,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" );
|
||||
}
|
||||
@ -925,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
|
||||
@ -1285,6 +1318,7 @@ namespace DocFileFormat
|
||||
{
|
||||
case Global::msoblipEMF:
|
||||
case Global::msoblipWMF:
|
||||
case Global::msoblipPICT:
|
||||
{
|
||||
//it's a meta image
|
||||
MetafilePictBlip* metaBlip = static_cast<MetafilePictBlip*>(RecordFactory::ReadRecord(&reader, 0));
|
||||
@ -1371,6 +1405,9 @@ namespace DocFileFormat
|
||||
case Global::msoblipWMF:
|
||||
return std::wstring( L".wmf" );
|
||||
|
||||
case Global::msoblipPICT:
|
||||
return std::wstring( L".pcz" );
|
||||
|
||||
default:
|
||||
return std::wstring( L".png" );
|
||||
}
|
||||
@ -1653,7 +1690,7 @@ namespace DocFileFormat
|
||||
}
|
||||
if (!bRelV && m_pSpa)
|
||||
{
|
||||
appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->bx));
|
||||
appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->by));
|
||||
}
|
||||
if (!m_isInlineShape && !bZIndex)
|
||||
{
|
||||
@ -1905,13 +1942,13 @@ namespace DocFileFormat
|
||||
switch (pSpa->wr)
|
||||
{
|
||||
case 0:
|
||||
case 2: wrapType = L"square";
|
||||
case 1: wrapType = L"topAndBottom";
|
||||
case 3: wrapType = L"through";
|
||||
case 2: wrapType = L"square"; break;
|
||||
case 1: wrapType = L"topAndBottom"; break;
|
||||
case 3: wrapType = L"through"; break;
|
||||
case 4:
|
||||
case 5: wrapType = L"tight";
|
||||
case 5: wrapType = L"tight"; break;
|
||||
default:
|
||||
wrapType = L"none";
|
||||
wrapType = L"none"; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1963,7 +2000,7 @@ namespace DocFileFormat
|
||||
{
|
||||
int index = (DWORD)val - 0x80000000;
|
||||
|
||||
if (index >= 0 && index < m_arrGuides.size())
|
||||
if (index >= 0 && index < (int)m_arrGuides.size())
|
||||
{
|
||||
new_val = m_arrGuides[index].param3;
|
||||
}
|
||||
@ -2130,7 +2167,7 @@ namespace DocFileFormat
|
||||
|
||||
void VMLShapeMapping::ApplyPrimitives(DrawingPrimitives * primitives)
|
||||
{
|
||||
int index = 0;
|
||||
size_t index = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
@ -2142,7 +2179,7 @@ namespace DocFileFormat
|
||||
|
||||
static int currentTextBoxIndex = 1;
|
||||
|
||||
int VMLShapeMapping::ApplyPrimitive(DrawingPrimitives * primitives, int index)
|
||||
size_t VMLShapeMapping::ApplyPrimitive(DrawingPrimitives * primitives, size_t index)
|
||||
{
|
||||
if (!primitives) return index++;
|
||||
if (index >= primitives->size()) return index++;
|
||||
@ -2241,11 +2278,11 @@ namespace DocFileFormat
|
||||
{
|
||||
//strStyle += L"left:" + FormatUtils::IntToWideString( x.ToPoints()) + L"pt;";
|
||||
//strStyle += L"top:" + FormatUtils::IntToWideString( y.ToPoints()) + L"pt;";
|
||||
strStyle += L"width:" + FormatUtils::IntToWideString( w.ToPoints()) + L"pt;";
|
||||
strStyle += L"height:" + FormatUtils::IntToWideString( h.ToPoints()) + L"pt;";
|
||||
strStyle += L"width:" + FormatUtils::IntToWideString( (int)w.ToPoints()) + L"pt;";
|
||||
strStyle += L"height:" + FormatUtils::IntToWideString( (int)h.ToPoints()) + L"pt;";
|
||||
|
||||
strStyle += L"margin-left:" + FormatUtils::IntToWideString( x.ToPoints()) + L"pt;";
|
||||
strStyle += L"margin-top:" + FormatUtils::IntToWideString( y.ToPoints()) + L"pt;";
|
||||
strStyle += L"margin-left:" + FormatUtils::IntToWideString( (int)x.ToPoints()) + L"pt;";
|
||||
strStyle += L"margin-top:" + FormatUtils::IntToWideString( (int)y.ToPoints()) + L"pt;";
|
||||
|
||||
std::wstring xMargin;
|
||||
std::wstring yMargin;
|
||||
|
||||
@ -73,7 +73,7 @@ namespace DocFileFormat
|
||||
private:
|
||||
|
||||
void ApplyPrimitives (DrawingPrimitives * primitives );
|
||||
int ApplyPrimitive (DrawingPrimitives * primitives, int index);
|
||||
size_t ApplyPrimitive (DrawingPrimitives * primitives, size_t index);
|
||||
|
||||
void WritePrimitiveProps(DrawingPrimitive * primitive, bool root);
|
||||
|
||||
|
||||
@ -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" );
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public:
|
||||
if (position + count > stream->size())
|
||||
{
|
||||
if (position > stream->size()) count = 0;
|
||||
else count = stream->size() - position;
|
||||
else count = (unsigned int)(stream->size() - position);
|
||||
}
|
||||
rdBytes = new unsigned char[count];
|
||||
}
|
||||
@ -152,7 +152,7 @@ public:
|
||||
|
||||
virtual unsigned long GetPosition() const
|
||||
{
|
||||
return this->position;
|
||||
return (unsigned long)this->position;
|
||||
}
|
||||
|
||||
virtual unsigned long GetSize() const
|
||||
@ -161,7 +161,7 @@ public:
|
||||
|
||||
if ( stream != NULL )
|
||||
{
|
||||
size = stream->size();
|
||||
size = (unsigned long)stream->size();
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -246,7 +246,7 @@ public:
|
||||
/// The string must have the following structure:
|
||||
/// unsigned char 1-4: Character count (cch)
|
||||
/// unsigned char 5-cch+4: ANSI characters terminated by \0
|
||||
std::wstring ReadLengthPrefixedAnsiString(int max_size)
|
||||
std::wstring ReadLengthPrefixedAnsiString(unsigned int max_size)
|
||||
{
|
||||
std::wstring result;
|
||||
|
||||
@ -257,8 +257,8 @@ public:
|
||||
if (cch > max_size)
|
||||
{
|
||||
//error ... skip to 0
|
||||
int pos_orinal = GetPosition();
|
||||
int pos = 0;
|
||||
unsigned int pos_orinal = GetPosition();
|
||||
unsigned int pos = 0;
|
||||
|
||||
stringBytes = ReadBytes( max_size, true );
|
||||
|
||||
|
||||
@ -40,8 +40,45 @@
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
static const int aCodePages[][2] = {
|
||||
//charset codepage
|
||||
0, 1252, //ANSI
|
||||
1, 0,//Default
|
||||
2, 42,//Symbol
|
||||
77, 10000,//Mac Roman
|
||||
78, 10001,//Mac Shift Jis
|
||||
79, 10003,//Mac Hangul
|
||||
80, 10008,//Mac GB2312
|
||||
81, 10002,//Mac Big5
|
||||
83, 10005,//Mac Hebrew
|
||||
84, 10004,//Mac Arabic
|
||||
85, 10006,//Mac Greek
|
||||
86, 10081,//Mac Turkish
|
||||
87, 10021,//Mac Thai
|
||||
88, 10029,//Mac East Europe
|
||||
89, 10007,//Mac Russian
|
||||
128, 932,//Shift JIS
|
||||
129, 949,//Hangul
|
||||
130, 1361,//Johab
|
||||
134, 936,//GB2312
|
||||
136, 950,//Big5
|
||||
238, 1250,//Greek
|
||||
161, 1253,//Greek
|
||||
162, 1254,//Turkish
|
||||
163, 1258,//Vietnamese
|
||||
177, 1255,//Hebrew
|
||||
178, 1256, //Arabic
|
||||
186, 1257,//Baltic
|
||||
204, 1251,//Russian
|
||||
222, 874,//Thai
|
||||
238, 1250,//Eastern European
|
||||
254, 437,//PC 437
|
||||
255, 850//OEM
|
||||
};
|
||||
WordDocument::WordDocument (const ProgressCallback* pCallFunc, const std::wstring & sTempFolder ) :
|
||||
m_PieceTable(NULL), WordDocumentStream(NULL), TableStream(NULL), DataStream(NULL), FIB(NULL),
|
||||
Text(NULL), RevisionAuthorTable(NULL), FontTable(NULL), BookmarkNames(NULL), AutoTextNames(NULL),
|
||||
@ -55,12 +92,15 @@ namespace DocFileFormat
|
||||
AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL),
|
||||
AnnotStartPlex(NULL), AnnotEndPlex(NULL), encryptionHeader(NULL)
|
||||
{
|
||||
m_pCallFunc = pCallFunc;
|
||||
m_sTempFolder = sTempFolder;
|
||||
m_pCallFunc = pCallFunc;
|
||||
m_sTempFolder = sTempFolder;
|
||||
|
||||
m_pStorage = NULL;
|
||||
officeArtContent = NULL;
|
||||
bOlderVersion = false;
|
||||
m_pStorage = NULL;
|
||||
officeArtContent = NULL;
|
||||
bOlderVersion = false;
|
||||
|
||||
bDocumentCodePage = false;
|
||||
nDocumentCodePage = ENCODING_WINDOWS_1250;
|
||||
}
|
||||
|
||||
WordDocument::~WordDocument()
|
||||
@ -95,7 +135,7 @@ namespace DocFileFormat
|
||||
return AVS_ERROR_FILEFORMAT;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false)
|
||||
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false)
|
||||
{
|
||||
Clear();
|
||||
return AVS_ERROR_FILEFORMAT;
|
||||
@ -121,24 +161,37 @@ namespace DocFileFormat
|
||||
|
||||
if (FIB->m_FibBase.fWhichTblStm)
|
||||
{
|
||||
if (!m_pStorage->GetStream ("1Table", &TableStream))
|
||||
if (!m_pStorage->GetStream (L"1Table", &TableStream))
|
||||
{
|
||||
res = m_pStorage->GetStream ("0Table", &TableStream);
|
||||
res = m_pStorage->GetStream (L"0Table", &TableStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_pStorage->GetStream ("0Table", &TableStream))
|
||||
if (!m_pStorage->GetStream (L"0Table", &TableStream))
|
||||
{
|
||||
res = m_pStorage->GetStream ("1Table", &TableStream);
|
||||
res = m_pStorage->GetStream (L"1Table", &TableStream);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -152,7 +205,7 @@ namespace DocFileFormat
|
||||
|
||||
if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM;
|
||||
}
|
||||
else
|
||||
else if (encryptionHeader->bAES)
|
||||
{
|
||||
CRYPT::ECMADecryptor Decryptor;
|
||||
|
||||
@ -168,18 +221,15 @@ 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;
|
||||
POLE::Stream * DocSummary = NULL;
|
||||
|
||||
m_pStorage->GetStream ("SummaryInformation", &Summary);
|
||||
m_pStorage->GetStream ("DocumentSummaryInformation", &DocSummary);
|
||||
|
||||
document_code_page = ENCODING_WINDOWS_1250;
|
||||
m_pStorage->GetStream (L"SummaryInformation", &Summary);
|
||||
m_pStorage->GetStream (L"DocumentSummaryInformation", &DocSummary);
|
||||
|
||||
if ((Summary) && (Summary->size() > 0))
|
||||
{
|
||||
@ -188,7 +238,10 @@ namespace DocFileFormat
|
||||
int document_code_page1 = summary_info.GetCodePage(); //from software last open
|
||||
|
||||
if (document_code_page1 > 0)
|
||||
document_code_page = document_code_page1;
|
||||
{
|
||||
nDocumentCodePage = document_code_page1;
|
||||
bDocumentCodePage = true;
|
||||
}
|
||||
}
|
||||
if ((DocSummary) && (DocSummary->size() > 0))
|
||||
{
|
||||
@ -197,16 +250,22 @@ namespace DocFileFormat
|
||||
int document_code_page2 = doc_summary_info.GetCodePage();
|
||||
|
||||
if (document_code_page2 > 0)
|
||||
document_code_page = document_code_page2;
|
||||
{
|
||||
nDocumentCodePage = document_code_page2;
|
||||
bDocumentCodePage = true;
|
||||
}
|
||||
}
|
||||
if (!bOlderVersion)
|
||||
document_code_page = ENCODING_UTF16;
|
||||
{
|
||||
nDocumentCodePage = ENCODING_UTF16;
|
||||
bDocumentCodePage = true;
|
||||
}
|
||||
|
||||
FIB->m_CodePage = document_code_page;
|
||||
FIB->m_CodePage = nDocumentCodePage;
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
try
|
||||
{
|
||||
m_pStorage->GetStream ("Data", &DataStream);
|
||||
m_pStorage->GetStream (L"Data", &DataStream);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -216,7 +275,7 @@ namespace DocFileFormat
|
||||
if (TableStream->size() < 1 && bOlderVersion)
|
||||
{
|
||||
RELEASEOBJECT(TableStream);
|
||||
m_pStorage->GetStream ("WordDocument", &TableStream);
|
||||
m_pStorage->GetStream (L"WordDocument", &TableStream);
|
||||
}
|
||||
|
||||
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
|
||||
@ -353,6 +412,31 @@ namespace DocFileFormat
|
||||
return AVS_ERROR_FILEFORMAT;
|
||||
}
|
||||
}
|
||||
if (!bDocumentCodePage && FontTable)
|
||||
{
|
||||
std::unordered_map<int, int> fonts_charsets;
|
||||
|
||||
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin();!bDocumentCodePage && iter != FontTable->Data.end(); iter++ )
|
||||
{
|
||||
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
|
||||
if (!font) continue;
|
||||
|
||||
if (fonts_charsets.find(font->chs) == fonts_charsets.end())
|
||||
{
|
||||
fonts_charsets.insert(std::make_pair(font->chs, font->ff));
|
||||
|
||||
for (int i = 0 ; i < sizeof(aCodePages) / 2; i++)
|
||||
{
|
||||
if (aCodePages[i][0] == font->chs && font->chs != 0)
|
||||
{
|
||||
nDocumentCodePage = aCodePages[i][1];
|
||||
bDocumentCodePage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FIB->m_FibWord97.lcbClx > 0)
|
||||
{
|
||||
@ -371,7 +455,7 @@ namespace DocFileFormat
|
||||
WordDocumentStream->read (bytes, cb);
|
||||
|
||||
Text = new std::vector<wchar_t>();
|
||||
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, document_code_page);
|
||||
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, nDocumentCodePage);
|
||||
|
||||
RELEASEARRAYOBJECTS(bytes);
|
||||
}
|
||||
@ -483,11 +567,11 @@ namespace DocFileFormat
|
||||
delete storageOut;
|
||||
return false;
|
||||
}
|
||||
DecryptStream( 0, "/", storageIn, storageOut, Decryptor);
|
||||
DecryptStream( 0, L"/", storageIn, storageOut, Decryptor);
|
||||
|
||||
//std::list<std::string> listStream = storageIn->entries();
|
||||
|
||||
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
|
||||
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); ++it)
|
||||
//{
|
||||
// if (storageIn->isDirectory(*it))
|
||||
// {
|
||||
@ -514,48 +598,80 @@ namespace DocFileFormat
|
||||
|
||||
m_pStorage->SetFile(m_sTempDecryptFileName.c_str());
|
||||
|
||||
if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false) return false;
|
||||
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false) return false;
|
||||
|
||||
if (FIB->m_FibBase.fWhichTblStm)
|
||||
{
|
||||
if (!m_pStorage->GetStream ("1Table", &TableStream)) m_pStorage->GetStream ("0Table", &TableStream);
|
||||
if (!m_pStorage->GetStream (L"1Table", &TableStream)) m_pStorage->GetStream (L"0Table", &TableStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_pStorage->GetStream ("0Table", &TableStream)) m_pStorage->GetStream ("1Table", &TableStream);
|
||||
if (!m_pStorage->GetStream (L"0Table", &TableStream)) m_pStorage->GetStream (L"1Table", &TableStream);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void WordDocument::DecryptStream( int level, std::string path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
void WordDocument::DecryptStream( int level, std::wstring path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
{
|
||||
std::list<std::string> entries;
|
||||
entries = storageIn->entries( path );
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for( it = entries.begin(); it != entries.end(); ++it )
|
||||
std::list<std::wstring> entries, entries_files, entries_dir;
|
||||
entries = storageIn->entries_with_prefix( path );
|
||||
|
||||
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it )
|
||||
{
|
||||
std::string name = *it;
|
||||
std::string fullname = path + name;
|
||||
std::wstring name = *it;
|
||||
std::wstring fullname = path + name;
|
||||
|
||||
if( storageIn->isDirectory( fullname ) )
|
||||
{
|
||||
DecryptStream( level + 1, fullname + "/", storageIn, storageOut, Decryptor );
|
||||
entries_dir.push_back(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
DecryptStream(fullname, storageIn, storageOut, Decryptor );
|
||||
entries_files.push_front(name);
|
||||
}
|
||||
}
|
||||
for( std::list<std::wstring>::iterator it = entries_dir.begin(); it != entries_dir.end(); ++it )
|
||||
{
|
||||
std::wstring fullname = path + *it;
|
||||
|
||||
DecryptStream( level + 1, fullname + L"/", storageIn, storageOut, Decryptor );
|
||||
|
||||
}
|
||||
//if (bSortFiles)
|
||||
entries_files.sort();
|
||||
|
||||
for( std::list<std::wstring>::iterator it = entries_files.begin(); it != entries_files.end(); ++it )
|
||||
{
|
||||
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::string 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);
|
||||
int size_stream = stream->size();
|
||||
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];
|
||||
@ -564,24 +680,28 @@ namespace DocFileFormat
|
||||
unsigned char* data_store = NULL;
|
||||
int size_data_store = 0;
|
||||
|
||||
if ( std::wstring::npos != streamName.find("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];
|
||||
}
|
||||
|
||||
if (data_store)
|
||||
memcpy(data_store, data_stream, size_data_store);
|
||||
|
||||
int size_block = 0x200;
|
||||
for (int pos = 0, block = 0 ; pos < size_stream; pos += size_block, block++)
|
||||
size_t size_block = 0x200;
|
||||
unsigned long block = 0;
|
||||
|
||||
for (POLE::uint64 pos = /*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);
|
||||
|
||||
@ -69,7 +69,6 @@ namespace DocFileFormat
|
||||
{
|
||||
class WordDocument: public IVisitable
|
||||
{
|
||||
/*Mapping classes with direct access to the Word Document.*/
|
||||
friend class FootnotesMapping;
|
||||
friend class EndnotesMapping;
|
||||
friend class CommentsMapping;
|
||||
@ -98,19 +97,19 @@ namespace DocFileFormat
|
||||
long LoadDocument (const std::wstring & fileName, const std::wstring & password);
|
||||
|
||||
bool bOlderVersion;
|
||||
int document_code_page;
|
||||
|
||||
private:
|
||||
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
|
||||
|
||||
bool DecryptStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
void DecryptStream (int level, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
int nDocumentCodePage;
|
||||
bool bDocumentCodePage;
|
||||
|
||||
inline StructuredStorageReader* GetStorage() const
|
||||
{
|
||||
return m_pStorage;
|
||||
}
|
||||
|
||||
private:
|
||||
bool DecryptOfficeFile (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 ()
|
||||
{
|
||||
return officeArtContent;
|
||||
|
||||
@ -35,6 +35,10 @@
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/ContentTypes.h"
|
||||
|
||||
namespace ImageHelper
|
||||
{
|
||||
struct __BITMAPINFOHEADER
|
||||
@ -71,7 +75,7 @@ namespace ImageHelper
|
||||
__BITMAPINFOHEADER * header = (__BITMAPINFOHEADER*)data;
|
||||
if (!header) return result;
|
||||
|
||||
result == Global::msoblipDIB;
|
||||
result = Global::msoblipDIB;
|
||||
|
||||
if (header->biWidth > 100000 || header->biHeight > 100000 || header->biSize != 40)
|
||||
{
|
||||
@ -180,10 +184,68 @@ namespace DocFileFormat
|
||||
{
|
||||
}
|
||||
|
||||
void WordprocessingDocument::SaveDocument()
|
||||
void WordprocessingDocument::SaveDocument(bool &bMacros)
|
||||
{
|
||||
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ;
|
||||
NSDirectory::CreateDirectory( pathWord );
|
||||
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ;
|
||||
NSDirectory::CreateDirectory( pathWord );
|
||||
|
||||
if (bMacros && docFile->GetStorage()->isDirectory(L"Macros"))
|
||||
{
|
||||
std::wstring sVbaProjectFile = pathWord + FILE_SEPARATOR_STR + L"vbaProject.bin";
|
||||
|
||||
POLE::Storage *storageVbaProject = new POLE::Storage(sVbaProjectFile.c_str());
|
||||
|
||||
if ((storageVbaProject) && (storageVbaProject->open(true, true)))
|
||||
{
|
||||
docFile->GetStorage()->copy(0, L"Macros/", storageVbaProject, false);
|
||||
|
||||
storageVbaProject->close();
|
||||
delete storageVbaProject;
|
||||
|
||||
RegisterDocumentMacros();
|
||||
RegisterVbaProject();
|
||||
//output_document->get_xl_files().add_vba_project();
|
||||
}
|
||||
else bMacros = false;
|
||||
}
|
||||
else
|
||||
bMacros = false;
|
||||
|
||||
if (!bMacros)
|
||||
{
|
||||
RegisterDocument();
|
||||
}
|
||||
OOX::CContentTypes oContentTypes;
|
||||
OOX::CPath pathDocProps = m_strOutputPath + FILE_SEPARATOR_STR + _T("docProps");
|
||||
NSDirectory::CreateDirectory(pathDocProps.GetPath());
|
||||
|
||||
OOX::CPath DocProps = std::wstring(_T("docProps"));
|
||||
|
||||
OOX::CApp* pApp = new OOX::CApp(NULL);
|
||||
if (pApp)
|
||||
{
|
||||
pApp->SetApplication(L"ONLYOFFICE");
|
||||
#if defined(INTVER)
|
||||
pApp->SetAppVersion(VALUE2STR(INTVER));
|
||||
#endif
|
||||
pApp->SetDocSecurity(0);
|
||||
pApp->SetScaleCrop(false);
|
||||
pApp->SetLinksUpToDate(false);
|
||||
pApp->SetSharedDoc(false);
|
||||
pApp->SetHyperlinksChanged(false);
|
||||
|
||||
pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, oContentTypes);
|
||||
delete pApp;
|
||||
}
|
||||
OOX::CCore* pCore = new OOX::CCore(NULL);
|
||||
if (pCore)
|
||||
{
|
||||
pCore->SetCreator(_T(""));
|
||||
pCore->SetLastModifiedBy(_T(""));
|
||||
pCore->write(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"), DocProps, oContentTypes);
|
||||
delete pCore;
|
||||
}
|
||||
RegisterDocPr();
|
||||
|
||||
WritePackage();
|
||||
|
||||
|
||||
@ -76,6 +76,7 @@ namespace DocFileFormat
|
||||
public:
|
||||
WordprocessingDocument(const std::wstring & _docxDirectory, const WordDocument* _docFile);
|
||||
virtual ~WordprocessingDocument();
|
||||
void SaveDocument();
|
||||
|
||||
void SaveDocument(bool &bMacros);
|
||||
};
|
||||
}
|
||||
@ -34,14 +34,14 @@
|
||||
#include "../DocDocxConverter/Converter.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, ProgressCallback *ffCallBack )
|
||||
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
|
||||
{
|
||||
HRESULT hr = S_FALSE;
|
||||
|
||||
DocFileFormat::Converter docToDocx;
|
||||
docToDocx.m_sTempFolder = m_sTempFolder;
|
||||
|
||||
hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack);
|
||||
hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack, bMacros);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public:
|
||||
|
||||
std::wstring m_sTempFolder;
|
||||
|
||||
HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, ProgressCallback *ffCallBack = NULL);
|
||||
HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack = NULL);
|
||||
HRESULT SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack = NULL);
|
||||
|
||||
};
|
||||
|
||||
@ -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 \
|
||||
@ -94,6 +92,7 @@ SOURCES += \
|
||||
../../DocDocxConverter/VMLShapeTypeMapping.cpp \
|
||||
../../DocDocxConverter/WordDocument.cpp \
|
||||
../../DocDocxConverter/WordprocessingDocument.cpp \
|
||||
../../DocDocxConverter/FormFieldData.cpp \
|
||||
../../DocDocxConverter/OfficeDrawing/Record.cpp \
|
||||
../../DocDocxConverter/OfficeDrawing/RecordFactory.cpp \
|
||||
../../DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp
|
||||
@ -236,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 \
|
||||
|
||||
@ -74,6 +74,7 @@
|
||||
#include "../../DocDocxConverter/VMLShapeTypeMapping.cpp"
|
||||
#include "../../DocDocxConverter/WordDocument.cpp"
|
||||
#include "../../DocDocxConverter/WordprocessingDocument.cpp"
|
||||
#include "../../DocDocxConverter/FormFieldData.cpp"
|
||||
#include "../../DocDocxConverter/OfficeDrawing/Record.cpp"
|
||||
#include "../../DocDocxConverter/OfficeDrawing/RecordFactory.cpp"
|
||||
#include "../../DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp"
|
||||
|
||||
@ -47,11 +47,12 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4005;4311;4312"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
@ -479,6 +480,14 @@
|
||||
RelativePath="..\..\DocDocxConverter\FormattedDiskPagePAPX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\FormFieldData.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\FormFieldData.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\Global.h"
|
||||
>
|
||||
@ -886,6 +895,10 @@
|
||||
RelativePath="..\..\DocDocxConverter\OfficeDrawing\SplitMenuColorContainer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\OfficeDrawing\threeDBooleanProperties.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\OfficeDrawing\UnknownRecord.h"
|
||||
>
|
||||
@ -1090,6 +1103,10 @@
|
||||
RelativePath="..\..\DocDocxConverter\FootnotesMapping.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\FormFieldDataMapping.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\HeaderMapping.cpp"
|
||||
>
|
||||
|
||||
@ -29,19 +29,17 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
// DocFormatTest.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
#include "../DocFormatLib/DocFormatLib.h"
|
||||
|
||||
#include "../../OfficeUtils/src/ASCOfficeCriticalSection.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "../../Common/DocxFormat/Source/Base/Base.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../DocFormatLib/DocFormatLib.h"
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#pragma comment(lib,"Shell32.lib")
|
||||
#pragma comment(lib,"Advapi32.lib")
|
||||
#pragma comment(lib,"Rpcrt4.lib")
|
||||
|
||||
#if defined(_WIN64)
|
||||
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
|
||||
@ -49,26 +47,34 @@
|
||||
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
|
||||
#endif
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
HRESULT convert_single(std::wstring srcFileName)
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
std::wstring sSrcDoc = argv[1];
|
||||
std::wstring sDstDocx = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx";
|
||||
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(sDstDocx);
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(srcFileName);
|
||||
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
std::wstring dstPath;
|
||||
|
||||
COfficeDocFile docFile;
|
||||
|
||||
docFile.m_sTempFolder = outputDir;
|
||||
|
||||
HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", NULL);
|
||||
bool bMacros = true;
|
||||
HRESULT hRes = docFile.LoadFromFile( srcFileName, dstTempPath, L"password", bMacros, NULL);
|
||||
|
||||
if (bMacros)
|
||||
{
|
||||
dstPath = srcFileName + L"-my.docm";
|
||||
}
|
||||
else
|
||||
{
|
||||
dstPath = srcFileName + L"-my.docx";
|
||||
|
||||
}
|
||||
if (hRes == S_OK)
|
||||
{
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), sDstDocx, -1);
|
||||
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath, -1);
|
||||
}
|
||||
|
||||
NSDirectory::DeleteDirectory(dstTempPath);
|
||||
@ -76,3 +82,33 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
return hRes;
|
||||
}
|
||||
|
||||
|
||||
HRESULT convert_directory(std::wstring pathName)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
|
||||
|
||||
for (size_t i = 0; i < arFiles.size(); i++)
|
||||
{
|
||||
convert_single(arFiles[i]);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
HRESULT hr = -1;
|
||||
if (NSFile::CFileBinary::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_single(argv[1]);
|
||||
}
|
||||
else if (NSDirectory::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_directory(argv[1]);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
@ -48,7 +48,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
@ -67,7 +67,7 @@
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Urlmon.lib"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="LIBCMT.lib"
|
||||
IgnoreDefaultLibraryNames=""
|
||||
IgnoreEmbeddedIDL="true"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
@ -392,6 +392,14 @@
|
||||
<File
|
||||
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/bigobj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
@ -442,6 +450,10 @@
|
||||
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
|
||||
>
|
||||
|
||||
@ -55,7 +55,9 @@ namespace Writers
|
||||
oFile.CreateFileW(filePath.GetPath());
|
||||
oFile.WriteStringUTF8( std::wstring(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
|
||||
oFile.WriteStringUTF8( std::wstring(_T("<w:document \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
|
||||
@ -60,16 +60,50 @@ namespace Writers
|
||||
std::wstring rId;
|
||||
SimpleTypes::EHdrFtr eType;
|
||||
};
|
||||
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:hdr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<w:hdr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_hdr_End = _T("</w:hdr>");
|
||||
|
||||
static std::wstring g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:ftr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<w:ftr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_ftr_End = _T("</w:ftr>");
|
||||
|
||||
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_footnotes_End = _T("</w:footnotes>");
|
||||
|
||||
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_endnotes_End = _T("</w:endnotes>");
|
||||
|
||||
class HeaderFooterWriter
|
||||
|
||||
@ -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())
|
||||
@ -355,10 +364,13 @@ class Tab
|
||||
public:
|
||||
BYTE Val;
|
||||
double Pos;
|
||||
BYTE Leader;
|
||||
bool bLeader;
|
||||
Tab()
|
||||
{
|
||||
Val = shd_Nil;
|
||||
Pos = 0;
|
||||
bLeader = false;
|
||||
}
|
||||
};
|
||||
class Tabs
|
||||
@ -369,7 +381,7 @@ public:
|
||||
class rPr
|
||||
{
|
||||
private:
|
||||
std::map<std::wstring, int>& m_mapFonts;
|
||||
boost::unordered_map<std::wstring, int>& m_mapFonts;
|
||||
public:
|
||||
bool Bold;
|
||||
bool Italic;
|
||||
@ -442,7 +454,7 @@ public:
|
||||
|
||||
bool bDoNotWriteNullProp;
|
||||
public:
|
||||
rPr(std::map<std::wstring, int>& mapFonts) : m_mapFonts(mapFonts)
|
||||
rPr(boost::unordered_map<std::wstring, int>& mapFonts) : m_mapFonts(mapFonts)
|
||||
{
|
||||
Reset();
|
||||
|
||||
@ -1697,7 +1709,7 @@ public:
|
||||
std::vector<std::wstring> arSplit;
|
||||
boost::algorithm::split(arSplit, pComment->UserName, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
for (int i = 0; i < arSplit.size(); i++)
|
||||
for (size_t i = 0; i < arSplit.size(); i++)
|
||||
{
|
||||
sInitials += arSplit[i][0];
|
||||
}
|
||||
@ -1733,7 +1745,7 @@ public:
|
||||
|
||||
bool bFirst = true;
|
||||
int nPrevIndex = 0;
|
||||
for(size_t i = 0; i < sText.length(); i++)
|
||||
for (int i = 0; i < (int)sText.length(); i++)
|
||||
{
|
||||
wchar_t cToken = sText[i];
|
||||
if('\n' == cToken)
|
||||
@ -1784,8 +1796,8 @@ w15:paraIdParent=\"" + pComment->m_sParaIdParent + L"\" w15:done=\"" + sDone + L
|
||||
};
|
||||
class CComments
|
||||
{
|
||||
std::map<int, CComment*> m_mapComments;
|
||||
std::map<std::wstring, CComment*> m_mapAuthors;
|
||||
boost::unordered_map<int, CComment*> m_mapComments;
|
||||
boost::unordered_map<std::wstring, CComment*> m_mapAuthors;
|
||||
public:
|
||||
IdCounter m_oFormatIdCounter;
|
||||
IdCounter m_oParaIdCounter;
|
||||
@ -1795,7 +1807,7 @@ public:
|
||||
}
|
||||
~CComments()
|
||||
{
|
||||
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
@ -1819,7 +1831,7 @@ public:
|
||||
CComment* get(int nInd)
|
||||
{
|
||||
CComment* pRes = NULL;
|
||||
std::map<int, CComment*>::const_iterator pair = m_mapComments.find(nInd);
|
||||
boost::unordered_map<int, CComment*>::const_iterator pair = m_mapComments.find(nInd);
|
||||
if(m_mapComments.end() != pair)
|
||||
pRes = pair->second;
|
||||
return pRes;
|
||||
@ -1831,7 +1843,7 @@ public:
|
||||
std::wstring writeContent()
|
||||
{
|
||||
std::wstring sRes;
|
||||
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sRes += (it->second->writeTemplates(CComment::writeContent));
|
||||
}
|
||||
@ -1840,7 +1852,7 @@ public:
|
||||
std::wstring writeContentExt()
|
||||
{
|
||||
std::wstring sRes;
|
||||
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sRes += (it->second->writeTemplates(CComment::writeContentExt));
|
||||
}
|
||||
@ -1849,7 +1861,7 @@ public:
|
||||
std::wstring writePeople()
|
||||
{
|
||||
std::wstring sRes;
|
||||
for (std::map<std::wstring, CComment*>::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it)
|
||||
for (boost::unordered_map<std::wstring, CComment*>::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it)
|
||||
{
|
||||
sRes += (it->second->writePeople(it->second));
|
||||
}
|
||||
@ -2337,7 +2349,7 @@ public:
|
||||
{
|
||||
return Jc.empty() && TableInd.empty() && TableW.empty() && TableCellMar.empty() && TableBorders.empty() && Shd.empty() && tblpPr.empty()&& Style.empty() && Look.empty() && tblPrChange.empty() && TableCellSpacing.empty() && RowBandSize.empty() && ColBandSize.empty();
|
||||
}
|
||||
std::wstring Write(bool bBandSize, bool bLayout)
|
||||
std::wstring Write()
|
||||
{
|
||||
std::wstring sRes;
|
||||
sRes += L"<w:tblPr>";
|
||||
@ -2361,13 +2373,8 @@ public:
|
||||
sRes += (TableBorders);
|
||||
if(false == Shd.empty())
|
||||
sRes += (Shd);
|
||||
if(bLayout)
|
||||
{
|
||||
if(false == Layout.empty())
|
||||
sRes += (Layout);
|
||||
else if(g_nCurFormatVersion < 4)
|
||||
sRes += L"<w:tblLayout w:type=\"fixed\"/>";
|
||||
}
|
||||
if(false == Layout.empty())
|
||||
sRes += (Layout);
|
||||
if(false == TableCellMar.empty())
|
||||
sRes += (TableCellMar);
|
||||
if(false == Look.empty())
|
||||
@ -2755,7 +2762,7 @@ public:
|
||||
}
|
||||
if(NULL != tblPr)
|
||||
{
|
||||
pCStringWriter->WriteString(tblPr->Write(false, true));
|
||||
pCStringWriter->WriteString(tblPr->Write());
|
||||
}
|
||||
if(NULL != tblGridChange)
|
||||
{
|
||||
|
||||
@ -36,7 +36,7 @@ namespace BinDocxRW {
|
||||
|
||||
int Binary_VbaProjectTableReader::Read()
|
||||
{
|
||||
m_oFileWriter.m_pVbaProject = new OOX::VbaProject();
|
||||
m_oFileWriter.m_pVbaProject = new OOX::VbaProject(NULL);
|
||||
m_oFileWriter.m_pVbaProject->fromPPTY(&m_oBufferedStream);
|
||||
|
||||
return c_oSerConstants::ReadOk;
|
||||
|
||||
@ -37,7 +37,17 @@
|
||||
|
||||
#include "../BinWriter/BinReaderWriterDefines.h"
|
||||
#include "../../XlsxSerializerCom/Writer/BinaryReader.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Document.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/FontTable.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Numbering.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Comments.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Styles.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Footnote.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Endnote.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Settings/Settings.h"
|
||||
|
||||
#include "../DocWrapper/XlsxSerializer.h"
|
||||
|
||||
#include "../../DesktopEditor/common/ASCVariant.h"
|
||||
@ -61,6 +71,13 @@ enum ETblStyleOverrideType
|
||||
tblstyleoverridetypeSwCell = 11,
|
||||
tblstyleoverridetypeWholeTable = 12
|
||||
};
|
||||
|
||||
struct RowHeight
|
||||
{
|
||||
unsigned char HRule = 0;
|
||||
long nHeight = 0;
|
||||
};
|
||||
|
||||
class SdtWraper
|
||||
{
|
||||
public:
|
||||
@ -249,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();
|
||||
@ -434,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:
|
||||
@ -784,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:
|
||||
@ -827,7 +836,23 @@ public:
|
||||
case g_tabtype_clear: sVal = L"clear"; break;
|
||||
default: sVal = L"left"; break;
|
||||
}
|
||||
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"/>");
|
||||
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"");
|
||||
if (oTab.bLeader)
|
||||
{
|
||||
std::wstring sLeader;
|
||||
switch(oTab.Leader)
|
||||
{
|
||||
case SimpleTypes::tabtlcDot : sLeader = (L"dot");break;
|
||||
case SimpleTypes::tabtlcHeavy : sLeader = (L"heavy");break;
|
||||
case SimpleTypes::tabtlcHyphen : sLeader = (L"hyphen");break;
|
||||
case SimpleTypes::tabtlcMiddleDot : sLeader = (L"middleDot");break;
|
||||
case SimpleTypes::tabtlcNone : sLeader = (L"none");break;
|
||||
case SimpleTypes::tabtlcUnderscore : sLeader = (L"underscore");break;
|
||||
default : sLeader = (L"none");break;
|
||||
}
|
||||
pCStringWriter->WriteString(L" w:leader=\"" + sLeader + L"\"");
|
||||
}
|
||||
pCStringWriter->WriteString(L"/>");
|
||||
}
|
||||
pCStringWriter->WriteString(std::wstring(L"</w:tabs>"));
|
||||
}
|
||||
@ -885,6 +910,11 @@ public:
|
||||
pCStringWriter->WriteString(oSectPr.Write());
|
||||
pCStringWriter->WriteString(std::wstring(_T("</w:sectPr>")));
|
||||
}break;
|
||||
case c_oSerProp_pPrType::outlineLvl:
|
||||
{
|
||||
long outlineLvl = m_oBufferedStream.GetLong();
|
||||
pCStringWriter->WriteString(L"<w:outlineLvl w:val=\"" + std::to_wstring(outlineLvl) + L"\"/>");
|
||||
}break;
|
||||
default:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
break;
|
||||
@ -1003,6 +1033,11 @@ public:
|
||||
poTabItem->Val = m_oBufferedStream.GetUChar();
|
||||
else if(c_oSerProp_pPrType::Tab_Item_Pos == type)
|
||||
poTabItem->Pos = m_oBufferedStream.GetDouble();
|
||||
else if(c_oSerProp_pPrType::Tab_Item_Leader == type)
|
||||
{
|
||||
poTabItem->bLeader = true;
|
||||
poTabItem->Leader = m_oBufferedStream.GetUChar();
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -1739,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 )
|
||||
{
|
||||
@ -2085,7 +2117,17 @@ public:
|
||||
}
|
||||
else if( c_oSerProp_rowPrType::Height == type )
|
||||
{
|
||||
res = Read2(length, &Binary_tblPrReader::ReadHeight, this, poResult);
|
||||
RowHeight val;
|
||||
res = Read2(length, &Binary_tblPrReader::ReadHeight, this, &val);
|
||||
|
||||
pCStringWriter->WriteString(L"<w:trHeight w:val=\"" + std::to_wstring(val.nHeight) + L"\"");
|
||||
|
||||
switch (val.HRule)
|
||||
{
|
||||
case 1: pCStringWriter->WriteString(L" w:hRule=\"auto\""); break;
|
||||
case 2: pCStringWriter->WriteString(L" w:hRule=\"exact\""); break;
|
||||
}
|
||||
pCStringWriter->WriteString(L"/>");
|
||||
}
|
||||
else if( c_oSerProp_rowPrType::TableHeader == type )
|
||||
{
|
||||
@ -2154,17 +2196,17 @@ public:
|
||||
int ReadHeight(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
XmlUtils::CStringWriter* pCStringWriter = static_cast<XmlUtils::CStringWriter*>(poResult);
|
||||
/*if( c_oSerProp_rowPrType::Height_Rule == type )
|
||||
|
||||
RowHeight* pHeight = static_cast<RowHeight*>(poResult);
|
||||
|
||||
if( c_oSerProp_rowPrType::Height_Rule == type )
|
||||
{
|
||||
Height.HRule = this.stream.GetUChar();
|
||||
pHeight->HRule = m_oBufferedStream.GetUChar();
|
||||
}
|
||||
else */if( c_oSerProp_rowPrType::Height_Value == type )
|
||||
else if( c_oSerProp_rowPrType::Height_Value == type )
|
||||
{
|
||||
double dHeight = m_oBufferedStream.GetDouble();
|
||||
long nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
|
||||
|
||||
pCStringWriter->WriteString(L"<w:trHeight w:val=\"" + std::to_wstring(nHeight) + L"\"/>");
|
||||
pHeight->nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
@ -2191,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 )
|
||||
{
|
||||
@ -2800,7 +2839,7 @@ public:
|
||||
{
|
||||
CWiterTblPr oWiterTblPr;
|
||||
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
|
||||
odocStyle->TablePr = oWiterTblPr.Write(true, false);
|
||||
odocStyle->TablePr = oWiterTblPr.Write();
|
||||
}
|
||||
else if(c_oSer_sts::Style_RowPr == type)
|
||||
{
|
||||
@ -2896,7 +2935,7 @@ public:
|
||||
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
|
||||
|
||||
if(false == oWiterTblPr.IsEmpty())
|
||||
ptblStylePr->Writer.WriteString(oWiterTblPr.Write(false, false));
|
||||
ptblStylePr->Writer.WriteString(oWiterTblPr.Write());
|
||||
}
|
||||
else if(c_oSerProp_tblStylePrType::TrPr == type)
|
||||
{
|
||||
@ -2938,7 +2977,7 @@ public:
|
||||
int Read()
|
||||
{
|
||||
return ReadTable(&Binary_OtherTableReader::ReadOtherContent, this);
|
||||
};
|
||||
}
|
||||
int ReadOtherContent(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
@ -2948,7 +2987,7 @@ public:
|
||||
}
|
||||
else if(c_oSerOtherTableTypes::DocxTheme == type)
|
||||
{
|
||||
smart_ptr<PPTX::Theme> pTheme = new PPTX::Theme();
|
||||
smart_ptr<PPTX::Theme> pTheme = new PPTX::Theme(NULL);
|
||||
pTheme->fromPPTY(&m_oBufferedStream);
|
||||
NSBinPptxRW::CXmlWriter xmlWriter;
|
||||
pTheme->toXmlWriter(&xmlWriter);
|
||||
@ -2957,7 +2996,7 @@ public:
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
}
|
||||
int ReadImageMapContent(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
@ -3000,7 +3039,7 @@ public:
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
}
|
||||
};
|
||||
class Binary_CommentsTableReader : public Binary_CommonReader<Binary_CommentsTableReader>
|
||||
{
|
||||
@ -3708,6 +3747,33 @@ public:
|
||||
res = Read2(length, &Binary_DocumentTableReader::Read_Background, this, &oBackground);
|
||||
m_oDocumentWriter.m_oBackground.WriteString(oBackground.Write());
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkStart == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkEnd == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else if(c_oSerParType::JsaProject == type)
|
||||
{
|
||||
BYTE* pData = m_oBufferedStream.GetPointer(length);
|
||||
OOX::CPath sJsaProject = OOX::FileTypes::JsaProject.DefaultFileName();
|
||||
std::wstring filePath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word"+ FILE_SEPARATOR_STR + sJsaProject.GetPath();
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(filePath);
|
||||
oFile.WriteFile(pData, length);
|
||||
oFile.CloseFile();
|
||||
|
||||
long lId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::JsaProject.RelationType(), sJsaProject.GetPath(), L"", &lId);
|
||||
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(sJsaProject.GetExtention(false));
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -3846,6 +3912,18 @@ public:
|
||||
SdtWraper oSdt(1);
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkStart == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkEnd == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -4003,6 +4081,19 @@ public:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadFldChar(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Logic::CFldChar* pFldChar = static_cast<OOX::Logic::CFldChar*>(poResult);
|
||||
if ( c_oSer_FldSimpleType::CharType == type )
|
||||
{
|
||||
pFldChar->m_oFldCharType.Init();
|
||||
pFldChar->m_oFldCharType->SetValue((SimpleTypes::EFldCharType)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadFldSimple(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
@ -4228,6 +4319,57 @@ public:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadBookmarkStart(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(poResult);
|
||||
if ( c_oSerBookmark::Id == type )
|
||||
{
|
||||
pBookmarkStart->m_oId.Init();
|
||||
pBookmarkStart->m_oId->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else if ( c_oSerBookmark::Name == type )
|
||||
{
|
||||
pBookmarkStart->m_sName.Init();
|
||||
pBookmarkStart->m_sName->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
|
||||
{
|
||||
pBookmarkStart->m_oDisplacedByCustomXml.Init();
|
||||
pBookmarkStart->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else if ( c_oSerBookmark::ColFirst == type )
|
||||
{
|
||||
pBookmarkStart->m_oColFirst.Init();
|
||||
pBookmarkStart->m_oColFirst->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else if ( c_oSerBookmark::ColLast == type )
|
||||
{
|
||||
pBookmarkStart->m_oColLast.Init();
|
||||
pBookmarkStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadBookmarkEnd(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(poResult);
|
||||
if ( c_oSerBookmark::Id == type )
|
||||
{
|
||||
pBookmarkEnd->m_oId.Init();
|
||||
pBookmarkEnd->m_oId->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
|
||||
{
|
||||
pBookmarkEnd->m_oDisplacedByCustomXml.Init();
|
||||
pBookmarkEnd->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
|
||||
int ReadHyperlink(BYTE type, long length, void* poResult)
|
||||
{
|
||||
@ -4421,6 +4563,18 @@ public:
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadMathSSup, this, poResult);
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("</m:sSup>")));
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::BookmarkStart == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
GetRunStringWriter().WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::BookmarkEnd == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
GetRunStringWriter().WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -6629,7 +6783,7 @@ public:
|
||||
//сбрасываем Shd
|
||||
oBinary_tblPrReader.m_sCurTableShd.clear();
|
||||
}
|
||||
else if(c_oSerRunType::fldstart == type)
|
||||
else if(c_oSerRunType::fldstart_deprecated == type)
|
||||
{
|
||||
std::wstring sField(m_oBufferedStream.GetString3(length));
|
||||
sField = XmlUtils::EncodeXmlString(sField);
|
||||
@ -6643,7 +6797,7 @@ public:
|
||||
m_oCur_rPr.Write(&GetRunStringWriter());
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:fldChar w:fldCharType=\"separate\"/>")));
|
||||
}
|
||||
else if(c_oSerRunType::fldend == type)
|
||||
else if(c_oSerRunType::fldend_deprecated == type)
|
||||
{
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:fldChar w:fldCharType=\"end\"/>")));
|
||||
}
|
||||
@ -6692,6 +6846,28 @@ public:
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadEndnoteRef, this, &oEndnoteRef);
|
||||
GetRunStringWriter().WriteString(oEndnoteRef.toXML());
|
||||
}
|
||||
else if ( c_oSerRunType::fldChar == type)
|
||||
{
|
||||
OOX::Logic::CFldChar oFldChar;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadFldChar, this, &oFldChar);
|
||||
GetRunStringWriter().WriteString(oFldChar.toXML());
|
||||
}
|
||||
else if ( c_oSerRunType::instrText == type)
|
||||
{
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:instrText xml:space=\"preserve\">")));
|
||||
std::wstring sText(m_oBufferedStream.GetString3(length));
|
||||
sText = XmlUtils::EncodeXmlString(sText);
|
||||
GetRunStringWriter().WriteString(sText);
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("</w:instrText>")));
|
||||
}
|
||||
else if ( c_oSerRunType::delInstrText == type)
|
||||
{
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:delInstrText xml:space=\"preserve\">")));
|
||||
std::wstring sText(m_oBufferedStream.GetString3(length));
|
||||
sText = XmlUtils::EncodeXmlString(sText);
|
||||
GetRunStringWriter().WriteString(sText);
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("</w:delInstrText>")));
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -6790,7 +6966,7 @@ public:
|
||||
{
|
||||
CWiterTblPr oWiterTblPr;
|
||||
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
|
||||
pCStringWriter->WriteString(oWiterTblPr.Write(false, true));
|
||||
pCStringWriter->WriteString(oWiterTblPr.Write());
|
||||
}
|
||||
else if( c_oSerDocTableType::tblGrid == type )
|
||||
{
|
||||
@ -6862,6 +7038,18 @@ public:
|
||||
SdtWraper oSdt(2);
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkStart == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
pCStringWriter->WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkEnd == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
pCStringWriter->WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -6899,6 +7087,18 @@ public:
|
||||
SdtWraper oSdt(3);
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkStart == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
pCStringWriter->WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkEnd == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
pCStringWriter->WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -7054,7 +7254,7 @@ public:
|
||||
BinXlsxRW::SaveParams oSaveParams(m_oFileWriter.m_sThemePath, m_oFileWriter.m_pDrawingConverter->GetContentTypes());
|
||||
BinXlsxRW::BinaryChartReader oBinaryChartReader(m_oBufferedStream, oSaveParams, m_oFileWriter.m_pDrawingConverter);
|
||||
|
||||
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace();
|
||||
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace(NULL);
|
||||
oBinaryChartReader.ReadCT_ChartSpace(length, &pChartSpace->m_oChartSpace);
|
||||
|
||||
//save xlsx
|
||||
@ -7064,21 +7264,22 @@ public:
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(nChartIndex) + L".xlsx";
|
||||
std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename;
|
||||
BinXlsxRW::CXlsxSerializer oXlsxSerializer;
|
||||
oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace);
|
||||
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
|
||||
{
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rIdXlsx;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rIdXlsx;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
|
||||
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
|
||||
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
|
||||
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
|
||||
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
}
|
||||
|
||||
//save chart.xml
|
||||
NSStringUtils::CStringBuilder sw;
|
||||
@ -7234,6 +7435,8 @@ public:
|
||||
{
|
||||
PPTX::Logic::CNvPr pNonVisualDrawingProps(L"wp");
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadDocPr, this, &pNonVisualDrawingProps);
|
||||
|
||||
pNonVisualDrawingProps.id = pDrawingProperty->m_nDocPr;
|
||||
pDrawingProperty->sDocPr = pNonVisualDrawingProps.toXML2(L"wp:docPr");
|
||||
}
|
||||
else
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include "../../XlsxSerializerCom/Common/Common.h"
|
||||
#include "../../DesktopEditor/fontengine/FontManager.h"
|
||||
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
namespace Writers
|
||||
{
|
||||
@ -48,7 +49,7 @@ namespace Writers
|
||||
CApplicationFonts m_oApplicationFonts;
|
||||
CFontManager* m_pFontManager;
|
||||
public:
|
||||
std::map<std::wstring, int> m_mapFonts;
|
||||
boost::unordered_map<std::wstring, int> m_mapFonts;
|
||||
|
||||
FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir)
|
||||
{
|
||||
@ -81,7 +82,7 @@ namespace Writers
|
||||
bool bCalibri = false;
|
||||
bool bTimes = false;
|
||||
bool bCambria = false;
|
||||
for (std::map<std::wstring, int>::const_iterator it = m_mapFonts.begin(); it != m_mapFonts.end(); ++it)
|
||||
for (boost::unordered_map<std::wstring, int>::const_iterator it = m_mapFonts.begin(); it != m_mapFonts.end(); ++it)
|
||||
{
|
||||
const std::wstring& sFontName = it->first;
|
||||
if(_T("Calibri") == sFontName)
|
||||
|
||||
@ -144,9 +144,13 @@ namespace MathEquation
|
||||
void AddAccent (MEMBELTYPE eType)
|
||||
{
|
||||
LONG lPos = GetSize() - 1;
|
||||
|
||||
if (lPos < 0) return;
|
||||
|
||||
EquationRun oRun;
|
||||
oRun = arrRun[lPos];
|
||||
RemoveElem(lPos);
|
||||
|
||||
oRun.bAccent = true;
|
||||
oRun.eType = eType;
|
||||
Add(oRun);
|
||||
@ -412,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()
|
||||
@ -557,11 +561,11 @@ namespace MathEquation
|
||||
BYTE horAlign;
|
||||
switch(eHorAlign)
|
||||
{
|
||||
case matrixhoralignLeft: horAlign = SimpleTypes::xalignLeft;
|
||||
case matrixhoralignCenter: horAlign = SimpleTypes::xalignCenter;
|
||||
case matrixhoralignRight: horAlign = SimpleTypes::xalignRight;
|
||||
case matrixhoralignEqualSign: horAlign = SimpleTypes::xalignCenter;
|
||||
case matrixhoralignCommaSign: horAlign = SimpleTypes::xalignCenter;
|
||||
case matrixhoralignLeft: horAlign = SimpleTypes::xalignLeft; break;
|
||||
case matrixhoralignCenter: horAlign = SimpleTypes::xalignCenter; break;
|
||||
case matrixhoralignRight: horAlign = SimpleTypes::xalignRight; break;
|
||||
case matrixhoralignEqualSign: horAlign = SimpleTypes::xalignCenter; break;
|
||||
case matrixhoralignCommaSign: horAlign = SimpleTypes::xalignCenter; break;
|
||||
}
|
||||
WriteItemVal(BinDocxRW::c_oSer_OMathBottomNodesType::McJc, horAlign);
|
||||
|
||||
@ -1675,7 +1679,7 @@ namespace MathEquation
|
||||
|
||||
void WriteEndNode(BinaryEquationWriter* pWriter)
|
||||
{
|
||||
int nCurPos;
|
||||
int nCurPos = -1;
|
||||
if (!m_aBaseStack.empty())
|
||||
{
|
||||
nCurPos = m_aBaseStack.top();
|
||||
@ -1687,14 +1691,20 @@ namespace MathEquation
|
||||
}
|
||||
|
||||
if (bPile && bEqArrayStart)
|
||||
{
|
||||
pWriter->WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if (!bPile && !bEqArrayStart)
|
||||
{
|
||||
pWriter->WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if (!bPile && bEqArrayStart)
|
||||
{
|
||||
pWriter->m_aRowsCounter.push(nRows);
|
||||
bEqArrayStart = false;
|
||||
pWriter->WriteItemEnd(nCurPos);//eqArr
|
||||
|
||||
if (nCurPos > 0)
|
||||
pWriter->WriteItemEnd(nCurPos);//eqArr
|
||||
|
||||
if (!m_aBaseStack.empty())
|
||||
{
|
||||
|
||||
@ -344,7 +344,9 @@ extern int g_nCurFormatVersion;
|
||||
FramePr = 30,
|
||||
SectPr = 31,
|
||||
numPr_Ins = 32,
|
||||
pPrChange = 33
|
||||
pPrChange = 33,
|
||||
outlineLvl = 34,
|
||||
Tab_Item_Leader = 35
|
||||
};}
|
||||
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
|
||||
{
|
||||
@ -474,7 +476,11 @@ extern int g_nCurFormatVersion;
|
||||
MoveFromRangeStart = 18,
|
||||
MoveFromRangeEnd = 19,
|
||||
MoveToRangeStart = 20,
|
||||
MoveToRangeEnd = 21
|
||||
MoveToRangeEnd = 21,
|
||||
JsaProject = 22,
|
||||
BookmarkStart = 23,
|
||||
BookmarkEnd = 24
|
||||
|
||||
};}
|
||||
namespace c_oSerDocTableType{enum c_oSerDocTableType
|
||||
{
|
||||
@ -489,7 +495,9 @@ extern int g_nCurFormatVersion;
|
||||
Cell_Pr = 7,
|
||||
Cell_Content = 8,
|
||||
tblGridChange = 9,
|
||||
Sdt = 10
|
||||
Sdt = 10,
|
||||
BookmarkStart = 11,
|
||||
BookmarkEnd = 12
|
||||
};}
|
||||
namespace c_oSerRunType{enum c_oSerRunType
|
||||
{
|
||||
@ -502,8 +510,8 @@ extern int g_nCurFormatVersion;
|
||||
image = 6,
|
||||
table = 7,
|
||||
Content = 8,
|
||||
fldstart = 9,
|
||||
fldend = 10,
|
||||
fldstart_deprecated = 9,
|
||||
fldend_deprecated = 10,
|
||||
CommentReference = 11,
|
||||
pptxDrawing = 12,
|
||||
object = 14,
|
||||
@ -520,7 +528,10 @@ extern int g_nCurFormatVersion;
|
||||
endnoteRef = 25,
|
||||
footnoteReference = 26,
|
||||
endnoteReference = 27,
|
||||
arPr = 28
|
||||
arPr = 28,
|
||||
fldChar = 29,
|
||||
instrText = 30,
|
||||
delInstrText = 31
|
||||
};}
|
||||
namespace c_oSerVbaProjectTypes{enum c_oSerVbaProjectType
|
||||
{
|
||||
@ -895,7 +906,9 @@ extern int g_nCurFormatVersion;
|
||||
Ins = 62,
|
||||
Del = 63,
|
||||
columnbreak = 64,
|
||||
ARPr = 65
|
||||
ARPr = 65,
|
||||
BookmarkStart = 66,
|
||||
BookmarkEnd = 67
|
||||
};}
|
||||
namespace c_oSer_FramePrType{ enum c_oSer_FramePrType
|
||||
{
|
||||
@ -928,7 +941,8 @@ extern int g_nCurFormatVersion;
|
||||
{
|
||||
Content = 0,
|
||||
Instr = 1,
|
||||
FFData = 2
|
||||
FFData = 2,
|
||||
CharType = 3
|
||||
};}
|
||||
namespace c_oSer_ColorThemeType{ enum c_oSer_ColorThemeType
|
||||
{
|
||||
@ -1099,6 +1113,14 @@ extern int g_nCurFormatVersion;
|
||||
Name = 6,
|
||||
UserId = 7
|
||||
};}
|
||||
namespace c_oSerBookmark{enum c_oSerBookmark
|
||||
{
|
||||
Id = 0,
|
||||
Name = 1,
|
||||
DisplacedByCustomXml = 2,
|
||||
ColFirst = 3,
|
||||
ColLast = 4
|
||||
};}
|
||||
}
|
||||
|
||||
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,12 @@
|
||||
#include "ChartWriter.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.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"
|
||||
|
||||
#define NUMID_START 160
|
||||
const wchar_t* gc_Cat = L"cat";
|
||||
@ -127,10 +132,11 @@ namespace BinXlsxRW{
|
||||
}
|
||||
ChartWriter::~ChartWriter()
|
||||
{
|
||||
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); it++)
|
||||
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
|
||||
{
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
|
||||
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
|
||||
|
||||
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
|
||||
{
|
||||
delete itRow->second;
|
||||
}
|
||||
@ -140,28 +146,34 @@ namespace BinXlsxRW{
|
||||
void ChartWriter::toXlsx(OOX::Spreadsheet::CXlsx& oXlsx)
|
||||
{
|
||||
std::vector<std::wstring> aSharedStrings;
|
||||
//Sheet
|
||||
OOX::Spreadsheet::CWorkbook* pWorkbook = oXlsx.CreateWorkbook();
|
||||
pWorkbook->m_oSheets.Init();
|
||||
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets = oXlsx.GetWorksheets();
|
||||
|
||||
oXlsx.CreateWorkbook();
|
||||
oXlsx.m_pWorkbook->m_oSheets.Init();
|
||||
|
||||
int nSheetId = 1;
|
||||
OOX::Spreadsheet::CWorksheet* pFirstWorksheet = NULL;
|
||||
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); it++)
|
||||
|
||||
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
|
||||
{
|
||||
const std::wstring& sSheetName = it->first;
|
||||
OOX::Spreadsheet::CWorksheet* pWorksheet = toXlsxGetSheet(mapWorksheets, sSheetName);
|
||||
|
||||
//find or generate black worksheet
|
||||
OOX::Spreadsheet::CWorksheet* pWorksheet = toXlsxGetSheet(oXlsx.m_arWorksheets, oXlsx.m_mapWorksheets, sSheetName);
|
||||
//fill data to worksheet
|
||||
toXlsxSheetdata(pWorksheet, *it->second, aSharedStrings);
|
||||
|
||||
OOX::Spreadsheet::CSheet* pSheet = new OOX::Spreadsheet::CSheet();
|
||||
pSheet->m_oName.Init();
|
||||
pSheet->m_oName->append(sSheetName);
|
||||
pSheet->m_oSheetId.Init();
|
||||
pSheet->m_oSheetId->SetValue(nSheetId++);
|
||||
|
||||
smart_ptr<OOX::File> oWorksheetFile = smart_ptr<OOX::File>(pWorksheet);
|
||||
const OOX::RId oRId = pWorkbook->Add(oWorksheetFile);
|
||||
const OOX::RId oRId = oXlsx.m_pWorkbook->Add(oWorksheetFile);
|
||||
pSheet->m_oRid.Init();
|
||||
pSheet->m_oRid->SetValue(oRId.get());
|
||||
pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
|
||||
mapWorksheets[pSheet->m_oName.get()] = pWorksheet;
|
||||
|
||||
oXlsx.m_pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
|
||||
|
||||
if(NULL == pFirstWorksheet)
|
||||
{
|
||||
@ -170,7 +182,7 @@ namespace BinXlsxRW{
|
||||
}
|
||||
|
||||
//SharedStrings
|
||||
OOX::Spreadsheet::CSharedStrings* pSharedStrings = oXlsx.CreateSharedStrings();
|
||||
oXlsx.CreateSharedStrings();
|
||||
for(size_t i = 0; i < aSharedStrings.size(); ++i)
|
||||
{
|
||||
OOX::Spreadsheet::CText* pText = new OOX::Spreadsheet::CText();
|
||||
@ -182,33 +194,35 @@ namespace BinXlsxRW{
|
||||
}
|
||||
OOX::Spreadsheet::CSi* pSi = new OOX::Spreadsheet::CSi();
|
||||
pSi->m_arrItems.push_back(pText);
|
||||
pSharedStrings->m_arrItems.push_back(pSi);
|
||||
oXlsx.m_pSharedStrings->AddSi(pSi);
|
||||
}
|
||||
pSharedStrings->m_oCount.Init();
|
||||
pSharedStrings->m_oCount->SetValue(pSharedStrings->m_arrItems.size());
|
||||
pSharedStrings->m_oUniqueCount.Init();
|
||||
pSharedStrings->m_oUniqueCount->SetValue(pSharedStrings->m_arrItems.size());
|
||||
oXlsx.m_pSharedStrings->m_oCount.Init();
|
||||
oXlsx.m_pSharedStrings->m_oCount->SetValue(oXlsx.m_pSharedStrings->m_nCount);
|
||||
oXlsx.m_pSharedStrings->m_oUniqueCount.Init();
|
||||
oXlsx.m_pSharedStrings->m_oUniqueCount->SetValue(oXlsx.m_pSharedStrings->m_nCount);
|
||||
//Styles
|
||||
OOX::Spreadsheet::CStyles* pStyles = oXlsx.CreateStyles();
|
||||
pStyles->m_oCellXfs.Init();
|
||||
oXlsx.CreateStyles();
|
||||
oXlsx.m_pStyles->m_oCellXfs.Init();
|
||||
for(size_t i = 0; i < m_aXfs.size(); ++i)
|
||||
{
|
||||
pStyles->m_oCellXfs->m_arrItems.push_back(m_aXfs[i]);
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_arrItems.push_back(m_aXfs[i]);
|
||||
}
|
||||
pStyles->m_oNumFmts.Init();
|
||||
for (std::map<std::wstring, int>::iterator it = m_mapFormats.begin(); it != m_mapFormats.end(); it++)
|
||||
oXlsx.m_pStyles->m_oNumFmts.Init();
|
||||
|
||||
for (boost::unordered_map<std::wstring, int>::iterator it = m_mapFormats.begin(); it != m_mapFormats.end(); ++it)
|
||||
{
|
||||
OOX::Spreadsheet::CNumFmt* pNumFmt = new OOX::Spreadsheet::CNumFmt();
|
||||
pNumFmt->m_oFormatCode.Init();
|
||||
pNumFmt->m_oFormatCode->append(it->first);
|
||||
pNumFmt->m_oNumFmtId.Init();
|
||||
pNumFmt->m_oNumFmtId->SetValue(NUMID_START + it->second);
|
||||
pStyles->m_oNumFmts->m_arrItems.push_back(pNumFmt);
|
||||
oXlsx.m_pStyles->m_oNumFmts->m_arrItems.push_back(pNumFmt);
|
||||
}
|
||||
pStyles->m_oNumFmts->m_oCount.Init();
|
||||
pStyles->m_oNumFmts->m_oCount->SetValue(pStyles->m_oNumFmts->m_arrItems.size());
|
||||
pStyles->m_oCellXfs->m_oCount.Init();
|
||||
pStyles->m_oCellXfs->m_oCount->SetValue(pStyles->m_oCellXfs->m_arrItems.size());
|
||||
oXlsx.m_pStyles->m_oNumFmts->m_oCount.Init();
|
||||
oXlsx.m_pStyles->m_oNumFmts->m_oCount->SetValue(oXlsx.m_pStyles->m_oNumFmts->m_arrItems.size());
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_oCount.Init();
|
||||
oXlsx.m_pStyles->m_oCellXfs->m_oCount->SetValue(oXlsx.m_pStyles->m_oCellXfs->m_arrItems.size());
|
||||
|
||||
OOX::Spreadsheet::CDxf* pDxf = new OOX::Spreadsheet::CDxf();
|
||||
pDxf->m_oBorder.Init();
|
||||
pDxf->m_oBorder->m_oStart.Init();
|
||||
@ -235,15 +249,16 @@ namespace BinXlsxRW{
|
||||
pDxf->m_oBorder->m_oBottom->m_oColor.Init();
|
||||
pDxf->m_oBorder->m_oBottom->m_oColor->m_oIndexed.Init();
|
||||
pDxf->m_oBorder->m_oBottom->m_oColor->m_oIndexed->SetValue(12);
|
||||
pStyles->m_oDxfs.Init();
|
||||
pStyles->m_oDxfs->m_arrItems.push_back(pDxf);
|
||||
pStyles->m_oDxfs->m_oCount.Init();
|
||||
pStyles->m_oDxfs->m_oCount->SetValue(pStyles->m_oDxfs->m_arrItems.size());
|
||||
|
||||
oXlsx.m_pStyles->m_oDxfs.Init();
|
||||
oXlsx.m_pStyles->m_oDxfs->m_arrItems.push_back(pDxf);
|
||||
oXlsx.m_pStyles->m_oDxfs->m_oCount.Init();
|
||||
oXlsx.m_pStyles->m_oDxfs->m_oCount->SetValue(oXlsx.m_pStyles->m_oDxfs->m_arrItems.size());
|
||||
//Table
|
||||
//todo table в случае нескольких sheet или если серии разнесены по sheet
|
||||
if(m_aTableNames.size() > 0)
|
||||
{
|
||||
OOX::Spreadsheet::CTableFile* pTable = new OOX::Spreadsheet::CTableFile();
|
||||
OOX::Spreadsheet::CTableFile* pTable = new OOX::Spreadsheet::CTableFile(NULL);
|
||||
pTable->m_oTable.Init();
|
||||
pTable->m_oTable->m_oDisplayName.Init();
|
||||
pTable->m_oTable->m_oDisplayName->append(L"Table1");
|
||||
@ -286,9 +301,11 @@ namespace BinXlsxRW{
|
||||
{
|
||||
OOX::Spreadsheet::CTablePart* pTablePart = new OOX::Spreadsheet::CTablePart();
|
||||
NSCommon::smart_ptr<OOX::File> pTableFile(pTable);
|
||||
|
||||
const OOX::RId oRId = pFirstWorksheet->Add(pTableFile);
|
||||
pTablePart->m_oRId.Init();
|
||||
pTablePart->m_oRId->SetValue(oRId.get());
|
||||
|
||||
pFirstWorksheet->m_oTableParts.Init();
|
||||
pFirstWorksheet->m_oTableParts->m_arrItems.push_back(pTablePart);
|
||||
pFirstWorksheet->m_oTableParts->m_oCount.Init();
|
||||
@ -458,18 +475,22 @@ namespace BinXlsxRW{
|
||||
//проверяем можем ли создать таблицу
|
||||
if(m_mapSheets.size() > 0 && m_nRow1 > 0 && m_nRow2 > 0 && m_nCol1 > 0 && m_nCol2 > 0 && m_nRow1 < m_nRow2)
|
||||
{
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
|
||||
if(itRows != rows->end())
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
|
||||
|
||||
if(itRows != rows->end())
|
||||
{
|
||||
std::map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
|
||||
std::map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
|
||||
std::vector<int> aIndexesCell;
|
||||
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); it++)
|
||||
|
||||
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); ++it)
|
||||
{
|
||||
aIndexesCell.push_back(it->first);
|
||||
}
|
||||
std::sort(aIndexesCell.begin(), aIndexesCell.end());
|
||||
if(m_nCol2 - m_nCol1 + 1 == aIndexesCell.size() && m_nCol1 == aIndexesCell[0] && m_nCol2 == aIndexesCell[aIndexesCell.size() - 1])
|
||||
|
||||
std::sort(aIndexesCell.begin(), aIndexesCell.end());
|
||||
|
||||
if(m_nCol2 - m_nCol1 + 1 == aIndexesCell.size() && m_nCol1 == aIndexesCell[0] && m_nCol2 == aIndexesCell[aIndexesCell.size() - 1])
|
||||
{
|
||||
for(size_t j = 0; j < aIndexesCell.size(); ++j)
|
||||
{
|
||||
@ -482,13 +503,14 @@ namespace BinXlsxRW{
|
||||
}
|
||||
}
|
||||
}
|
||||
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
|
||||
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(std::vector<OOX::Spreadsheet::CWorksheet*>& arWorksheets, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
|
||||
{
|
||||
OOX::Spreadsheet::CWorksheet* pWorksheet = NULL;
|
||||
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator it = mapWorksheets.find(sName);
|
||||
if (it == mapWorksheets.end())
|
||||
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator pFind = mapWorksheets.find(sName);
|
||||
|
||||
if (pFind == mapWorksheets.end())
|
||||
{
|
||||
pWorksheet = new OOX::Spreadsheet::CWorksheet();
|
||||
pWorksheet = new OOX::Spreadsheet::CWorksheet(NULL);
|
||||
pWorksheet->m_oSheetFormatPr.Init();
|
||||
pWorksheet->m_oSheetFormatPr->m_oDefaultRowHeight.Init();
|
||||
pWorksheet->m_oSheetFormatPr->m_oDefaultRowHeight->SetValue(15);
|
||||
@ -508,39 +530,48 @@ namespace BinXlsxRW{
|
||||
pWorksheet->m_oPageMargins->m_oFooter->FromInches(0.3);
|
||||
|
||||
mapWorksheets[sName] = pWorksheet;
|
||||
arWorksheets.push_back(pWorksheet);
|
||||
}
|
||||
else
|
||||
{
|
||||
pWorksheet = it->second;
|
||||
pWorksheet = pFind->second;
|
||||
}
|
||||
return pWorksheet;
|
||||
}
|
||||
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
|
||||
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
|
||||
{
|
||||
pWorksheet->m_oSheetData.Init();
|
||||
std::vector<int> aIndexesRow;
|
||||
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); it++)
|
||||
|
||||
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); ++it)
|
||||
{
|
||||
aIndexesRow.push_back(it->first);
|
||||
}
|
||||
std::sort(aIndexesRow.begin(), aIndexesRow.end());
|
||||
for(size_t i = 0; i < aIndexesRow.size(); ++i)
|
||||
|
||||
std::sort(aIndexesRow.begin(), aIndexesRow.end());
|
||||
|
||||
for(size_t i = 0; i < aIndexesRow.size(); ++i)
|
||||
{
|
||||
int nIndexRow = aIndexesRow[i];
|
||||
OOX::Spreadsheet::CRow* pRow = new OOX::Spreadsheet::CRow();
|
||||
|
||||
OOX::Spreadsheet::CRow* pRow = new OOX::Spreadsheet::CRow();
|
||||
pRow->m_oR.Init();
|
||||
pRow->m_oR->SetValue(nIndexRow);
|
||||
const std::map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
|
||||
|
||||
const std::map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
|
||||
std::vector<int> aIndexesCell;
|
||||
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); it++)
|
||||
|
||||
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); ++it)
|
||||
{
|
||||
aIndexesCell.push_back(it->first);
|
||||
}
|
||||
std::sort(aIndexesCell.begin(), aIndexesCell.end());
|
||||
for(size_t j = 0; j < aIndexesCell.size(); ++j)
|
||||
|
||||
for(size_t j = 0; j < aIndexesCell.size(); ++j)
|
||||
{
|
||||
int nIndexCell = aIndexesCell[j];
|
||||
OOX::Spreadsheet::CCell* pCell = cells.at(nIndexCell);
|
||||
|
||||
OOX::Spreadsheet::CCell* pCell = cells.at(nIndexCell);
|
||||
//SharedStrings
|
||||
if(pCell->m_oValue.IsInit())
|
||||
{
|
||||
@ -588,22 +619,24 @@ namespace BinXlsxRW{
|
||||
}
|
||||
void ChartWriter::parseCell(const std::wstring& sheet, const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format = NULL)
|
||||
{
|
||||
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
|
||||
if(itSheets == m_mapSheets.end())
|
||||
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
|
||||
|
||||
if(itSheets == m_mapSheets.end())
|
||||
{
|
||||
rows = new std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>();
|
||||
rows = new std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>();
|
||||
m_mapSheets.insert(std::make_pair(sheet, rows));
|
||||
}
|
||||
else
|
||||
{
|
||||
rows = itSheets->second;
|
||||
}
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
|
||||
std::map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
|
||||
if(itRows == rows->end())
|
||||
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
|
||||
std::map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
|
||||
|
||||
if(itRows == rows->end())
|
||||
{
|
||||
cells = new std::map<int, OOX::Spreadsheet::CCell*>();
|
||||
cells = new std::map<int, OOX::Spreadsheet::CCell*>();
|
||||
rows->insert(std::make_pair(nRow, cells));
|
||||
}
|
||||
else
|
||||
@ -622,10 +655,12 @@ namespace BinXlsxRW{
|
||||
//пока добавляем как есть, shared string после записи таблицы
|
||||
pNewCell->m_oValue.Init();
|
||||
pNewCell->m_oValue->m_sText = val;
|
||||
if(NULL != format)
|
||||
|
||||
if(NULL != format)
|
||||
{
|
||||
int nXfsIndex = m_aXfs.size();
|
||||
std::map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
|
||||
|
||||
boost::unordered_map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
|
||||
if(itFormat == m_mapFormats.end())
|
||||
{
|
||||
m_mapFormats[*format] = nXfsIndex;
|
||||
@ -658,8 +693,7 @@ namespace BinXlsxRW{
|
||||
std::wstring wb, sheetFrom, sheetTo;
|
||||
int nRow1, nCol1, nRow2, nCol2;
|
||||
if(OOX::Spreadsheet::CCell::parse3DRef(*pStrRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
|
||||
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() &&
|
||||
NULL != pStrRef->m_strCache)
|
||||
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pStrRef->m_strCache)
|
||||
{
|
||||
bool bRow = nRow1 == nRow2;
|
||||
if(bUpdateRange)
|
||||
@ -727,7 +761,7 @@ namespace BinXlsxRW{
|
||||
std::wstring wb, sheetFrom, sheetTo;
|
||||
int nRow1, nCol1, nRow2, nCol2;
|
||||
if(OOX::Spreadsheet::CCell::parse3DRef(*pNumRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
|
||||
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
|
||||
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
|
||||
{
|
||||
bool bRow = nRow1 == nRow2;
|
||||
if(bUpdateRange)
|
||||
|
||||
@ -33,8 +33,9 @@
|
||||
#define CHART_WRITER
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
@ -59,22 +60,26 @@ namespace BinXlsxRW {
|
||||
class ChartWriter
|
||||
{
|
||||
public:
|
||||
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*> m_mapSheets;
|
||||
std::map<std::wstring, int> m_mapFormats;
|
||||
std::vector<OOX::Spreadsheet::CXfs*> m_aXfs;
|
||||
std::vector<std::wstring> m_aTableNames;
|
||||
int m_nRow1;
|
||||
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*> m_mapSheets;
|
||||
boost::unordered_map<std::wstring, int> m_mapFormats;
|
||||
|
||||
std::vector<OOX::Spreadsheet::CXfs*> m_aXfs;
|
||||
std::vector<std::wstring> m_aTableNames;
|
||||
|
||||
int m_nRow1;
|
||||
int m_nCol1;
|
||||
int m_nRow2;
|
||||
int m_nCol2;
|
||||
public:
|
||||
ChartWriter();
|
||||
|
||||
ChartWriter();
|
||||
~ChartWriter();
|
||||
void toXlsx(OOX::Spreadsheet::CXlsx& oXlsx);
|
||||
void parseChart(const OOX::Spreadsheet::CT_Chart* pChart);
|
||||
private:
|
||||
OOX::Spreadsheet::CWorksheet* toXlsxGetSheet(std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName);
|
||||
|
||||
private:
|
||||
OOX::Spreadsheet::CWorksheet* toXlsxGetSheet(std::vector<OOX::Spreadsheet::CWorksheet*>& arWorksheets, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName);
|
||||
void toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings);
|
||||
|
||||
void parseCell(const std::wstring& sheet, const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format);
|
||||
OOX::Spreadsheet::CCell* parseCreateCell(const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format);
|
||||
void parseStrRef(const OOX::Spreadsheet::CT_StrRef* pStrRef, bool bUpdateRange, const wchar_t* cRangeName);
|
||||
|
||||
@ -39,6 +39,9 @@
|
||||
#include "../../ASCOfficePPTXFile/Editor/FontPicker.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
|
||||
|
||||
int BinDocxRW::g_nCurFormatVersion = 0;
|
||||
|
||||
BinDocxRW::CDocxSerializer::CDocxSerializer()
|
||||
@ -47,7 +50,7 @@ BinDocxRW::CDocxSerializer::CDocxSerializer()
|
||||
m_pCurFileWriter = NULL;
|
||||
|
||||
m_bIsNoBase64Save = false;
|
||||
m_bIsNoBase64 = false;
|
||||
m_bIsNoBase64 = false;
|
||||
m_bSaveChartAsImg = false;
|
||||
}
|
||||
BinDocxRW::CDocxSerializer::~CDocxSerializer()
|
||||
@ -292,11 +295,13 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
|
||||
|
||||
OOX::CPath DocProps = std::wstring(_T("docProps"));
|
||||
|
||||
OOX::CApp* pApp = new OOX::CApp();
|
||||
OOX::CApp* pApp = new OOX::CApp(NULL);
|
||||
if (pApp)
|
||||
{
|
||||
pApp->SetApplication(_T("OnlyOffice"));
|
||||
pApp->SetAppVersion(_T("5.0"));
|
||||
pApp->SetApplication(L"ONLYOFFICE");
|
||||
#if defined(INTVER)
|
||||
pApp->SetAppVersion(VALUE2STR(INTVER));
|
||||
#endif
|
||||
pApp->SetDocSecurity(0);
|
||||
pApp->SetScaleCrop(false);
|
||||
pApp->SetLinksUpToDate(false);
|
||||
@ -306,7 +311,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
|
||||
pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, *pContentTypes);
|
||||
delete pApp;
|
||||
}
|
||||
OOX::CCore* pCore = new OOX::CCore();
|
||||
OOX::CCore* pCore = new OOX::CCore(NULL);
|
||||
if (pCore)
|
||||
{
|
||||
pCore->SetCreator(_T(""));
|
||||
|
||||
@ -33,6 +33,12 @@
|
||||
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/FontTable.h"
|
||||
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/TableStyles.h"
|
||||
|
||||
#include "../../ASCOfficePPTXFile/PPTXFormat/Theme.h"
|
||||
|
||||
#include "../../Common/ASCUtils.h"
|
||||
|
||||
namespace DocWrapper {
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#include "ChartWriter.h"
|
||||
|
||||
#include "../BinReader/DefaultThemeWriter.h"
|
||||
//#include "../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
|
||||
|
||||
namespace BinXlsxRW{
|
||||
int g_nCurFormatVersion = 0;
|
||||
@ -84,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);
|
||||
|
||||
@ -96,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);
|
||||
@ -136,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)
|
||||
{
|
||||
@ -168,7 +168,7 @@ namespace BinXlsxRW{
|
||||
|
||||
//todo theme path
|
||||
BinXlsxRW::SaveParams oSaveParams(sThemePath, m_pExternalDrawingConverter->GetContentTypes());
|
||||
OOX::Spreadsheet::CChartSpace oChartSpace;
|
||||
OOX::Spreadsheet::CChartSpace oChartSpace(NULL);
|
||||
BinXlsxRW::BinaryChartReader oBinaryChartReader(*pReader, oSaveParams, m_pExternalDrawingConverter);
|
||||
|
||||
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);
|
||||
@ -181,20 +181,22 @@ namespace BinXlsxRW{
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
|
||||
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
|
||||
|
||||
writeChartXlsx(sXlsxPath, oChartSpace);
|
||||
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
if (writeChartXlsx(sXlsxPath, oChartSpace))
|
||||
{
|
||||
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rId;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rId;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
|
||||
|
||||
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring strFilepath = sFilepath;
|
||||
@ -233,7 +235,7 @@ namespace BinXlsxRW{
|
||||
m_bIsNoBase64 = bIsNoBase64;
|
||||
}
|
||||
|
||||
void CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
|
||||
bool CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
|
||||
{
|
||||
//анализируем chart
|
||||
BinXlsxRW::ChartWriter helper;
|
||||
@ -252,11 +254,15 @@ namespace BinXlsxRW{
|
||||
helper.toXlsx(oXlsx);
|
||||
//write
|
||||
OOX::CContentTypes oContentTypes;
|
||||
oXlsx.Write(oPath, oContentTypes);
|
||||
//zip
|
||||
COfficeUtils oOfficeUtils(NULL);
|
||||
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
|
||||
bool res = oXlsx.Write(oPath, oContentTypes);
|
||||
if (res)
|
||||
{
|
||||
//zip
|
||||
COfficeUtils oOfficeUtils(NULL);
|
||||
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
|
||||
}
|
||||
//clean
|
||||
NSDirectory::DeleteDirectory(sTempDir);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -72,7 +72,7 @@ namespace BinXlsxRW {
|
||||
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
|
||||
void setIsNoBase64 (bool bIsNoBase64);
|
||||
|
||||
void writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
|
||||
bool writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
|
||||
};
|
||||
}
|
||||
#endif // #ifndef XLSX_SERIALIZER
|
||||
|
||||
@ -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 \
|
||||
|
||||
@ -314,7 +314,7 @@
|
||||
17E17ED41AC453F800BEA2EA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0830;
|
||||
LastUpgradeCheck = 0900;
|
||||
ORGANIZATIONNAME = "Ascensio System SIA";
|
||||
};
|
||||
buildConfigurationList = 17E17ED71AC453F800BEA2EA /* Build configuration list for PBXProject "ASCOfficeDocxFile2Lib" */;
|
||||
@ -402,6 +402,7 @@
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_ENABLE_CPP_EXCEPTIONS = YES;
|
||||
GCC_ENABLE_CPP_RTTI = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
UNICODE,
|
||||
_UNICODE,
|
||||
@ -441,14 +442,20 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@ -470,7 +477,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -486,14 +493,20 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
@ -509,7 +522,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
|
||||
@ -34,9 +34,11 @@
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "../../Common/OfficeFileFormatChecker.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../src/ConvertOO2OOX.h"
|
||||
#include "../include/logging.h"
|
||||
|
||||
|
||||
#if defined(_WIN64)
|
||||
@ -45,30 +47,55 @@
|
||||
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
HRESULT convert_single(std::wstring srcFileName)
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
std::wstring srcFileName = argv[1];
|
||||
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx docx
|
||||
|
||||
COfficeFileFormatChecker fileChecker(srcFileName);
|
||||
|
||||
std::wstring dstPath = srcFileName;// + ; //xlsx pptx docx
|
||||
switch(fileChecker.nFileType)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT: dstPath += L"-my.docx"; break;
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS:
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT: dstPath += L"-my.xlsx"; break;
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP:
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT: dstPath += L"-my.pptx"; break;
|
||||
|
||||
default:
|
||||
return S_FALSE;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
|
||||
|
||||
std::wstring srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
std::wstring srcTempPath;
|
||||
|
||||
// распаковываем исходник во временную директорию
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
|
||||
return S_FALSE;
|
||||
if (fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT ||
|
||||
fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS ||
|
||||
fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP)
|
||||
{
|
||||
srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
|
||||
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
|
||||
return S_FALSE;
|
||||
}
|
||||
else // flat
|
||||
{
|
||||
srcTempPath = srcFileName;
|
||||
}
|
||||
_CP_LOG << L"[info] " << srcFileName << std::endl;
|
||||
|
||||
hr = ConvertOO2OOX(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", false, NULL);
|
||||
|
||||
NSDirectory::DeleteDirectory(srcTempPath);
|
||||
if (srcTempPath != srcFileName)
|
||||
{
|
||||
NSDirectory::DeleteDirectory(srcTempPath);
|
||||
}
|
||||
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
@ -77,6 +104,35 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
|
||||
NSDirectory::DeleteDirectory(dstTempPath);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
return 0;
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT convert_directory(std::wstring pathName)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
|
||||
|
||||
for (size_t i = 0; i < arFiles.size(); i++)
|
||||
{
|
||||
convert_single(arFiles[i]);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
HRESULT hr = -1;
|
||||
if (NSFile::CFileBinary::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_single(argv[1]);
|
||||
}
|
||||
else if (NSDirectory::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_directory(argv[1]);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
@ -47,7 +47,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE;UNICODE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
@ -68,6 +68,7 @@
|
||||
ShowProgress="0"
|
||||
Version=""
|
||||
LinkIncremental="2"
|
||||
IgnoreDefaultLibraryNames=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
@ -336,6 +337,14 @@
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\Common\OfficeFileFormatChecker.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
|
||||
>
|
||||
@ -348,6 +357,10 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
|
||||
>
|
||||
|
||||
@ -389,29 +389,37 @@ namespace formulasconvert {
|
||||
}
|
||||
|
||||
|
||||
std::wstring forbidden_formulas[] =
|
||||
{
|
||||
L"NULLFORMULA"
|
||||
//L"BETADIST",
|
||||
//L"CEILING",
|
||||
//L"FLOOR",
|
||||
//L"RANK",
|
||||
//L"ROUND",
|
||||
//L"ROUNDDOWN",
|
||||
//L"ROUNDUP",
|
||||
//L"SUBTOTAL",
|
||||
//L"FORMULA",
|
||||
//L"ISREF"
|
||||
};
|
||||
//std::wstring forbidden_formulas[] =
|
||||
//{
|
||||
// L"NULLFORMULA"
|
||||
// //L"BETADIST",
|
||||
// //L"CEILING",
|
||||
// //L"FLOOR",
|
||||
// //L"RANK",
|
||||
// //L"ROUND",
|
||||
// //L"ROUNDDOWN",
|
||||
// //L"ROUNDUP",
|
||||
// //L"SUBTOTAL",
|
||||
// //L"FORMULA",
|
||||
// //L"ISREF"
|
||||
//};
|
||||
|
||||
bool is_forbidden(const std::wstring & formula)
|
||||
std::wstring is_forbidden(const std::wstring & formula)
|
||||
{
|
||||
for (size_t i = 0; i < 1/*forbidden_formulas.size()*/; i++)
|
||||
std::wstring result = formula;
|
||||
std::map<std::wstring, std::wstring> forbidden_formulas;
|
||||
|
||||
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
|
||||
{
|
||||
if (boost::algorithm::contains(formula, forbidden_formulas[i]))
|
||||
return true;
|
||||
if (boost::algorithm::contains(formula, it->first))
|
||||
{
|
||||
|
||||
XmlUtils::replace_all(result, it->first, it->second);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
// заменить вертикальную черту во всех вхождениях в фигурных скобках, но не внутри строк
|
||||
@ -437,10 +445,7 @@ namespace formulasconvert {
|
||||
|
||||
std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
|
||||
{
|
||||
if (is_forbidden(expr))
|
||||
return L"NULLFORMULA()";
|
||||
|
||||
std::wstring workstr = expr;
|
||||
std::wstring workstr = is_forbidden(expr);
|
||||
//boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// Better_Donut.ods- cell(c27)
|
||||
//std::wstring workstr = boost::regex_replace(
|
||||
// expr,
|
||||
@ -449,7 +454,7 @@ namespace formulasconvert {
|
||||
// boost::match_default | boost::format_all);
|
||||
|
||||
bool isFormula = check_formula(workstr);
|
||||
|
||||
|
||||
boost::regex_replace(
|
||||
workstr,
|
||||
boost::wregex(L"('.*?')|(\".*?\")"),
|
||||
@ -472,6 +477,12 @@ namespace formulasconvert {
|
||||
}
|
||||
//todooo INDEX((A1:C6~A8:C11),2,2,2) - ???? - INDEX_emb.ods
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t sz_workstr = workstr.length();
|
||||
if (workstr.substr(0, (std::min)((size_t)3, sz_workstr)) == L"of:")//sample_02neu_crashes.ods
|
||||
workstr = workstr.substr(3);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
@ -517,10 +528,8 @@ namespace formulasconvert {
|
||||
|
||||
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
|
||||
{
|
||||
if (is_forbidden(expr))
|
||||
return L"NULLFORMULA()";
|
||||
std::wstring workstr = is_forbidden(expr);
|
||||
|
||||
std::wstring workstr = expr;
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
|
||||
@ -35,11 +35,15 @@
|
||||
#include "../CPSharedPtr.h"
|
||||
#include "../CPScopedPtr.h"
|
||||
|
||||
|
||||
struct ProgressCallback;
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace xml
|
||||
{
|
||||
class sax;
|
||||
}
|
||||
|
||||
namespace oox {
|
||||
class docx_conversion_context;
|
||||
class xlsx_conversion_context;
|
||||
@ -54,9 +58,10 @@ class odf_document
|
||||
{
|
||||
public:
|
||||
odf_document(const std::wstring & Folder, const ProgressCallback* CallBack);
|
||||
~odf_document();
|
||||
odf_document(xml::sax * Reader);
|
||||
|
||||
~odf_document();
|
||||
|
||||
public:
|
||||
odf_read_context & odf_context();
|
||||
|
||||
bool docx_convert(oox::docx_conversion_context & Context);
|
||||
@ -77,6 +82,7 @@ private:
|
||||
_CP_SCOPED_PTR(Impl) impl_;
|
||||
|
||||
};
|
||||
typedef shared_ptr<odf_document>::Type odf_document_ptr;
|
||||
|
||||
}
|
||||
}
|
||||
@ -335,8 +335,8 @@ namespace internal
|
||||
inline bool starts_with_bom (octet_iterator it, octet_iterator end)
|
||||
{
|
||||
return (
|
||||
((it != end) && (internal::mask8(*it++)) == bom[0]) &&
|
||||
((it != end) && (internal::mask8(*it++)) == bom[1]) &&
|
||||
((it != end) && (internal::mask8(*++it)) == bom[0]) &&
|
||||
((it != end) && (internal::mask8(*++it)) == bom[1]) &&
|
||||
((it != end) && (internal::mask8(*it)) == bom[2])
|
||||
);
|
||||
}
|
||||
@ -346,8 +346,8 @@ namespace internal
|
||||
inline bool is_bom (octet_iterator it)
|
||||
{
|
||||
return (
|
||||
(internal::mask8(*it++)) == bom[0] &&
|
||||
(internal::mask8(*it++)) == bom[1] &&
|
||||
(internal::mask8(*++it)) == bom[0] &&
|
||||
(internal::mask8(*++it)) == bom[1] &&
|
||||
(internal::mask8(*it)) == bom[2]
|
||||
);
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ namespace utf8
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
it++;
|
||||
++it;
|
||||
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
|
||||
break;
|
||||
case 3:
|
||||
|
||||
@ -154,7 +154,7 @@ namespace cpdoccore
|
||||
if (val)
|
||||
{
|
||||
std::wstring tmp = *val;
|
||||
XmlUtils::GetLower(tmp);
|
||||
tmp = XmlUtils::GetLower(tmp);
|
||||
return optional<bool>::Type((tmp == xml_char_value_type::trueVal));
|
||||
}
|
||||
else
|
||||
|
||||
@ -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
|
||||
|
||||
@ -217,6 +215,7 @@ SOURCES += \
|
||||
../src/odf/datatypes/tableorientation.cpp \
|
||||
../src/odf/datatypes/tablefunction.cpp \
|
||||
../src/odf/datatypes/tableorder.cpp \
|
||||
../src/odf/datatypes/dategroup.cpp \
|
||||
../src/docx/xlsx_conditionalFormatting.cpp \
|
||||
../src/docx/xlsx_dxfs.cpp \
|
||||
../src/docx/docx_content_type.cpp \
|
||||
@ -287,6 +286,7 @@ SOURCES += \
|
||||
../src/docx/xlsx_table_state.cpp \
|
||||
../src/docx/xlsx_textcontext.cpp \
|
||||
../src/docx/xlsx_pivots_context.cpp \
|
||||
../src/docx/xlsx_data_validation.cpp \
|
||||
../src/docx/xlsx_utils.cpp \
|
||||
../src/docx/xlsx_xf.cpp
|
||||
}
|
||||
@ -550,11 +550,11 @@ HEADERS += \
|
||||
../src/docx/xlsx_table_position.h \
|
||||
../src/docx/xlsx_table_state.h \
|
||||
../src/docx/xlsx_textcontext.h \
|
||||
../src/docx/xlsx_data_validation.h \
|
||||
../src/docx/xlsx_utils.h \
|
||||
../src/docx/xlsx_xf.h \
|
||||
../include/logging.h \
|
||||
../include/cpdoccore/CPColorUtils.h \
|
||||
../include/cpdoccore/CPHash.h \
|
||||
../include/cpdoccore/CPNoncopyable.h \
|
||||
../include/cpdoccore/CPOptional.h \
|
||||
../include/cpdoccore/CPScopedPtr.h \
|
||||
|
||||
@ -126,3 +126,4 @@
|
||||
#include "../src/odf/datatypes/tableorientation.cpp"
|
||||
#include "../src/odf/datatypes/tablefunction.cpp"
|
||||
#include "../src/odf/datatypes/tableorder.cpp"
|
||||
#include "../src/odf/datatypes/dategroup.cpp"
|
||||
|
||||
@ -101,3 +101,4 @@
|
||||
#include "../src/docx/xlsx_utils.cpp"
|
||||
#include "../src/docx/xlsx_xf.cpp"
|
||||
#include "../src/docx/xlsx_pivots_context.cpp"
|
||||
#include "../src/docx/xlsx_data_validation.cpp""
|
||||
|
||||
@ -97,14 +97,6 @@ HRESULT ConvertOO2OOX(const std::wstring & srcPath, const std::wstring & dstPath
|
||||
|
||||
if (encrypted) return AVS_ERROR_DRM;
|
||||
|
||||
//if (type<1)
|
||||
//{
|
||||
// if (ext == L".odt")type = 1;
|
||||
// if (ext == L".ods")type = 2;
|
||||
// if (ext == L".odp")type = 3;
|
||||
|
||||
//}
|
||||
|
||||
if (bOnlyPresentation && type != 3)return AVS_ERROR_UNEXPECTED;
|
||||
|
||||
switch (type)
|
||||
|
||||
@ -96,7 +96,7 @@ void text_tracked_context::start_change (std::wstring id)
|
||||
{
|
||||
current_state_.clear();
|
||||
|
||||
current_state_.id = id;
|
||||
current_state_.id = id;
|
||||
}
|
||||
void text_tracked_context::end_change ()
|
||||
{
|
||||
@ -378,7 +378,8 @@ void docx_conversion_context::start_document()
|
||||
output_stream() << L"xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ";
|
||||
output_stream() << L"xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ";
|
||||
output_stream() << L"xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ";
|
||||
output_stream() << L"xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ";
|
||||
output_stream() << L"xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ";
|
||||
output_stream() << L"xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ";
|
||||
output_stream() << L"mc:Ignorable=\"w14 wp14\">";
|
||||
|
||||
|
||||
@ -406,14 +407,12 @@ void docx_conversion_context::end_document()
|
||||
|
||||
output_document_->get_word_files().set_notes(notes_context_);
|
||||
////////////////////////
|
||||
int count = 0;
|
||||
BOOST_FOREACH(const oox_chart_context_ptr& chart, charts_)
|
||||
for (size_t i = 0; i < charts_.size(); i++)
|
||||
{
|
||||
count++;
|
||||
package::chart_content_ptr content = package::chart_content::create();
|
||||
|
||||
chart->serialize(content->content());
|
||||
chart->dump_rels(content->get_rel_file()->get_rels());
|
||||
charts_[i]->serialize(content->content());
|
||||
charts_[i]->dump_rels(content->get_rel_file()->get_rels());
|
||||
|
||||
output_document_->get_word_files().add_charts(content);
|
||||
|
||||
@ -580,10 +579,10 @@ mc:Ignorable=\"w14 wp14\">";
|
||||
strm << L"</w:abstractNum>";
|
||||
}
|
||||
|
||||
BOOST_FOREACH(int numId, numIds)
|
||||
for (size_t i = 0; i < numIds.size(); i++)
|
||||
{
|
||||
strm << L"<w:num w:numId=\"" << numId << L"\" >";
|
||||
strm << L"<w:abstractNumId w:val=\"" << numId << "\" />";
|
||||
strm << L"<w:num w:numId=\"" << numIds[i] << L"\" >";
|
||||
strm << L"<w:abstractNumId w:val=\"" << numIds[i] << "\" />";
|
||||
strm << L"</w:num>";
|
||||
}
|
||||
|
||||
@ -733,16 +732,38 @@ void docx_conversion_context::start_process_style_content()
|
||||
styles_context_.start();
|
||||
}
|
||||
|
||||
void docx_conversion_context::process_section(std::wostream & strm, odf_reader::style_columns * columns)
|
||||
void docx_conversion_context::process_section(std::wostream & strm, odf_reader::style_columns * columns)//from page layout
|
||||
{
|
||||
int count_columns = 1;
|
||||
bool sep_columns = false;
|
||||
|
||||
oox::section_context::_section & section = get_section_context().get();
|
||||
|
||||
if (!columns)
|
||||
{
|
||||
if (const odf_reader::style_instance * secStyle = root()->odf_context().styleContainer().style_by_name(section.style_, odf_types::style_family::Section, process_headers_footers_))
|
||||
{
|
||||
if (const odf_reader::style_content * content = secStyle->content())
|
||||
{
|
||||
if (odf_reader::style_section_properties * sectPr = content->get_style_section_properties())
|
||||
{
|
||||
columns = dynamic_cast<odf_reader::style_columns *>( sectPr->style_columns_.get());
|
||||
|
||||
section.margin_left_ = sectPr->common_horizontal_margin_attlist_.fo_margin_left_;
|
||||
section.margin_right_ = sectPr->common_horizontal_margin_attlist_.fo_margin_right_;
|
||||
}
|
||||
}
|
||||
if (section.is_dump_)
|
||||
{
|
||||
get_section_context().remove_section();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::pair<double, double>> width_space;
|
||||
if (columns)
|
||||
{
|
||||
if ((columns->fo_column_count_) && (*columns->fo_column_count_ > 1))
|
||||
if (columns->fo_column_count_)
|
||||
{
|
||||
count_columns = *columns->fo_column_count_;
|
||||
}
|
||||
@ -751,44 +772,64 @@ void docx_conversion_context::process_section(std::wostream & strm, odf_reader::
|
||||
if (columns_sep->style_style_ != _T("none"))
|
||||
sep_columns = true;
|
||||
}
|
||||
}
|
||||
if (const odf_reader::style_instance * secStyle = root()->odf_context().styleContainer().style_by_name(section.style_, odf_types::style_family::Section, process_headers_footers_))
|
||||
{
|
||||
if (const odf_reader::style_content * content = secStyle->content())
|
||||
{
|
||||
if (odf_reader::style_section_properties * sectPr = content->get_style_section_properties())
|
||||
{
|
||||
if (odf_reader::style_columns * columns = dynamic_cast<odf_reader::style_columns *>( sectPr->style_columns_.get() ))
|
||||
{
|
||||
if (columns->fo_column_count_)
|
||||
{
|
||||
count_columns = *columns->fo_column_count_;
|
||||
}
|
||||
if (odf_reader::style_column_sep * columns_sep = dynamic_cast<odf_reader::style_column_sep *>( columns->style_column_sep_.get() ))
|
||||
{
|
||||
if (columns_sep->style_style_ != _T("none"))
|
||||
sep_columns = true;
|
||||
}
|
||||
}
|
||||
|
||||
section.margin_left_ = sectPr->common_horizontal_margin_attlist_.fo_margin_left_;
|
||||
section.margin_right_ = sectPr->common_horizontal_margin_attlist_.fo_margin_right_;
|
||||
if (!columns->style_columns_.empty())
|
||||
{
|
||||
double page_width = 0;
|
||||
const odf_reader::page_layout_instance * pp = root()->odf_context().pageLayoutContainer().page_layout_first();
|
||||
|
||||
if ((pp) && (pp->properties()))
|
||||
{
|
||||
odf_reader::style_page_layout_properties_attlist & attr_page = pp->properties()->attlist_;
|
||||
if (attr_page.fo_page_width_)
|
||||
{
|
||||
page_width = attr_page.fo_page_width_->get_value_unit(odf_types::length::pt);
|
||||
}
|
||||
if (attr_page.common_horizontal_margin_attlist_.fo_margin_left_)
|
||||
{
|
||||
page_width -= attr_page.common_horizontal_margin_attlist_.fo_margin_left_->get_length().get_value_unit(odf_types::length::pt);
|
||||
}
|
||||
if (attr_page.common_horizontal_margin_attlist_.fo_margin_right_)
|
||||
{
|
||||
page_width -= attr_page.common_horizontal_margin_attlist_.fo_margin_right_->get_length().get_value_unit(odf_types::length::pt);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; page_width > 0, i < columns->style_columns_.size(); i++)
|
||||
{
|
||||
odf_reader::style_column * col = dynamic_cast<odf_reader::style_column*>( columns->style_columns_[i].get());
|
||||
if (!col) continue;
|
||||
|
||||
double width = page_width * (col->style_rel_width_ ? col->style_rel_width_->get_value() / 65535. : 0);
|
||||
|
||||
double space = col->fo_end_indent_ ? col->fo_end_indent_->get_value_unit(odf_types::length::pt) : 0;
|
||||
|
||||
if (i < columns->style_columns_.size() - 1)
|
||||
{
|
||||
col = dynamic_cast<odf_reader::style_column*>( columns->style_columns_[i + 1].get());
|
||||
space += col->fo_start_indent_ ? col->fo_start_indent_->get_value_unit(odf_types::length::pt) : 0;
|
||||
}
|
||||
|
||||
width_space.push_back(std::make_pair(width, space));
|
||||
}
|
||||
}
|
||||
if (section.is_dump_)
|
||||
{
|
||||
get_section_context().remove_section();
|
||||
}
|
||||
}
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"w:cols")
|
||||
{
|
||||
CP_XML_ATTR(L"w:equalWidth", L"true");
|
||||
CP_XML_ATTR(L"w:equalWidth", width_space.empty());
|
||||
CP_XML_ATTR(L"w:num", count_columns);
|
||||
CP_XML_ATTR(L"w:sep", sep_columns);
|
||||
CP_XML_ATTR(L"w:space",0);
|
||||
CP_XML_ATTR(L"w:space", 708);
|
||||
|
||||
for (size_t i = 0; i < width_space.size(); i++)
|
||||
{
|
||||
CP_XML_NODE(L"w:col")
|
||||
{
|
||||
CP_XML_ATTR(L"w:w", (int)(width_space[i].first * 20));
|
||||
CP_XML_ATTR(L"w:space", (int)(width_space[i].second * 20));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -801,7 +842,7 @@ bool docx_conversion_context::process_page_properties(std::wostream & strm)
|
||||
|
||||
if (page_layout_instance_)
|
||||
{
|
||||
page_layout_instance_->docx_convert_serialize(strm, *this);
|
||||
page_layout_instance_->docx_serialize(strm, *this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -847,18 +888,18 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
//Tutor_Charlotte_Tutor_the_Entire_World_.odt
|
||||
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
|
||||
&& !get_table_context().in_table() && !in_drawing)
|
||||
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
|
||||
CP_XML_NODE(L"w:pPr")
|
||||
{
|
||||
CP_XML_STREAM() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
}
|
||||
finish_paragraph();
|
||||
start_paragraph();
|
||||
}
|
||||
////Tutor_Charlotte_Tutor_the_Entire_World_.odt
|
||||
//if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
|
||||
// && !get_table_context().in_table() && !in_drawing)
|
||||
//{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
|
||||
// CP_XML_NODE(L"w:pPr")
|
||||
// {
|
||||
// CP_XML_STREAM() << get_section_context().dump_;
|
||||
// get_section_context().dump_.clear();
|
||||
// }
|
||||
// finish_paragraph();
|
||||
// start_paragraph();
|
||||
//}
|
||||
|
||||
if (!paragraph_style.str().empty() || !ParentId.empty())
|
||||
{
|
||||
@ -1129,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;
|
||||
}
|
||||
@ -1286,7 +1327,8 @@ void docx_conversion_context::start_text_changes (std::wstring id)
|
||||
L" w:author=\"" + state.author + L"\"" ;
|
||||
|
||||
finish_run();
|
||||
state.active = true;
|
||||
state.active = true;
|
||||
state.in_drawing = get_drawing_state_content();
|
||||
|
||||
if (state.type == 1)
|
||||
{
|
||||
@ -1320,7 +1362,7 @@ void docx_conversion_context::start_changes()
|
||||
text_tracked_context_.dumpTcPr_.clear();
|
||||
text_tracked_context_.dumpTblPr_.clear();
|
||||
|
||||
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
|
||||
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); ++it)
|
||||
{
|
||||
text_tracked_context::_state &state = it->second;
|
||||
|
||||
@ -1413,13 +1455,16 @@ void docx_conversion_context::end_changes()
|
||||
{
|
||||
if (process_comment_) return;
|
||||
|
||||
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
|
||||
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); ++it)
|
||||
{
|
||||
text_tracked_context::_state &state = it->second;
|
||||
|
||||
if (state.type == 0) continue; //unknown change ... libra format change skip
|
||||
if (state.type == 3) continue;
|
||||
if (!state.active) continue;
|
||||
|
||||
if (state.in_drawing != get_drawing_state_content())
|
||||
continue;
|
||||
|
||||
if (state.type == 1) output_stream() << L"</w:ins>";
|
||||
if (state.type == 2) output_stream() << L"</w:del>";
|
||||
|
||||
@ -224,8 +224,9 @@ public:
|
||||
bool & get_use_image_replace()
|
||||
{
|
||||
bool res = false;
|
||||
if (frames_.size()>0) return frames_.back().use_image_replace;
|
||||
else return res;
|
||||
if (!frames_.empty()) return frames_.back().use_image_replace;
|
||||
else
|
||||
throw;
|
||||
}
|
||||
|
||||
std::wstring & get_text_stream_shape()
|
||||
@ -492,10 +493,11 @@ public:
|
||||
std::wstring id;
|
||||
std::wstring author;
|
||||
std::wstring date;
|
||||
int type;
|
||||
int type = 0;
|
||||
std::wstring style_name;
|
||||
std::vector<std::wstring> content; //delete elements
|
||||
bool active;
|
||||
bool active = false;
|
||||
bool in_drawing = false;
|
||||
|
||||
void clear()
|
||||
{
|
||||
@ -505,6 +507,7 @@ public:
|
||||
date.clear();
|
||||
content.clear();
|
||||
active = false;
|
||||
in_drawing = false;
|
||||
}
|
||||
};
|
||||
std::wstring dumpPPr_;
|
||||
@ -760,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_;
|
||||
@ -778,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_;// цепочки переименований нумераций
|
||||
};
|
||||
|
||||
@ -392,8 +392,11 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"wp:extent")
|
||||
{
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
if (val.cx > 0 || val.cy > 0)
|
||||
{
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
}
|
||||
|
||||
serialize_null_extent(CP_XML_STREAM());
|
||||
}
|
||||
@ -463,10 +466,13 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"wp:extent")
|
||||
if (val.cx > 0 || val.cy > 0)
|
||||
{
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
CP_XML_NODE(L"wp:extent")
|
||||
{
|
||||
CP_XML_ATTR(L"cx", val.cx);
|
||||
CP_XML_ATTR(L"cy", val.cy);
|
||||
}
|
||||
}
|
||||
|
||||
serialize_wrap(CP_XML_STREAM(), val);
|
||||
|
||||
@ -319,6 +319,7 @@ namespace
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" >";
|
||||
|
||||
//mc:Ignorable=\"w14 wp14\"
|
||||
|
||||
@ -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_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -181,7 +181,11 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
sub_path = L"embeddings/";
|
||||
}
|
||||
else
|
||||
{
|
||||
isMediaInternal = is_internal(href, odf_packet_);
|
||||
if (href.empty() && type == typeImage)
|
||||
return L"";
|
||||
}
|
||||
|
||||
int number=0;
|
||||
|
||||
@ -205,9 +209,9 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
if ( type == typeChart) outputPath = outputPath + L".xml";
|
||||
|
||||
std::wstring id;
|
||||
for (int i = 0 ; i < items_.size(); i++)
|
||||
for (size_t i = 0 ; i < items_.size(); i++)
|
||||
{
|
||||
if (items_[i].href == inputPath)
|
||||
if ((items_[i].href == inputPath && !inputPath.empty()) || (items_[i].type == type && inputPath.empty()))
|
||||
{
|
||||
id = items_[i].Id;
|
||||
outputPath = items_[i].outputName;
|
||||
|
||||
@ -127,6 +127,7 @@ public:
|
||||
if (sExt == L"m4v") return typeVideo;
|
||||
if (sExt == L"mp4") return typeVideo;
|
||||
if (sExt == L"mov") return typeVideo;
|
||||
if (sExt == L"mkv") return typeVideo;
|
||||
|
||||
return typeMedia;
|
||||
}
|
||||
|
||||
@ -48,13 +48,19 @@ _CP_PTR(oox_axis_content) oox_axis_content::create(int type)
|
||||
|
||||
oox_axis_content::oox_axis_content(int type/*,std::wstring name*/)
|
||||
{
|
||||
//id_ = abs((int)*((_UINT32*)this));
|
||||
id_ = abs((long)this);
|
||||
type_=type; //dimension
|
||||
if (type == 0)
|
||||
{
|
||||
id_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
id_ = abs((long)this);
|
||||
}
|
||||
type_ = type;
|
||||
}
|
||||
void oox_axis_content::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
if (id_ <0 )return;//not activate
|
||||
if (id_ < 1 )return; //not activate, blank axis
|
||||
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user