This commit is contained in:
Elena.Subbotina
2021-10-07 19:08:05 +03:00
parent 19420e98d4
commit 8c212908bd
19 changed files with 134 additions and 349 deletions

View File

@ -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);
}
}

View File

@ -34,8 +34,6 @@
#include <string>
#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);
};
}

View File

@ -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

View File

@ -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;
};
}

View File

@ -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();

View File

@ -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))

View File

@ -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)

View File

@ -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<ODRAW::ShadowStyleBooleanProperties*>(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";";
}

View File

@ -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<WideString> (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>(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, nWordVersion);
@ -422,20 +407,6 @@ namespace DocFileFormat
ListPlex = new Plex<ListNumCache> (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<int, int> 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()

View File

@ -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"

View File

@ -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;
}
}

View File

@ -79,6 +79,6 @@ namespace DocFileFormat
WordprocessingDocument(const std::wstring & _docxDirectory, const WordDocument* _docFile);
virtual ~WordprocessingDocument();
void SaveDocument(bool &bMacros);
_UINT32 SaveDocument(bool &bMacros);
};
}

View File

@ -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;
}

View File

@ -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 <windows.h>
@ -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

View File

@ -124,7 +124,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>14.0.23107.0</_ProjectFileVersion>
<_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(Platform)\Output\$(Configuration)\</OutDir>
@ -145,8 +145,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(Platform)\Output\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
<IncludePath>D:\_Work\core\Common\3dParty\boost\build\win_32\include;$(IncludePath)</IncludePath>
<LibraryPath>D:\_Work\core\Common\3dParty\boost\build\win_32\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(Platform)\Output\$(Configuration)\</OutDir>
@ -287,8 +285,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;USE_PRECOMPILED_HEADERS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<ProgramDataBaseFileName>$(OutDir)vc80.pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>

View File

@ -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]))
{//</body>
return true;
}
}
}
else if (dwBytes > 3)

View File

@ -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

View File

@ -64,7 +64,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>14.0.23107.0</_ProjectFileVersion>
<_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
@ -75,8 +75,6 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);D:\_Work\core\Common\3dParty\boost\build\win_64\include;</IncludePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;D:\_Work\core\Common\3dParty\boost\build\win_64\lib;</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
@ -107,7 +105,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;DONT_WRITE_EMBEDDED_FONTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -148,6 +146,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Common\3dParty\cryptopp\cryptlib.vcxproj">
<Project>{3423ec9a-52e4-4a4d-9753-edebc38785ef}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -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))