From 8c212908bd0e0b1196d2c509a13738ee5f4eb6ab Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 7 Oct 2021 19:08:05 +0300 Subject: [PATCH] fix bug #52560 --- .../DocDocxConverter/Converter.cpp | 110 +--------------- ASCOfficeDocFile/DocDocxConverter/Converter.h | 6 +- .../DocDocxConverter/MainDocumentMapping.cpp | 21 +--- .../DocDocxConverter/MainDocumentMapping.h | 7 +- .../DocDocxConverter/SprmTDefTable.h | 2 +- .../TableCellPropertiesMapping.cpp | 15 ++- .../TablePropertiesMapping.cpp | 119 ++++++------------ .../DocDocxConverter/VMLShapeMapping.cpp | 39 ++++-- .../DocDocxConverter/WordDocument.cpp | 74 +---------- .../DocDocxConverter/WordDocument.h | 5 +- .../WordprocessingDocument.cpp | 3 +- .../DocDocxConverter/WordprocessingDocument.h | 2 +- .../DocFormatLib/DocFormatLib.cpp | 6 +- ASCOfficeDocFile/DocFormatLib/DocFormatLib.h | 10 +- Common/3dParty/cryptopp/cryptlib.vcxproj | 7 +- Common/OfficeFileFormatChecker2.cpp | 6 + OfficeCryptReader/Test/Test.sln | 18 ++- .../win32/ECMACryptReader.vcxproj | 7 +- X2tConverter/src/ASCConverters.cpp | 26 ++-- 19 files changed, 134 insertions(+), 349 deletions(-) diff --git a/ASCOfficeDocFile/DocDocxConverter/Converter.cpp b/ASCOfficeDocFile/DocDocxConverter/Converter.cpp index 3715d76c64..33bf6f1ff1 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Converter.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/Converter.cpp @@ -61,7 +61,7 @@ namespace DocFileFormat namespace DocFileFormat { - _UINT32 Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress) + _UINT32 Converter::Convert(WordDocument* doc, WordprocessingDocument* docx) { if (!doc || !docx) return S_FALSE; @@ -81,21 +81,9 @@ namespace DocFileFormat } //write document.xml and the header and footers - MainDocumentMapping mainDocMapping( &context, progress ); + MainDocumentMapping mainDocMapping( &context); doc->Convert( &mainDocMapping ); - if ( progress != NULL ) - { - progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 810000 ); - - short cancel = 0; - progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 810000, &cancel ); - - if ( cancel != 0 ) - { - return S_FALSE; - } - } //Write numbering.xml if (doc->listTable) { @@ -103,129 +91,43 @@ namespace DocFileFormat doc->listTable->Convert( &numberingMapping ); } - if ( progress != NULL ) - { - progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 850000 ); - - short cancel = 0; - progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 850000, &cancel ); - - if ( cancel != 0 ) - { - return S_FALSE; - } - } - if ( progress != NULL ) - { - progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 875000 ); - - short cancel = 0; - progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 875000, &cancel ); - - if ( cancel != 0 ) - { - return S_FALSE; - } - } //write the footnotes FootnotesMapping footnotesMapping( &context ); doc->Convert( &footnotesMapping ); - if ( progress != NULL ) - { - progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 900000 ); - - short cancel = 0; - progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 900000, &cancel ); - - if ( cancel != 0 ) - { - return S_FALSE; - } - } - //write the endnotes EndnotesMapping endnotesMapping( &context ); doc->Convert( &endnotesMapping ); - if ( progress != NULL ) - { - progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 925000 ); - - short cancel = 0; - progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 925000, &cancel ); - - if ( cancel != 0 ) - { - return S_FALSE; - } - } - //write the comments CommentsMapping commentsMapping( &context ); doc->Convert( &commentsMapping ); - if ( progress != NULL ) - { - progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 950000 ); - - short cancel = 0; - progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 950000, &cancel ); - - if ( cancel != 0 ) - { - return S_FALSE; - } - } - //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 ); - - short cancel = 0; - progress->OnProgressEx( progress->caller, DOC_ONPROGRESSEVENT_ID, 975000, &cancel ); - - if ( cancel != 0 ) - { - return S_FALSE; - } - } return S_OK; } - _UINT32 Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros) + _UINT32 Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, bool &bMacros) { - WordDocument doc(progress, m_sTempFolder, m_nUserLCID); + WordDocument doc(m_sTempFolder, m_nUserLCID); WordprocessingDocument docx(strDstDirectory, &doc); _UINT32 result = doc.LoadDocument(strSrcFile, password); if (result == 0) { - result = Convert(&doc, &docx, progress); + result = Convert(&doc, &docx); if (result == 0) { - docx.SaveDocument(bMacros); - - if (progress)progress->OnProgress(progress->caller, DOC_ONPROGRESSEVENT_ID, 1000000); - - short cancel = 0; - if (progress)progress->OnProgressEx(progress->caller, DOC_ONPROGRESSEVENT_ID, 1000000, &cancel); - - if (0 != cancel) - { - return S_FALSE; - } + result = docx.SaveDocument(bMacros); } } diff --git a/ASCOfficeDocFile/DocDocxConverter/Converter.h b/ASCOfficeDocFile/DocDocxConverter/Converter.h index d42bb1efbf..d0400b18a0 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Converter.h +++ b/ASCOfficeDocFile/DocDocxConverter/Converter.h @@ -34,8 +34,6 @@ #include #include "../../Common/DocxFormat/Source/Base/Types_32.h" -struct ProgressCallback; - namespace DocFileFormat { class WordDocument; @@ -50,9 +48,9 @@ namespace DocFileFormat std::wstring m_sTempFolder; int m_nUserLCID; - _UINT32 LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress, bool &bMacros); + _UINT32 LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, bool &bMacros); private: - _UINT32 Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress); + _UINT32 Convert(WordDocument* doc, WordprocessingDocument* docx); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp index 7234ced61b..0f158f6d64 100644 --- a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp @@ -34,9 +34,8 @@ namespace DocFileFormat { - MainDocumentMapping::MainDocumentMapping (ConversionContext* ctx, const ProgressCallback* ffCallBack) : DocumentMapping( ctx, this ), m_ffCallBack(NULL) + MainDocumentMapping::MainDocumentMapping (ConversionContext* ctx) : DocumentMapping( ctx, this ) { - m_ffCallBack = ffCallBack; } MainDocumentMapping::~MainDocumentMapping() @@ -168,24 +167,6 @@ namespace DocFileFormat cp = m_document->FIB->m_RgLw97.ccpText; } - - if (m_ffCallBack) - { - if (( (unsigned int) cp > (progressStep * index) ) && (m_ffCallBack)) - { - double progress = ( double( 800000 - 500000 ) / m_document->FIB->m_RgLw97.ccpText * cp ); - - m_ffCallBack->OnProgress (m_ffCallBack->caller, DOC_ONPROGRESSEVENT_ID, long( 500000 + progress )); - - short bCancel = 0; - m_ffCallBack->OnProgressEx (m_ffCallBack->caller, DOC_ONPROGRESSEVENT_ID, long( 500000 + progress ), &bCancel); - - if (0 != bCancel) - return; - - ++index; - } - } } //write the section properties of the body with the last SEPX diff --git a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.h b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.h index 1b91bf8660..a6be80ef82 100644 --- a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.h @@ -41,12 +41,9 @@ namespace DocFileFormat class MainDocumentMapping : public DocumentMapping { public: - MainDocumentMapping (ConversionContext* ctx, const ProgressCallback* ffCallBack); + MainDocumentMapping (ConversionContext* ctx); virtual ~MainDocumentMapping(); + virtual void Apply (IVisitable* visited); - - private: - - const ProgressCallback* m_ffCallBack; }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h b/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h index 0944f96cd4..1ce2e44d8d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h @@ -114,7 +114,7 @@ namespace DocFileFormat TC80 oTC80; oTC80.ftsWidth = Global::dxa; - oTC80.wWidth = 3190; + oTC80.wWidth = 0; oTC80.brcTop = new BorderCode(); oTC80.brcLeft = new BorderCode(); diff --git a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp index 781698ab72..4c1a7b03b0 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp @@ -111,6 +111,18 @@ namespace DocFileFormat bPresentDefTable = true; SprmTDefTable tdef(iter->Arguments, iter->argumentsSize); + + bool bUseWidth = true; + + for (size_t j = 0; j < tdef.rgTc80.size(); ++j) + { // 1bc0f6c0-b226-4bcb-912c-e7f97b009d8a.doc + // Технические_Требования_1_287_ДИТ.DOC + if (tdef.rgTc80[j].horzMerge == 0 && tdef.rgTc80[j].wWidth < 1) + { + bUseWidth = false; + break; + } + } int cc = tdef.numberOfColumns; _tGrid = tdef.rgdxaCenter; @@ -172,9 +184,8 @@ namespace DocFileFormat _gridSpan = 1; nComputedCellWidths += (tdef.rgdxaCenter[ _cellIndex + 1] - tdef.rgdxaCenter[ 0 ]); - nComputedCellWidth += /*tdef.rgTc80[ _cellIndex].wWidth > 1 ? tdef.rgTc80[ _cellIndex].wWidth :*/ // 1bc0f6c0-b226-4bcb-912c-e7f97b009d8a.doc + nComputedCellWidth += bUseWidth ? tdef.rgTc80[ _cellIndex].wWidth : (tdef.rgdxaCenter[ _cellIndex + 1] - tdef.rgdxaCenter[ _cellIndex ]); - //Технические_Требования_1_287_ДИТ.DOC } if (!IsTableBordersDefined(tapx->grpprl)) diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp index b8a9c45501..1e17518a45 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp @@ -84,9 +84,7 @@ namespace DocFileFormat case sprmTDxaGapHalf: { gabHalf = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ); - } - break; - + }break; case sprmOldTDefTable: case sprmTDefTable: { @@ -101,9 +99,7 @@ namespace DocFileFormat //If there follows a real sprmTWidthIndent, this value will be overwritten //tblIndent = (std::max)((int)tblIndent,0); //cerere.doc - } - break; - + }break; case sprmTTableWidth: { //preferred table width @@ -121,8 +117,7 @@ namespace DocFileFormat _tblPr->AppendChild( tblW ); bTableW = true; - } - break; + }break; case sprmTMerge: { itcFirst = iter->Arguments[0]; @@ -135,23 +130,19 @@ namespace DocFileFormat case sprmOldTJc: case sprmTJc: case sprmTJcRow: - { //justification + { appendValueElement( _tblPr, L"jc" , FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ), true ); - } - break; - + }break; case sprmTWidthIndent: - { //indent + { tblIndent = FtsWWidth_Indent(iter->Arguments).wWidth; // tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize ); - } - break; - + }break; case sprmTIstd: case sprmTIstdPermute: - { //style + { if ( _isTableStyleNeeded ) { @@ -164,28 +155,21 @@ namespace DocFileFormat appendValueElement( _tblPr, L"tblStyle", id, true ); } } - } - break; - + }break; case sprmTFBiDi: case sprmTFBiDi90: - { //bidi + { appendValueElement( _tblPr, L"bidiVisual", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), true ); - } - break; - + }break; case sprmOldTTlp: case sprmTTlp: - { //table look + { appendValueElement( _tblPr, L"tblLook", FormatUtils::IntToFormattedWideString( FormatUtils::BytesToInt16( iter->Arguments, 2, iter->argumentsSize ), L"%04x" ), true ); - } - break; + }break; case sprmTFAutofit: - {//autofit - - layoutType.SetValue(L"fixed"); + { if ( iter->Arguments[0] == 1 ) { layoutType.SetValue( L"auto" ); @@ -219,48 +203,36 @@ namespace DocFileFormat { marginRight = wMar; } - } - break; - - case sprmTCHorzBands: - { //row count + }break; + case sprmTCHorzBands: + { appendValueElement( _tblPr, L"tblStyleRowBandSize", iter->Arguments[0], true ); - } - break; - + }break; case sprmTCVertBands: - { //col count + { appendValueElement( _tblPr, L"tblStyleColBandSize", iter->Arguments[0], true ); - } - break; - + }break; case sprmTFNoAllowOverlap: - { //overlap - - std::wstring tblOverlapVal = std::wstring( L"overlap"); + { + std::wstring tblOverlapVal(L"overlap"); if ( iter->Arguments[0] ) { - tblOverlapVal = std::wstring( L"never"); + tblOverlapVal = L"never"; } appendValueElement( _tblPr, L"tblOverlap", tblOverlapVal, true ); - } - break; - + }break; case sprmOldTSetShd : case sprmTSetShdTable : - { //shading + { appendShading( _tblPr, ShadingDescriptor( iter->Arguments, iter->argumentsSize ) ); - } - break; - + }break; case sprmTTableBorders80: - { //borders 80 exceptions - + { const int size = 4; unsigned char brc80[size]; @@ -293,10 +265,7 @@ namespace DocFileFormat memcpy( brc80, ( iter->Arguments + 20 ), size ); RELEASEOBJECT( brcVert ); brcVert = new BorderCode( brc80, size ); - } - break; - - //border exceptions + }break; case sprmOldTTableBorders: case sprmTTableBorders: { @@ -332,10 +301,7 @@ namespace DocFileFormat memcpy( brc, ( iter->Arguments + 40 ), size ); RELEASEOBJECT( brcVert ); brcVert = new BorderCode( brc, size ); - } - break; - - //floating table properties + }break; case sprmTPc: { unsigned char flag = ( iter->Arguments[0] & 0x30 ) >> 4; @@ -345,44 +311,31 @@ namespace DocFileFormat flag = ( iter->Arguments[0] & 0xC0 ) >> 6; appendValueAttribute( &tblpPr, L"w:horzAnchor", FormatUtils::MapValueToWideString( flag, &Global::HorizontalPositionCode[0][0], 4, 7 ) ); - } - break; - + }break; case sprmTDxaFromText: { appendValueAttribute( &tblpPr, L"w:leftFromText", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); - } - break; - + }break; case sprmTDxaFromTextRight: { appendValueAttribute( &tblpPr, L"w:rightFromText", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); - } - break; - + }break; case sprmTDyaFromText: { appendValueAttribute( &tblpPr, L"w:topFromText", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); - } - break; - + }break; case sprmTDyaFromTextBottom: { appendValueAttribute( &tblpPr, L"w:bottomFromText", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); - } - break; - + }break; case sprmTDxaAbs: { appendValueAttribute( &tblpPr, L"w:tblpX", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); - } - break; - + }break; case sprmTDyaAbs: { appendValueAttribute( &tblpPr, L"w:tblpY", FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ); - } - break; + }break; } } if (false == bTableW) diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp index 04a6f6faeb..fb2aecc025 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp @@ -565,6 +565,7 @@ namespace DocFileFormat case ODRAW::fillFocus: { appendValueAttribute(&m_fill, L"focus", (FormatUtils::IntToWideString(iter->op) + L"%")); + appendValueAttribute(&m_fill, L"focusposition", L".5, .5"); appendValueAttribute(&m_fill, L"focussize", L""); }break; case ODRAW::fillType: @@ -602,12 +603,14 @@ namespace DocFileFormat }break; case ODRAW::fillOpacity: { - appendValueAttribute(&m_fill, L"opacity", (FormatUtils::IntToWideString(iter->op) + L"f")); + double opa = (iter->op / pow((double)2, (double)16)); + appendValueAttribute(&m_fill, L"opacity", FormatUtils::DoubleToFormattedWideString(opa, L"%.2f")); } break; case ODRAW::fillBackOpacity: { - appendValueAttribute(&m_fill, L"o:opacity2", (FormatUtils::IntToWideString(iter->op) + L"f")); + double opa = (iter->op / pow((double)2, (double)16)); + appendValueAttribute(&m_fill, L"o:opacity2", FormatUtils::DoubleToFormattedWideString(opa, L"%.2f")); }break; // SHADOW case ODRAW::shadowType: @@ -652,8 +655,14 @@ namespace DocFileFormat }break; case ODRAW::shadowStyleBooleanProperties: { - //ODRAW::ShadowStyleBooleanProperties - + ODRAW::ShadowStyleBooleanProperties* booleans = dynamic_cast(iter.get()); + if (booleans) + { + if (booleans->fUsefShadow && booleans->fShadow) + { + bShadow = true; + } + } }break; // OLE case ODRAW::pictureId: @@ -1020,13 +1029,6 @@ namespace DocFileFormat appendValueAttribute(&m_shadow, L"origin", FormatUtils::DoubleToWideString(*ShadowOriginX) + std::wstring(L"," ) + FormatUtils::DoubleToWideString(*ShadowOriginY)); } -// write shadow - if (m_shadow.GetAttributeCount() > 0) - { - appendValueAttribute(&m_shadow, L"on", bShadow ? L"t" : L"f" ); - m_pXmlWriter->WriteString(m_shadow.GetXMLString()); - } - //write the viewpoint if ( ViewPointX || ViewPointY || ViewPointZ ) { @@ -1095,6 +1097,13 @@ namespace DocFileFormat { m_pXmlWriter->WriteString(m_fill.GetXMLString()); } + +// write shadow + if (m_shadow.GetAttributeCount() > 0) + { + appendValueAttribute(&m_shadow, L"on", bShadow ? L"t" : L"f"); + m_pXmlWriter->WriteString(m_shadow.GetXMLString()); + } // write imagedata if (m_imagedata.GetAttributeCount()) { @@ -2029,8 +2038,12 @@ namespace DocFileFormat std::wstring result; for (size_t i = 0; i < pColors->complex.data.size(); ++i) { - result += FormatUtils::IntToWideString((int)pColors->complex.data[i].dPosition); - result += L"f #"; + if (pColors->complex.data[i].position.Fractional == 0) + result += FormatUtils::IntToWideString(pColors->complex.data[i].position.Integral); + else + result += FormatUtils::IntToWideString(pColors->complex.data[i].position.Fractional) +L"f"; + + result += L" #"; result += pColors->complex.data[i].color.sColorRGB; result += L";"; } diff --git a/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp b/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp index 3d37195bc6..1eb9120177 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp @@ -80,7 +80,7 @@ namespace DocFileFormat 254, 437,//PC 437 255, 850//OEM }; - WordDocument::WordDocument (const ProgressCallback* pCallFunc, const std::wstring & sTempFolder, const int userLCID) : + WordDocument::WordDocument (const std::wstring & sTempFolder, const int userLCID) : m_PieceTable(NULL), WordDocumentStream(NULL), TableStream(NULL), DataStream(NULL), FIB(NULL), Text(NULL), RevisionAuthorTable(NULL), FontTable(NULL), BookmarkNames(NULL), AutoTextNames(NULL), IndividualFootnotesPlex(NULL), FootnoteReferenceCharactersPlex(NULL), IndividualEndnotesPlex(NULL), @@ -93,7 +93,6 @@ namespace DocFileFormat AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL), AnnotStartPlex(NULL), AnnotEndPlex(NULL), encryptionHeader(NULL) { - m_pCallFunc = pCallFunc; m_sTempFolder = sTempFolder; m_nUserLCID = userLCID; @@ -315,21 +314,7 @@ namespace DocFileFormat BookmarkAnnotNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfAtnBkmk, FIB->m_FibWord97.lcbSttbfAtnBkmk, nWordVersion, true); - if (m_pCallFunc) - { - m_pCallFunc->OnProgress (m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 100000); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 100000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - - // Read all needed PLCFs + // Read all needed PLCFs if (FIB->m_RgLw97.ccpFtn > 0) { FootnoteReferenceCharactersPlex = new Plex(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, nWordVersion); @@ -422,20 +407,6 @@ namespace DocFileFormat ListPlex = new Plex (ListNumCache::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBteLvc, FIB->m_FibWord97.lcbPlcfBteLvc, nWordVersion); - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - // Read the FKPs AllPapxFkps = FormattedDiskPagePAPX::GetAllPAPXFKPs (FIB, WordDocumentStream, TableStream, DataStream); AllChpxFkps = FormattedDiskPageCHPX::GetAllCHPXFKPs (FIB, WordDocumentStream, TableStream); @@ -452,19 +423,6 @@ namespace DocFileFormat AnnotationOwners = new AnnotationOwnerList (FIB, TableStream); } - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 300000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 300000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } if (FontTable) { std::unordered_map fonts_charsets; @@ -556,20 +514,6 @@ namespace DocFileFormat std::sort (AllPapxVector->begin(), AllPapxVector->end()); - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 400000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 400000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - //build a dictionary of all SEPX if ( !SectionPlex->Elements.empty() ) { @@ -594,20 +538,6 @@ namespace DocFileFormat } } - if (m_pCallFunc) - { - m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 500000 ); - - SHORT bCancel = 0; - m_pCallFunc->OnProgressEx(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 500000, &bCancel); - - if (bCancel) - { - Clear(); - return AVS_ERROR_FILEFORMAT; - } - } - return 0; } bool WordDocument::LoadDocumentFlat() diff --git a/ASCOfficeDocFile/DocDocxConverter/WordDocument.h b/ASCOfficeDocFile/DocDocxConverter/WordDocument.h index be5cd5556d..fd1b3515f5 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordDocument.h +++ b/ASCOfficeDocFile/DocDocxConverter/WordDocument.h @@ -58,7 +58,6 @@ #include "EndnoteDescriptor.h" #include "FieldCharacter.h" #include "IVisitable.h" -#include "../Common/Callback.h" namespace CRYPT { @@ -92,7 +91,7 @@ namespace DocFileFormat public: - WordDocument (const ProgressCallback* pCallFunc, const std::wstring & tempFolder, const int userLCID); + WordDocument (const std::wstring & tempFolder, const int userLCID); virtual ~WordDocument(); _UINT32 LoadDocument(const std::wstring & fileName, const std::wstring & password); @@ -155,8 +154,6 @@ namespace DocFileFormat std::wstring m_sTempDecryptFileName; int m_nUserLCID; - const ProgressCallback* m_pCallFunc; - POLE::Stream * WordDocumentStream; // The stream "WordDocument" POLE::Stream * TableStream; // The stream "0Table" or "1Table" POLE::Stream * DataStream; // The stream called "Data" diff --git a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp index 67fcf618f8..32a28d50df 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp @@ -51,7 +51,7 @@ namespace DocFileFormat { } - void WordprocessingDocument::SaveDocument(bool &bMacros) + _UINT32 WordprocessingDocument::SaveDocument(bool &bMacros) { std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ; NSDirectory::CreateDirectory( pathWord ); @@ -179,5 +179,6 @@ namespace DocFileFormat { SaveToFile(pathWord, ( std::wstring( L"footer" ) + FormatUtils::IntToWideString(++footersCount) + std::wstring( L".xml" ) ), *iter); } + return 0; } } diff --git a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h index e8ca077310..3d912e1cc6 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h +++ b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h @@ -79,6 +79,6 @@ namespace DocFileFormat WordprocessingDocument(const std::wstring & _docxDirectory, const WordDocument* _docFile); virtual ~WordprocessingDocument(); - void SaveDocument(bool &bMacros); + _UINT32 SaveDocument(bool &bMacros); }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp index 5a593b3e38..cff1633292 100644 --- a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp +++ b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.cpp @@ -34,7 +34,7 @@ #include "../DocDocxConverter/Converter.h" #include "../../OfficeUtils/src/OfficeUtils.h" -_UINT32 COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack) +_UINT32 COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros) { _UINT32 hr = 0; @@ -43,12 +43,12 @@ _UINT32 COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::w docToDocx.m_sTempFolder = m_sTempFolder; docToDocx.m_nUserLCID = m_nUserLCID; - hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack, bMacros); + hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, bMacros); return hr; } -_UINT32 COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack ) +_UINT32 COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName) { return 0; } diff --git a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h index a6b1e3d9d7..d3e36ede2f 100644 --- a/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h +++ b/ASCOfficeDocFile/DocFormatLib/DocFormatLib.h @@ -29,8 +29,7 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -#ifndef DOC_FORMAT_LIB -#define DOC_FORMAT_LIB +#pragma once #if defined(_WIN32) || defined(_WIN64) #include @@ -38,8 +37,6 @@ #include "../../DesktopEditor/common/ASCVariant.h" -struct ProgressCallback; - class COfficeDocFile { public: @@ -49,9 +46,8 @@ public: std::wstring m_sTempFolder; int m_nUserLCID; - _UINT32 LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack = NULL); - _UINT32 SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack = NULL); + _UINT32 LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, bool &bMacros); + _UINT32 SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName); }; -#endif //DOC_FORMAT_LIB diff --git a/Common/3dParty/cryptopp/cryptlib.vcxproj b/Common/3dParty/cryptopp/cryptlib.vcxproj index 550b86904f..f812298ece 100644 --- a/Common/3dParty/cryptopp/cryptlib.vcxproj +++ b/Common/3dParty/cryptopp/cryptlib.vcxproj @@ -124,7 +124,7 @@ - <_ProjectFileVersion>14.0.23107.0 + <_ProjectFileVersion>14.0.25431.1 $(Platform)\Output\$(Configuration)\ @@ -145,8 +145,6 @@ $(Platform)\Output\$(Configuration)\ $(Platform)\$(ProjectName)\$(Configuration)\ - D:\_Work\core\Common\3dParty\boost\build\win_32\include;$(IncludePath) - D:\_Work\core\Common\3dParty\boost\build\win_32\lib;$(LibraryPath) $(Platform)\Output\$(Configuration)\ @@ -287,8 +285,7 @@ true _DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32;%(PreprocessorDefinitions) MultiThreadedDebugDLL - - + Use pch.h $(OutDir)vc80.pdb Level4 diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index aceed22fd0..0245a82fee 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -70,6 +70,12 @@ bool COfficeFileFormatChecker::isHtmlFormatFile(unsigned char* pBuffer, int dwBy { return true; } + else if ((0x3C == pBuffer[i]) && (0x2F == pBuffer[i + 1]) && (0x62 == pBuffer[i + 2]) + && (0x6f == pBuffer[i + 3]) && (0x64 == pBuffer[i + 4]) && (0x79 == pBuffer[i + 5]) + && (0x3e == pBuffer[i + 6])) + {// + return true; + } } } else if (dwBytes > 3) diff --git a/OfficeCryptReader/Test/Test.sln b/OfficeCryptReader/Test/Test.sln index e46a2f5707..3792276fd5 100644 --- a/OfficeCryptReader/Test/Test.sln +++ b/OfficeCryptReader/Test/Test.sln @@ -1,17 +1,13 @@  -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{BE4AA52B-8AF0-48DD-8240-CCBA6F84D7A2}" - ProjectSection(ProjectDependencies) = postProject - {C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C} - EndProjectSection +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcxproj", "{BE4AA52B-8AF0-48DD-8240-CCBA6F84D7A2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeFileCrypt", "..\win32\ECMACryptReader.vcproj", "{C27E9A9F-3A17-4482-9C5F-BF15C01E747C}" - ProjectSection(ProjectDependencies) = postProject - {3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeFileCrypt", "..\win32\ECMACryptReader.vcxproj", "{C27E9A9F-3A17-4482-9C5F-BF15C01E747C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptlib", "..\..\Common\3dParty\cryptopp\cryptlib.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptlib", "..\..\Common\3dParty\cryptopp\cryptlib.vcxproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/OfficeCryptReader/win32/ECMACryptReader.vcxproj b/OfficeCryptReader/win32/ECMACryptReader.vcxproj index 80a00823b3..eb058a6764 100644 --- a/OfficeCryptReader/win32/ECMACryptReader.vcxproj +++ b/OfficeCryptReader/win32/ECMACryptReader.vcxproj @@ -64,7 +64,7 @@ - <_ProjectFileVersion>14.0.23107.0 + <_ProjectFileVersion>14.0.25431.1 $(SolutionDir)$(Configuration)\ @@ -75,8 +75,6 @@ $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ - $(VC_IncludePath);$(WindowsSDK_IncludePath);D:\_Work\core\Common\3dParty\boost\build\win_64\include; - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\_Work\core\Common\3dParty\boost\build\win_64\lib; $(SolutionDir)$(Configuration)\ @@ -107,7 +105,7 @@ Disabled - WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -148,6 +146,7 @@ {3423ec9a-52e4-4a4d-9753-edebc38785ef} + false diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index 70b05a85d0..cbcaa01a45 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -2336,6 +2336,7 @@ namespace NExtractTools RtfConvertationManager rtfConvert; rtfConvert.m_sTempFolder = sTemp; + rtfConvert.m_nUserLCID = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; if ( rtfConvert.ConvertRtfToOOX(sFrom, sResultDocxDir) == 0) { @@ -2371,6 +2372,7 @@ namespace NExtractTools RtfConvertationManager rtfConvert; rtfConvert.m_sTempFolder = sTemp; + rtfConvert.m_nUserLCID = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; if (rtfConvert.ConvertOOXToRtf(sTo, sDocxDir) == 0) return 0; @@ -2414,7 +2416,7 @@ namespace NExtractTools params.m_bMacro = false; - _UINT32 hRes = docFile.LoadFromFile( sFrom, sTo, params.getPassword(), params.m_bMacro, NULL); + _UINT32 hRes = docFile.LoadFromFile( sFrom, sTo, params.getPassword(), params.m_bMacro); if (AVS_ERROR_DRM == hRes) { if(!params.getDontSaveAdditional()) @@ -2462,10 +2464,11 @@ namespace NExtractTools { COfficeDocFile docFile; docFile.m_sTempFolder = sTemp; - + docFile.m_nUserLCID = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; + params.m_bMacro = true; - _UINT32 hRes = docFile.LoadFromFile( sFrom, sTo, params.getPassword(), params.m_bMacro, NULL); + _UINT32 hRes = docFile.LoadFromFile( sFrom, sTo, params.getPassword(), params.m_bMacro); if (AVS_ERROR_DRM == hRes) { if(!params.getDontSaveAdditional()) @@ -2510,10 +2513,11 @@ namespace NExtractTools COfficeDocFile docFile; docFile.m_sTempFolder = sTemp; + docFile.m_nUserLCID = (NULL != params.m_nLcid) ? *params.m_nLcid : -1;; params.m_bMacro = true; - _UINT32 nRes = docFile.LoadFromFile( sFrom, sResultDocxDir, params.getPassword(), params.m_bMacro, NULL); + _UINT32 nRes = docFile.LoadFromFile( sFrom, sResultDocxDir, params.getPassword(), params.m_bMacro); nRes = processEncryptionError(nRes, sFrom, params); if (SUCCEEDED_X2T(nRes)) @@ -2533,8 +2537,6 @@ namespace NExtractTools _UINT32 docx_dir2doc (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { return AVS_FILEUTILS_ERROR_CONVERT; - COfficeDocFile docFile; - return /*S_OK == docFile.SaveToFile(sTo, sDocxDir, NULL) ? 0 : */AVS_FILEUTILS_ERROR_CONVERT; } // doct -> rtf @@ -2587,7 +2589,8 @@ namespace NExtractTools //docx folder to rtf RtfConvertationManager rtfConvert; - rtfConvert.m_sTempFolder = sTemp; + rtfConvert.m_sTempFolder = sTemp; + rtfConvert.m_nUserLCID = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; nRes = rtfConvert.ConvertOOXToRtf(sTo, sResultDocxDir); } @@ -4400,8 +4403,10 @@ namespace NExtractTools _UINT32 xls2xlsm_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { params.m_bMacro = true; + + int lcid = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; - _UINT32 nRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, NULL, params.m_bMacro); + _UINT32 nRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, lcid, params.m_bMacro); nRes = processEncryptionError(nRes, sFrom, params); return nRes; @@ -4434,7 +4439,10 @@ namespace NExtractTools NSDirectory::CreateDirectory(sResultXlsxDir); params.m_bMacro = true; - _UINT32 nRes = ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), sTemp, NULL, params.m_bMacro); + + int lcid = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; + + _UINT32 nRes = ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), sTemp, lcid, params.m_bMacro); nRes = processEncryptionError(nRes, sFrom, params); if (SUCCEEDED_X2T(nRes))