Compare commits

...

16 Commits

Author SHA1 Message Date
187bf8823a x2t - version up 2018-06-21 11:28:58 +03:00
cd7c85967c Merge remote-tracking branch 'origin/hotfix/v5.1.5' into develop 2018-06-21 11:19:45 +03:00
045b00ad5a x2t - version up 2018-06-21 11:17:42 +03:00
9b5784e344 . 2018-06-20 19:37:32 +03:00
2b6650dde1 Merge remote-tracking branch 'origin/hotfix/v5.1.5' into develop 2018-06-20 18:56:53 +03:00
ff8ecb2d2f RtfFormat - fix users files 2018-06-20 18:54:06 +03:00
5893b93e3a XlsFormatFile - fix users files 2018-06-19 13:48:57 +03:00
c462f522d6 x2t - fix bugs #37945, #37946 2018-06-18 15:57:38 +03:00
678ec98721 . 2018-06-18 13:34:40 +03:00
c17fa8462d x2t - add document ID for crypt ooxml 2018-06-18 13:24:59 +03:00
04eda04870 Add StopNoJoin method to BaseThread 2018-06-15 11:46:21 +03:00
0295ef2d54 RtfFormatReader - fix bug #37902 2018-06-07 18:01:45 +03:00
797b745b35 [s2t] Fix open file with unknown picture format
As result, different file names were obtained in binary and file system
2018-06-07 14:42:45 +03:00
37c276b736 [x2t] Fix bug #37892 2018-06-04 18:46:13 +03:00
41ea42459a . 2018-06-01 19:23:56 +03:00
bc68323506 . 2018-06-01 19:20:35 +03:00
35 changed files with 473 additions and 157 deletions

View File

@ -1639,11 +1639,8 @@ std::wostream & bibliography_mark::text_to_stream(std::wostream & _Wostream) con
CP_SERIALIZE_TEXT(content_);
return _Wostream;
}
void bibliography_mark::docx_convert(oox::docx_conversion_context & Context)
void bibliography_mark::serialize(std::wostream & strm)
{
std::wstringstream strm;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"b:Tag")
@ -1706,14 +1703,117 @@ void bibliography_mark::docx_convert(oox::docx_conversion_context & Context)
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*url_);
}
}
if (note_)
{
CP_XML_NODE(L"b:Comments")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*note_);
}
}
if (chapter_)
{
CP_XML_NODE(L"b:ChapterNumber")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*chapter_);
}
}
if (journal_)
{
CP_XML_NODE(L"b:JournalName")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*journal_);
}
}
if (month_)
{
CP_XML_NODE(L"b:Month")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*month_);
}
}
if (pages_)
{
CP_XML_NODE(L"b:Pages")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*pages_);
}
}
if (publisher_)
{
CP_XML_NODE(L"b:Publisher")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*publisher_);
}
}
if (volume_)
{
CP_XML_NODE(L"b:Volume")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*volume_);
}
}
if (address_)
{
CP_XML_NODE(L"b:City")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*address_);
}
}
if (booktitle_)
{
CP_XML_NODE(L"b:BookTitle")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*booktitle_);
}
}
if (edition_)
{
CP_XML_NODE(L"b:Edition")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*edition_);
}
}
if (institution_)
{
CP_XML_NODE(L"b:Institution")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*institution_);
}
}
if (institution_)
{
CP_XML_NODE(L"b:Institution")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*institution_);
}
}
//isbn_;
//annote_;
//editor_;
//howpublished_;
//issn_;
//number_;
//organizations_;
//report_type_;
//school_;
//series_;
}
}
void bibliography_mark::docx_convert(oox::docx_conversion_context & Context)
{
std::wstringstream strm;
serialize(strm);
Context.add_bibliography_item(strm.str());
}
void bibliography_mark::pptx_convert(oox::pptx_conversion_context & Context)
{
if (content_)
content_->pptx_convert(Context);
std::wstringstream strm;
serialize(strm);
//if (content_)
// content_->pptx_convert(Context);
}
//-----------------------------------------------------------------------------------------------
// text:alphabetical-index-auto-mark-file

View File

@ -1262,6 +1262,8 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
void serialize(std::wostream & strm);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
std::wstring identifier_;

View File

@ -76,7 +76,8 @@ namespace NSShapeImageGen
itWMF = 3,
itEMF = 4,
itSVG = 5,
itMedia = 6
itMedia = 6,
itUnknown = 7
};
class CMediaInfo
@ -382,6 +383,10 @@ namespace NSShapeImageGen
//конвертация неудачная - берем оригинальный файл
OOX::CPath pathOriginal = strFileSrc;
//default is itJPG. set itUnknown to use original extension
oInfo.m_eType = itUnknown;
oInfo.m_sExt = pathOriginal.GetExtention();
std::wstring strSaveItem = oInfo.GetPathWithoutExtension();
strSaveItem = m_strDstMedia + FILE_SEPARATOR_STR + strSaveItem + pathOriginal.GetExtention();

View File

@ -983,22 +983,30 @@ public:
else
{
RtfShapePtr pNewShape ( new RtfShape() );
pNewShape->m_bInGroup = true;
pNewShape->m_bIsGroup = true;
pNewShape->m_nShapeType = 1;
RtfShapeGroupReader oShapeGroupReader ( *pNewShape );
StartSubReader( oShapeGroupReader, oDocument, oReader );
m_oShapeGroup.AddItem( pNewShape );
}
}
else if( "shp" == sCommand )
{
RtfShapePtr pNewShape ( new RtfShape() );
RtfShapePtr pNewShape ( new RtfShape() );
pNewShape->m_bInGroup = true;
RtfShapeReader oShapeReader( *pNewShape );
StartSubReader( oShapeReader, oDocument, oReader );
m_oShapeGroup.AddItem( pNewShape );
}
else
{
return RtfShapeReader::ExecuteCommand( oDocument, oReader, sCommand, hasParameter, parameter);
}
return true;
}
};

View File

@ -121,14 +121,27 @@ public:
std::wstring sFont;
std::wstring sTempFont;
bool bFont = false;
if( !sAscii.empty() )
{
bFont = true;
sFont = sAscii;
}
else if( !sAsciiTheme.empty() && !GetThemeFont(sAsciiTheme, *oParam.oReader).empty() )
{
bFont = true;
sFont = GetThemeFont(sAsciiTheme, *oParam.oReader);
}
else if( !sHAnsi.empty() )
{
bFont = true;
sFont = sHAnsi;
}
else if( !sHAnsiTheme.empty() && !GetThemeFont(sHAnsiTheme, *oParam.oReader).empty() )
{
bFont = true;
sFont = GetThemeFont(sHAnsiTheme, *oParam.oReader);
}
else if( !sCs.empty() )
sFont = sCs;
else if( !sCsTheme.empty() && !GetThemeFont(sCsTheme, *oParam.oReader).empty() )
@ -143,13 +156,18 @@ public:
{
RtfFont oCurFont;
if( true == oParam.oRtf->m_oFontTable.GetFont( sFont, oCurFont ) )
nFont = oCurFont.m_nID;
{
if (bFont)
nFont = oCurFont.m_nID;
}
else
{
oCurFont.m_sName = sFont;
nFont = oParam.oRtf->m_oFontTable.GetCount() + 1;
oCurFont.m_nID = nFont;
oCurFont.m_nID = oParam.oRtf->m_oFontTable.GetCount() + 1;
oParam.oRtf->m_oFontTable.AddItem( oCurFont );
if (bFont)
nFont = oCurFont.m_nID;
}
}
return true;

View File

@ -400,9 +400,9 @@ bool OOXParagraphReader::Parse3( ReaderParameter oParam , RtfParagraph& oOutputP
{
OOX::Logic::CSmartTag * pSmartTag = dynamic_cast<OOX::Logic::CSmartTag*>(m_ooxElement);
for (std::vector<OOX::WritingElement*>::iterator it = pSmartTag->m_arrItems.begin(); it != pSmartTag->m_arrItems.end(); ++it)
for (size_t i = 0; i < pSmartTag->m_arrItems.size(); ++i)
{
OOX::Logic::CRun * pRun = dynamic_cast<OOX::Logic::CRun*>(*it);
OOX::Logic::CRun * pRun = dynamic_cast<OOX::Logic::CRun*>(pSmartTag->m_arrItems[i]);
if (pRun == NULL) continue;
OOXRunReader oRunReader(pRun);

View File

@ -854,10 +854,14 @@ void OOXShapeReader::Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::L
}
if (oox_grad_fill->path->rect.IsInit())
{
pOutput->m_nFillToBottom = XmlUtils::GetInteger(oox_grad_fill->path->rect->b.get());
pOutput->m_nFillToTop = XmlUtils::GetInteger(oox_grad_fill->path->rect->t.get());
pOutput->m_nFillToRight = XmlUtils::GetInteger(oox_grad_fill->path->rect->r.get());
pOutput->m_nFillToLeft = XmlUtils::GetInteger(oox_grad_fill->path->rect->l.get());
if (oox_grad_fill->path->rect->b.IsInit())
pOutput->m_nFillToBottom = XmlUtils::GetInteger(oox_grad_fill->path->rect->b.get());
if (oox_grad_fill->path->rect->t.IsInit())
pOutput->m_nFillToTop = XmlUtils::GetInteger(oox_grad_fill->path->rect->t.get());
if (oox_grad_fill->path->rect->r.IsInit())
pOutput->m_nFillToRight = XmlUtils::GetInteger(oox_grad_fill->path->rect->r.get());
if (oox_grad_fill->path->rect->l.IsInit())
pOutput->m_nFillToLeft = XmlUtils::GetInteger(oox_grad_fill->path->rect->l.get());
}
}
@ -1348,7 +1352,7 @@ bool OOXShapeReader::ParsePic( ReaderParameter oParam, RtfShapePtr& pOutput)
Parse(oParam, pOutput, &ooxPic->blipFill);
if (pOutput->m_oPicture->m_sPicFilename.empty() && !ooxPic->blipFill.blip->oleFilepathImage.empty())
if (pOutput->m_oPicture->m_sPicFilename.empty() && (ooxPic->blipFill.blip.IsInit() && !ooxPic->blipFill.blip->oleFilepathImage.empty()))
{
pOutput->m_oPicture->eDataType = RtfPicture::dt_png;
pOutput->m_oPicture->m_sPicFilename = ooxPic->blipFill.blip->oleFilepathImage;
@ -1456,7 +1460,7 @@ bool OOXShapeReader::ParsePic( ReaderParameter oParam, RtfShapePtr& pOutput)
}
return true;
}
bool OOXShapeReader::Parse( ReaderParameter oParam, RtfShapePtr& pOutput)
bool OOXShapeReader::Parse( ReaderParameter oParam, RtfShapePtr& pOutput, bool bUsedType)
{
if (!m_vmlElement && !m_arrElement && !m_ooxShape) return false;
@ -1465,7 +1469,7 @@ bool OOXShapeReader::Parse( ReaderParameter oParam, RtfShapePtr& pOutput)
else
pOutput->m_nHeader = 0;
if (m_vmlElement || m_arrElement) return ParseVml(oParam , pOutput);
if (m_vmlElement || m_arrElement) return ParseVml(oParam , pOutput, bUsedType);
PPTX::Logic::Shape *ooxShape = dynamic_cast<PPTX::Logic::Shape*> (m_ooxShape);
// PPTX::Logic::CxnSp *cxnShape = dynamic_cast<PPTX::Logic::CxnSp*> (m_ooxShape);
@ -1549,7 +1553,7 @@ void OOXShapeReader::Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::L
}
}
bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput)
bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput, bool bUsedType)
{
if (m_vmlElement == NULL && m_arrElement) return false;
if (m_vmlElement == NULL ) return ParseVmlChild(oParam , pOutput);
@ -1582,9 +1586,7 @@ bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput)
oParam.oReader->m_mapShapeTypes.end())
{
oParam.oReader->m_mapShapeTypes.insert(oParam.oReader->m_mapShapeTypes.begin(),
std::pair<std::wstring, OOX::Vml::CShapeType*>(shape_type->m_sId.get(), shape_type));
return false;//add type, not add object
std::pair<std::wstring, OOX::Vml::CShapeType*>(shape_type->m_sId.get(), shape_type));
}
}
custom_path = shape_type->m_oPath.GetPointer();
@ -1593,6 +1595,8 @@ bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput)
Width = shape_type->m_oCoordOrigin->GetX();
Height = shape_type->m_oCoordOrigin->GetY();
}
if (false == bUsedType)
return false;//add type, not add object
}
if (OOX::Vml::CShape* shape = dynamic_cast<OOX::Vml::CShape*>(m_vmlElement))
{
@ -1611,7 +1615,7 @@ bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput)
if ( it != oParam.oReader->m_mapShapeTypes.end())
{
OOXShapeReader sub_reader(it->second);
sub_reader.Parse(oParam, pOutput);
sub_reader.Parse(oParam, pOutput, true);
}
if (pOutput->m_nShapeType == PROP_DEF)
{
@ -1644,6 +1648,17 @@ bool OOXShapeReader::ParseVml( ReaderParameter oParam , RtfShapePtr& pOutput)
else if (OOX::Vml::CLine* line = dynamic_cast<OOX::Vml::CLine*>(m_vmlElement))
{
pOutput->m_nShapeType = NSOfficeDrawing::sptLine;
double x1 = line->m_oFrom.GetX();
double y1 = line->m_oFrom.GetY();
double x2 = line->m_oTo.GetX();
double y2 = line->m_oTo.GetY();
Width = abs(x1-x2); Height = abs(y1-y2);
pOutput->m_nRelLeft = (std::min) (x1,x2);
pOutput->m_nRelRight = (std::max) (x1,x2);
pOutput->m_nRelTop = (std::min) (y1,y2);
pOutput->m_nRelBottom = (std::max) (y1,y2);
}
else if (OOX::Vml::CArc* arc = dynamic_cast<OOX::Vml::CArc*>(m_vmlElement))
{
@ -1771,7 +1786,7 @@ bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput)
pOutput->m_nZOrderRelative = 0;
pOutput->m_nWrapType = 3; //def
pOutput->m_nWrapType = 3; //def
if ( m_vmlGroup->m_oStyle.IsInit())
{
@ -1803,31 +1818,31 @@ bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput)
pOutput->m_nGroupBottom =(pOutput->m_nGroupTop != PROP_DEF ? pOutput->m_nGroupTop : 0) + m_vmlGroup->m_oCoordSize->GetY();
}
for (std::vector<OOX::WritingElement*>::iterator it = m_vmlGroup->m_arrItems.begin(); it != m_vmlGroup->m_arrItems.end(); ++it)
for (size_t i = 0; i < m_vmlGroup->m_arrItems.size(); ++i)
{
if (*it == NULL) continue;
if (m_vmlGroup->m_arrItems[i] == NULL) continue;
if ((*it)->getType() == OOX::et_v_group)
if (m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_group)
{
RtfShapePtr pNewShape( new RtfShape() );
OOXShapeGroupReader oShapeReader(dynamic_cast<OOX::Vml::CGroup*>(*it));
OOXShapeGroupReader oShapeReader(dynamic_cast<OOX::Vml::CGroup*>(m_vmlGroup->m_arrItems[i]));
if( true == oShapeReader.Parse( oParam, pNewShape ) )
pOutput->AddItem( pNewShape );
}
else if ( (*it)->getType() == OOX::et_v_arc ||
(*it)->getType() == OOX::et_v_line ||
(*it)->getType() == OOX::et_v_oval ||
(*it)->getType() == OOX::et_v_shape ||
(*it)->getType() == OOX::et_v_rect ||
(*it)->getType() == OOX::et_v_roundrect ||
(*it)->getType() == OOX::et_v_polyline ||
(*it)->getType() == OOX::et_v_shapetype)
else if ( m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_arc ||
m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_line ||
m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_oval ||
m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_shape ||
m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_rect ||
m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_roundrect ||
m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_polyline ||
m_vmlGroup->m_arrItems[i]->getType() == OOX::et_v_shapetype)
{
RtfShapePtr pNewShape ( new RtfShape() );//set type .. .todooo
OOXShapeReader oShapeReader(dynamic_cast<OOX::Vml::CVmlCommonElements*>(*it));
OOXShapeReader oShapeReader(dynamic_cast<OOX::Vml::CVmlCommonElements*>(m_vmlGroup->m_arrItems[i]));
pNewShape->m_bInGroup = true;
if( true == oShapeReader.Parse( oParam, pNewShape ) )

View File

@ -59,9 +59,9 @@ public:
static bool WriteDataToPicture( std::wstring sPath, RtfPicture& pOutput, std::wstring sTempPath = L"" );
bool Parse ( ReaderParameter oParam , RtfShapePtr& oOutput);
bool Parse ( ReaderParameter oParam , RtfShapePtr& oOutput, bool bUsedType = false);
bool ParseVml ( ReaderParameter oParam , RtfShapePtr& oOutput, bool bUsedType = false);
bool ParseVmlChild ( ReaderParameter oParam , RtfShapePtr& oOutput);
bool ParseVml ( ReaderParameter oParam , RtfShapePtr& oOutput);
bool ParseVmlObject ( ReaderParameter oParam , RtfShapePtr& oOutput);
static bool ParseVmlStyle(RtfShapePtr pShape, SimpleTypes::Vml::CCssProperty* prop);

View File

@ -235,19 +235,17 @@ std::wstring RtfChar::renderRtfText( std::wstring& sText, void* poDocument, int
unsigned char nCharCode = sTempAnsiChars[k];
bWriteUnicode = false;
if (nCharCode == 0x5c || nCharCode == 0x7b || nCharCode == 0x7d)
if (nCharCode == 0x5c || nCharCode == 0x7b || nCharCode == 0x7d ||
(0x00 <= nCharCode && nCharCode < 0x20) )
{
sResult += L"\\'" + XmlUtils::IntToString( nCharCode, L"%x");
} else if (0x00 <= nCharCode && nCharCode - 1 < 0x10)
{
sResult += L"\\'0" + XmlUtils::IntToString( nCharCode - 1, L"%x" );
} else if (0x10 <= nCharCode - 1 && nCharCode < 0x20)
{
sResult += L"\\'" + XmlUtils::IntToString(nCharCode - 1, L"%x" );
} else if ( 0x20 <= nCharCode && nCharCode < 0x80 )
sResult += L"\\'" + XmlUtils::IntToString( nCharCode, L"%02x");
}
else if ( 0x20 <= nCharCode && nCharCode < 0x80 )
{
sResult += nCharCode;
} else { // 0x80 <= nUnicode <= 0xff
}
else
{ // 0x80 <= nUnicode <= 0xff
sResult += L"\\'" + XmlUtils::IntToString(nCharCode, L"%x" );
}
}

View File

@ -87,7 +87,8 @@ std::wstring RtfParagraph::RenderToRtf(RenderParameter oRenderParameter)
std::wstring RtfParagraph::RenderToOOX(RenderParameter oRenderParameter)
{
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
std::wstring sResult ;
@ -139,7 +140,28 @@ std::wstring RtfParagraph::RenderToOOX(RenderParameter oRenderParameter)
sResult += L"><w:pPr>";
m_oProperty.m_bOldList = (NULL != m_oOldList);
sResult += m_oProperty.RenderToOOX(oRenderParameter);
bool bRenderProps = false;
if ( PROP_DEF != m_oProperty.m_nTableStyle && m_oProperty.m_bInTable > 0)
{
RtfStylePtr oCurStyle;
if( true == poRtfDocument->m_oStyleTable.GetStyle( m_oProperty.m_nTableStyle, oCurStyle ) )
{
RtfParagraphStyle* oCurParaStyle = dynamic_cast<RtfParagraphStyle*>(oCurStyle.get());
if (oCurParaStyle)
{
RtfParagraphProperty newProps;
newProps.Merge(oCurParaStyle->m_oParProp);
newProps.Merge(m_oProperty);
sResult += newProps.RenderToOOX(oRenderParameter);
bRenderProps = true;
}
}
}
if (false == bRenderProps)
sResult += m_oProperty.RenderToOOX(oRenderParameter);
if( NULL != m_oOldList )
{

View File

@ -38,6 +38,8 @@
#include "../../../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Core.h"
#include <boost/algorithm/string.hpp>
std::wstring RtfFont::RenderToRtf(RenderParameter oRenderParameter)
{
if ( IsValid() == false) return L"";
@ -1081,6 +1083,68 @@ std::wstring RtfListLevelProperty::RenderToRtf(RenderParameter oRenderParameter)
sResult += L"}";
return sResult;
}
std::wstring RtfListLevelProperty::GetLevelTextOOX()
{
std::wstring sResult = m_sText;
if ( sResult.length() > 0 )
{
size_t nLevelTextLength = sResult[0];
nLevelTextLength--;
for (int i = (int)m_sNumber.length() - 1; i >= 0; i-- )
{
int nReplaceNumber = m_sNumber[i];
nReplaceNumber--;
if ( nReplaceNumber >= 0 && nReplaceNumber < (int)sResult.length() )
{
int nLevel = sResult[ nReplaceNumber ];
if (nLevel > 11)
{//001.rtf
nReplaceNumber++;
nLevel = sResult[ nReplaceNumber];
}
std::wstring sExt = L"%" + std::to_wstring(nLevel);
sResult.erase( nReplaceNumber, 1 );
sResult.insert(sResult.begin() + nReplaceNumber, sExt.begin(), sExt.end());
nLevelTextLength += sExt.length() - 1;
}
}
sResult = sResult.substr(1);
if ( nLevelTextLength < sResult.length() )
sResult = sResult.substr(0, nLevelTextLength );
}
return XmlUtils::EncodeXmlString( sResult );
}
void RtfListLevelProperty::SetLevelTextOOX(std::wstring sText)
{
m_sText = L"";
m_sNumber = L"";
int nLevelOffsets = 0;
for (size_t i = 0; i < sText.length() ; i++ )
{
if ( (sText[i] == '%') && (i + 1 < sText.length()) && (isdigit( sText[ i + 1 ] )))
{
int nLevel = RtfUtility::ToByte( sText[ i + 1 ] );
wchar_t ch1 = nLevel - 1;
m_sText += ch1;
i++; //т.к. следующий симовл уже учли
wchar_t ch2 = nLevelOffsets + 1;
m_sNumber += ch2;
}
else
m_sText += sText[i];
nLevelOffsets++;
}
wchar_t ch = m_sText.length();
m_sText.insert(m_sText.begin() + 0, ch );
}
std::wstring RtfListLevelProperty::RenderToOOX(RenderParameter oRenderParameter)
{
return RenderToOOX2(oRenderParameter);

View File

@ -1415,66 +1415,8 @@ public:
return 0; //decimal
}
std::wstring GetLevelTextOOX()
{
std::wstring sResult = m_sText;
if ( sResult.length() > 0 )
{
size_t nLevelTextLength = sResult[0];
nLevelTextLength--;
for (int i = (int)m_sNumber.length() - 1; i >= 0; i-- )
{
int nReplaceNumber = m_sNumber[i];
nReplaceNumber--;
if ( nReplaceNumber >= 0 && nReplaceNumber < (int)sResult.length() )
{
int nLevel = sResult[ nReplaceNumber ];
if (nLevel > 11)
{//001.rtf
nReplaceNumber++;
nLevel = sResult[ nReplaceNumber];
}
std::wstring sExt = L"%" + std::to_wstring(nLevel);
sResult.erase( nReplaceNumber, 1 );
sResult.insert(sResult.begin() + nReplaceNumber, sExt.begin(), sExt.end());
nLevelTextLength += sExt.length() - 1;
}
}
sResult = sResult.substr(1);
if ( nLevelTextLength < sResult.length() )
sResult = sResult.substr(0, nLevelTextLength );
}
return XmlUtils::EncodeXmlString( sResult );
}
void SetLevelTextOOX(std::wstring sText)
{
m_sText = L"";
m_sNumber = L"";
int nNumberIndex = 0; //индекс символа который отвечает за уровень символа
for (size_t i = 0; i < sText.length() ; i++ )
{
if ( sText[i] == '%' && i + 1 < sText.length() && isdigit( sText[ i + 1 ] ))
{
int nLevel = RtfUtility::ToByte( sText[ i + 1 ] );
wchar_t ch1 = nLevel;
m_sNumber += ch1;
wchar_t ch2 = nNumberIndex + 2;
m_sNumber += ch2;
i++; //т.к. следующий симовл уже учли
}
else
m_sText += sText[i];
nNumberIndex++;
}
wchar_t ch = nNumberIndex + 1; // 1 - учитывает то что мы сдвигаем на на единицу вниз при записи
m_sText.insert(m_sText.begin() + 0, ch );
}
std::wstring GetLevelTextOOX();
void SetLevelTextOOX(std::wstring sText);
};
class RtfListProperty : public IRenderableProperty, public ItemContainer<RtfListLevelProperty>

View File

@ -877,8 +877,29 @@ std::wstring RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderP
sContent += L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n";
sContent += L"<";
sContent += sRootName;
sContent += L" xmlns:ve=\"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: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:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\">";
sContent += L" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
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 w15 w16se wp14\">";
RenderParameter oNewParameter = oRenderParameter;
OOXRelsWriterPtr oNewRelsWr ( new OOXRelsWriter( sFilename, *poRtfDocument ) );

View File

@ -603,7 +603,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
RENDER_RTF_SHAPE_PROP(L"relRotation", sResult, m_nRelRotation );
RENDER_RTF_SHAPE_PROP(L"dhgt", sResult, m_nRelZOrder );
//Fill
if( 0 == m_bFilled )
if( 0 == m_bFilled)
sResult += L"{\\sp{\\sn fFilled}{\\sv 0}}";
RENDER_RTF_SHAPE_PROP(L"fillType", sResult, m_nFillType );
RENDER_RTF_SHAPE_PROP(L"fillColor", sResult, m_nFillColor );

View File

@ -54,6 +54,8 @@ public:
BaseObjectPtr m_AXES;
std::vector<BaseObjectPtr> m_arCRT;
std::map<int, int> m_mapCRTIndex;
void concatinate_second (BaseObjectPtr & addit);
};

View File

@ -31,13 +31,14 @@
*/
#include "AXISPARENT.h"
#include <Logic/Biff_records/AxisParent.h>
#include <Logic/Biff_records/Begin.h>
#include <Logic/Biff_records/Pos.h>
#include <Logic/Biff_records/End.h>
#include "AXES.h"
#include "CRT.h"
#include "../Biff_records/AxisParent.h"
#include "../Biff_records/Begin.h"
#include "../Biff_records/Pos.h"
#include "../Biff_records/End.h"
#include <Logic/Biff_unions/AXES.h>
#include <Logic/Biff_unions/CRT.h>
namespace XLS
{

View File

@ -178,6 +178,9 @@ const bool CRT::loadContent(BinProcessor& proc)
m_ChartFormat = elements_.back();
elements_.pop_back();
ChartFormat* fmt = dynamic_cast<ChartFormat*>(m_ChartFormat.get());
m_indexCrt = fmt->icrt;
if (proc.optional<Begin>()) elements_.pop_back();
proc.mandatory<Parenthesis_CRT_1>();

View File

@ -71,6 +71,7 @@ public:
std::wstring getOoxChartType();
bool m_bIs3D;
int m_iChartType;
int m_indexCrt;
int m_indAXISPARENT;
};

View File

@ -150,7 +150,7 @@ int PIVOTVIEW::serialize(std::wostream & strm)
PIVOTFRT9* frt9 = frt ? dynamic_cast<PIVOTFRT9*>(frt->m_PIVOTFRT9.get()) : NULL;
SXEx *view_ex = pivot_ex ? dynamic_cast<SXEx*>(pivot_ex->m_SXEx.get()) : NULL;
SXViewEx9 *view_ex9 = pivot_ex ? dynamic_cast<SXViewEx9*>(frt9->m_SXViewEx9.get()) : NULL;
SXViewEx9 *view_ex9 = frt9 ? dynamic_cast<SXViewEx9*>(frt9->m_SXViewEx9.get()) : NULL;
SXAddl_SXCView_SXDVer10Info *view_ex10 = addls ? dynamic_cast<SXAddl_SXCView_SXDVer10Info*>(addls->m_SXAddl_SXCView_SXDVer10Info.get()) : NULL;
SXAddl_SXCView_SXDVer12Info *view_ex12 = addls ? dynamic_cast<SXAddl_SXCView_SXDVer12Info*>(addls->m_SXAddl_SXCView_SXDVer12Info.get()) : NULL;

View File

@ -388,7 +388,14 @@ void ChartSheetSubstream::recalc(CHARTFORMATS* charts)
AXISPARENT* parent0 = dynamic_cast<AXISPARENT*>(charts->m_arAXISPARENT[ind_AXIS].get());
int iCrt = -1;
for (size_t i = 0; i < parent0->m_arCRT.size(); i++)
{
CRT* crt= dynamic_cast<CRT*>(parent0->m_arCRT[i].get());
if (crt)
{
parent0->m_mapCRTIndex.insert(std::make_pair(crt->m_indexCrt, i));
}
}
if (charts->m_arSERIESFORMAT.empty() && !parent0->m_arCRT.empty())
{
std::vector<int> ser;
@ -735,12 +742,16 @@ int ChartSheetSubstream::serialize_legend (std::wostream & _stream, const std::w
//todooo разобраться с разными типами в одном чарте .. считать количество серий??
std::unordered_map< int, std::vector<int>>::iterator it = m_mapTypeChart.begin();
if (it != m_mapTypeChart.end())
while (it != m_mapTypeChart.end())
{
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[it->first].get());
LD * ld = dynamic_cast<LD*>(crt->m_LD.get());
if (ld == NULL) return 0;
if (ld == NULL)
{
++it;
continue;
}
CP_XML_WRITER(_stream)
{
@ -750,6 +761,7 @@ int ChartSheetSubstream::serialize_legend (std::wostream & _stream, const std::w
ld->serialize(CP_XML_STREAM(), legend_entries);
}
}
break;
}
return 0;
}
@ -833,7 +845,12 @@ int ChartSheetSubstream::serialize_plot_area (std::wostream & _stream)
for (std::unordered_map<int, std::vector<int>>::iterator it = m_mapTypeChart.begin(); it != m_mapTypeChart.end(); ++it)
{
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[it->first].get());
std::map<int, int>::iterator pFindIndexCrt = parent0->m_mapCRTIndex.find(it->first);
if (pFindIndexCrt == parent0->m_mapCRTIndex.end())
continue;
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[pFindIndexCrt->second].get());
ChartFormat *format = dynamic_cast<ChartFormat*>(crt->m_ChartFormat.get());
AXISPARENT *parent = dynamic_cast<AXISPARENT*>(chart_formats->m_arAXISPARENT[crt->m_indAXISPARENT].get());

View File

@ -1056,7 +1056,7 @@ namespace OOX
std::vector<std::wstring> sAnchors;
boost::algorithm::split(sAnchors, m_oAnchor.get(), boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
if (sAnchors.size() != 8) return; //???? todoooo
if (sAnchors.size() < 8) return;
if (pCellAnchor == NULL)
{

View File

@ -368,7 +368,7 @@ namespace OOX
sClientData += boost::lexical_cast<std::wstring>(comment->m_nRight.get()) + L",";
sClientData += boost::lexical_cast<std::wstring>(comment->m_nRightOffset.get()) + L",";
sClientData += boost::lexical_cast<std::wstring>(comment->m_nBottom.get()) + L",";
sClientData += boost::lexical_cast<std::wstring>(comment->m_nBottomOffset.get()) + L",";
sClientData += boost::lexical_cast<std::wstring>(comment->m_nBottomOffset.get());
sClientData += L"</x:Anchor>";
}
sClientData += L"<x:AutoFill>False</x:AutoFill>";

View File

@ -251,7 +251,7 @@ namespace OOX
pCommentItem->m_sGfxdata = pShape->m_sGfxData.get2();
std::vector<int> m_aAnchor;
pClientData->getAnchorArray(m_aAnchor);
if(8 == m_aAnchor.size())
if(8 <= m_aAnchor.size())
{
pCommentItem->m_nLeft = m_aAnchor[0];
pCommentItem->m_nLeftOffset = m_aAnchor[1];

View File

@ -108,14 +108,14 @@ protected:
m_sFilePath = std::wstring( sTempFile );
// Открываем сессию
HINTERNET hInternetSession = InternetOpen ( L"Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
HINTERNET hInternetSession = InternetOpenW ( L"Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( NULL == hInternetSession )
return S_FALSE;
// Заголовок запроса ( пока содержит 0 байт ( необходимо для проверки ) )
std::wstring sHTTPHdr = L"Range: bytes=0-0";
// Открываем ссылку для проверки на ее существование, а также на возможность чтения частями
HINTERNET hInternetOpenURL = InternetOpenUrl ( hInternetSession, sFileUrl.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
HINTERNET hInternetOpenURL = InternetOpenUrlW ( hInternetSession, sFileUrl.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL != hInternetOpenURL )
{
// Открытие произошло, проверяем ответ
@ -211,7 +211,7 @@ protected:
// Заголовок запроса ( содержит nEndByte - nStartByte байт )
std::wstring sHTTPHdr = L"Range: bytes=" + std::to_wstring(nStartByte) + L"-" + std::to_wstring(nEndByte);
// Открываем ссылку для закачки
HINTERNET hInternetOpenURL = InternetOpenUrl ( hInternet, sFileURL.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
HINTERNET hInternetOpenURL = InternetOpenUrlW ( hInternet, sFileURL.c_str(), sHTTPHdr.c_str(), -1, INTERNET_FLAG_RESYNCHRONIZE, 0 );
if ( NULL == hInternetOpenURL )
return -1;
// Открытие произошло, проверяем ответ
@ -338,7 +338,7 @@ protected:
m_pFile = NULL;
}
// Скачиваем файл
return URLDownloadToFile (NULL, sFileURL.c_str(), strFileOutput.c_str(), NULL, NULL);
return URLDownloadToFileW (NULL, sFileURL.c_str(), strFileOutput.c_str(), NULL, NULL);
}
};

View File

@ -42,8 +42,9 @@ namespace POLE
class COfficeFileFormatChecker
{
public:
int nFileType;
bool bMacroEnabled;
int nFileType;
bool bMacroEnabled;
std::wstring sDocumentID;
COfficeFileFormatChecker()
{
@ -70,7 +71,8 @@ public:
bool isDocFormatFile (POLE::Storage *storage);
bool isXlsFormatFile (POLE::Storage *storage);
bool isPptFormatFile (POLE::Storage *storage);
bool isMS_OFFCRYPTOFormatFile (POLE::Storage * storage);
bool isMS_OFFCRYPTOFormatFile (POLE::Storage * storage, std::wstring & documentID);
bool isMS_OFFCRYPTOFormatFile (const std::wstring & fileName, std::wstring & documentID);
bool isDocFlatFormatFile (unsigned char* pBuffer,int dwBytes);

View File

@ -232,18 +232,55 @@ bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage)
return true;
}
bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage)
bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (const std::wstring & _fileName, std::wstring & documentID)
{
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
std::wstring fileName = CorrectPathW(_fileName);
#else
std::wstring fileName = _fileName;
#endif
POLE::Storage storage(fileName.c_str());
if (storage.open())
{
if ( isMS_OFFCRYPTOFormatFile(&storage, documentID) )
{
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO;
return true;
}
}
return false;
}
bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage, std::wstring & documentID)
{
if (storage == NULL) return false;
bool result = false;
std::list<std::wstring> entries = storage->entries(L"DataSpaces");
if (entries.size() > 0)
return true;
{
result = true;
}
if ( storage->exists(L"EncryptionInfo") &&
storage->exists(L"EncryptedPackage"))
return true;
return false;
{
result = true;
}
if (result)
{
POLE::Stream stream(storage, L"DocumentID");
std::string sData;
sData.resize(stream.size());
if (stream.read((BYTE*)sData.c_str(), stream.size()) > 0)
{
documentID = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sData.c_str(), sData.length());
}
}
return result;
}
bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
{
@ -284,7 +321,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT;
return true;
}
else if ( isMS_OFFCRYPTOFormatFile(&storage) )
else if ( isMS_OFFCRYPTOFormatFile(&storage, sDocumentID) )
{
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO;
return true;

View File

@ -1 +1 @@
2.4.538.0
2.4.539.0

View File

@ -212,7 +212,7 @@ namespace XmlUtils
if ((XmlNodeType_Element == eNodeType && nCurDepth == nDepth + 1)
|| ((XmlNodeType_Text == eNodeType ||
XmlNodeType_Whitespace == eNodeType ||
XmlNodeType_SIGNIFICANT_WHITESPACE == eNodeType ) && nCurDepth == nDepth + 1))
XmlNodeType_SIGNIFICANT_WHITESPACE == eNodeType ) && nCurDepth == nDepth + 1))
return true;
else if (XmlNodeType_EndElement == eNodeType && nCurDepth == nDepth)
return false;

View File

@ -2,6 +2,7 @@
//
#include "tchar.h"
#include "../source/ECMACryptFile.h"
#include "../../Common/OfficeFileFormatChecker.h"
int _tmain(int argc, _TCHAR* argv[])
{
@ -18,14 +19,21 @@ int _tmain(int argc, _TCHAR* argv[])
std::wstring password = L"574446f1-6aa0-860a-0296-787a87a214bb";
ECMACryptFile crypt_file;
bool result, bDataIntegrity;
bool result = false, bDataIntegrity = false;
//result = crypt_file.DecryptOfficeFile(srcFileName, dstFileName, password, bDataIntegrity);
//result = crypt_file.EncryptOfficeFile(dstFileName, dstFileName2, password);
result = crypt_file.EncryptOfficeFile(srcFileName, dstFileName, password);
result = crypt_file.EncryptOfficeFile(srcFileName, dstFileName, password, L"123456789");
result = crypt_file.DecryptOfficeFile(dstFileName, dstFileName2, password, bDataIntegrity);
COfficeFileFormatChecker fileChecker;
std::wstring sDocumentID;
if (fileChecker.isMS_OFFCRYPTOFormatFile(dstFileName, sDocumentID))
{
}
return 0;
}

View File

@ -3,19 +3,22 @@ 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
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeFileCrypt", "..\win32\ECMACryptReader.vcproj", "{C27E9A9F-3A17-4482-9C5F-BF15C01E747C}"
ProjectSection(ProjectDependencies) = postProject
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptlib", "..\..\Common\3dParty\cryptopp\cryptlib.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml2", "..\..\DesktopEditor\xml\build\vs2005\libxml2.vcproj", "{21663823-DE45-479B-91D0-B4FEF4916EF0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeUtilsLib", "..\..\OfficeUtils\win32\OfficeUtilsLib.vcproj", "{F8274B05-168E-4D6E-B843-AA7510725363}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -88,6 +91,22 @@ Global
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|Win32.Build.0 = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|x64.ActiveCfg = Release|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|x64.Build.0 = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|Win32.ActiveCfg = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|Win32.Build.0 = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|x64.ActiveCfg = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|x64.Build.0 = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|Win32.ActiveCfg = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|Win32.Build.0 = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|x64.ActiveCfg = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|x64.Build.0 = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|Win32.ActiveCfg = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|Win32.Build.0 = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|x64.ActiveCfg = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|x64.Build.0 = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|Win32.ActiveCfg = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|Win32.Build.0 = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|x64.ActiveCfg = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -173,6 +173,14 @@
<Filter
Name="Common"
>
<File
RelativePath="..\..\Common\OfficeFileFormatChecker.h"
>
</File>
<File
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>

View File

@ -484,7 +484,7 @@ bool ReadExtensibleEncryptionInfo(unsigned char* data, int size, _ecmaCryptData
//--------------------------------------------------------------
bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password)
bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, const std::wstring &documentID)
{
_ecmaCryptData cryptData;
@ -562,6 +562,17 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
pStream->flush();
delete pStream;
if (false == documentID.empty())
{
std::string utfDocumentID = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(documentID);
pStream = new POLE::Stream(pStorage, L"DocumentID", true, utfDocumentID.length());
pStream->write((BYTE*)utfDocumentID.c_str(), utfDocumentID.length());
pStream->flush();
delete pStream;
}
pStorage->close();
delete pStorage;
@ -589,7 +600,7 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
return true;
}
bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password, bool & bDataIntegrity)
bool ECMACryptFile::DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity)
{
bDataIntegrity = false;
@ -696,8 +707,7 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f
{
if (password.empty())
{
password = L"VelvetSweatshop";
if (!decryptor.SetPassword(password))
if (!decryptor.SetPassword(L"VelvetSweatshop"))
return false;
}
else

View File

@ -37,8 +37,8 @@
class ECMACryptFile
{
public:
bool DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password, bool & bDataIntegrity);
bool EncryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password);
bool DecryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, bool & bDataIntegrity);
bool EncryptOfficeFile(const std::wstring &file_name_inp, const std::wstring &file_name_out, const std::wstring &password, const std::wstring &documentID = L"");
struct _refComponent
{

View File

@ -2597,11 +2597,12 @@ namespace NExtractTools
}
int oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
{
std::wstring password = params.getSavePassword();
std::wstring password = params.getSavePassword();
std::wstring documentID = params.getDocumentID();
ECMACryptFile cryptReader;
if (cryptReader.EncryptOfficeFile(sFrom, sTo, password) == false)
if (cryptReader.EncryptOfficeFile(sFrom, sTo, password, documentID) == false)
{
return AVS_FILEUTILS_ERROR_CONVERT;
}

View File

@ -405,6 +405,7 @@ namespace NExtractTools
std::wstring* m_sHtmlFileInternalPath;
std::wstring* m_sPassword;
std::wstring* m_sSavePassword;
std::wstring* m_sDocumentID;
std::wstring* m_sTempDir;
bool* m_bIsNoBase64;
boost::unordered_map<int, InputLimit> m_mapInputLimits;
@ -433,6 +434,7 @@ namespace NExtractTools
m_sHtmlFileInternalPath = NULL;
m_sPassword = NULL;
m_sSavePassword = NULL;
m_sDocumentID = NULL;
m_sTempDir = NULL;
m_bIsNoBase64 = NULL;
@ -460,6 +462,7 @@ namespace NExtractTools
RELEASEOBJECT(m_sHtmlFileInternalPath);
RELEASEOBJECT(m_sPassword);
RELEASEOBJECT(m_sSavePassword);
RELEASEOBJECT(m_sDocumentID);
RELEASEOBJECT(m_sTempDir);
RELEASEOBJECT(m_bIsNoBase64);
}
@ -610,6 +613,11 @@ namespace NExtractTools
RELEASEOBJECT(m_sSavePassword);
m_sSavePassword = new std::wstring(sValue);
}
else if(_T("m_sDocumentID") == sName)
{
RELEASEOBJECT(m_sDocumentID);
m_sDocumentID = new std::wstring(sValue);
}
else if(_T("m_sTempDir") == sName)
{
RELEASEOBJECT(m_sTempDir);
@ -687,6 +695,10 @@ namespace NExtractTools
{
return (NULL != m_sSavePassword) ? (*m_sSavePassword) : L"";
}
std::wstring getDocumentID() const
{
return (NULL != m_sDocumentID) ? (*m_sDocumentID) : L"";
}
std::wstring getFontPath() const
{
return (NULL != m_sFontDir) ? (*m_sFontDir) : L"";