Compare commits

...

3 Commits

23 changed files with 280 additions and 619 deletions

View File

@ -3801,223 +3801,19 @@ public:
{
int res = c_oSerConstants::ReadOk;
CFldSimple* pFldSimple = static_cast<CFldSimple*>(poResult);
if ( c_oSer_FldSimpleType::Instr == type )
if ( c_oSer_HyperlinkType::Link == type )
pFldSimple->sInstr = m_oBufferedStream.GetString3(length);
else if ( c_oSer_FldSimpleType::Content == type )
else if ( c_oSer_HyperlinkType::Content == type )
{
XmlUtils::CStringWriter* pPrevWriter = m_pCurWriter;
m_pCurWriter = &pFldSimple->writer;
res = Read1(length, &Binary_DocumentTableReader::ReadParagraphContent, this, NULL);
m_pCurWriter = pPrevWriter;
}
else if ( c_oSer_FldSimpleType::FFData == type )
{
OOX::Logic::CFFData oFFData;
res = Read1(length, &Binary_DocumentTableReader::ReadFFData, this, &oFFData);
pFldSimple->writer.WriteString(oFFData.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFData(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFData* pFFData = static_cast<OOX::Logic::CFFData*>(poResult);
if ( c_oSerFFData::CalcOnExit == type )
{
pFFData->m_oCalcOnExit.Init();
pFFData->m_oCalcOnExit->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::CheckBox == type )
{
pFFData->m_oCheckBox.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadFFCheckBox, this, pFFData->m_oCheckBox.GetPointer());
}
else if ( c_oSerFFData::DDList == type )
{
pFFData->m_oDDList.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadDDList, this, pFFData->m_oDDList.GetPointer());
}
else if ( c_oSerFFData::Enabled == type )
{
pFFData->m_oEnabled.Init();
pFFData->m_oEnabled->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::EntryMacro == type )
{
pFFData->m_oEntryMacro.Init();
pFFData->m_oEntryMacro->m_oVal.Init();
pFFData->m_oEntryMacro->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::ExitMacro == type )
{
pFFData->m_oExitMacro.Init();
pFFData->m_oExitMacro->m_oVal.Init();
pFFData->m_oExitMacro->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::HelpText == type )
{
pFFData->m_oHelpText.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadFFHelpText, this, pFFData->m_oHelpText.GetPointer());
}
else if ( c_oSerFFData::Label == type )
{
pFFData->m_oLabel.Init();
pFFData->m_oLabel->m_oVal.Init();
pFFData->m_oLabel->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::Name == type )
{
pFFData->m_oName.Init();
pFFData->m_oName->m_oVal.Init();
pFFData->m_oName->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::StatusText == type )
{
pFFData->m_oStatusText.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadFFStatusText, this, pFFData->m_oStatusText.GetPointer());
}
else if ( c_oSerFFData::TabIndex == type )
{
pFFData->m_oTabIndex.Init();
pFFData->m_oTabIndex->m_oVal.Init();
pFFData->m_oTabIndex->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::TextInput == type )
{
pFFData->m_oTextInput.Init();
res = Read1(length, &Binary_DocumentTableReader::ReadTextInput, this, pFFData->m_oTextInput.GetPointer());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFCheckBox(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFCheckBox* pFFCheckBox = static_cast<OOX::Logic::CFFCheckBox*>(poResult);
if ( c_oSerFFData::CBChecked == type )
{
pFFCheckBox->m_oChecked.Init();
pFFCheckBox->m_oChecked->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::CBDefault == type )
{
pFFCheckBox->m_oDefault.Init();
pFFCheckBox->m_oDefault->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else if ( c_oSerFFData::CBSize == type )
{
pFFCheckBox->m_oSize.Init();
pFFCheckBox->m_oSize->m_oVal.Init();
pFFCheckBox->m_oSize->m_oVal->FromHps(m_oBufferedStream.GetULong());
}
else if ( c_oSerFFData::CBSizeAuto == type )
{
pFFCheckBox->m_oSizeAuto.Init();
pFFCheckBox->m_oSizeAuto->m_oVal.FromBool(m_oBufferedStream.GetBool());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadDDList(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFDDList* pDDList = static_cast<OOX::Logic::CFFDDList*>(poResult);
if ( c_oSerFFData::DLDefault == type )
{
pDDList->m_oDefault.Init();
pDDList->m_oDefault->m_oVal.Init();
pDDList->m_oDefault->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::DLResult == type )
{
pDDList->m_oResult.Init();
pDDList->m_oResult->m_oVal.Init();
pDDList->m_oResult->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::DLListEntry == type )
{
ComplexTypes::Word::String* pVal = new ComplexTypes::Word::String();
pVal->m_sVal.Init();
pVal->m_sVal->append(m_oBufferedStream.GetString3(length));
pDDList->m_arrListEntry.push_back(pVal);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFHelpText(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
ComplexTypes::Word::CFFHelpText* pHelpText = static_cast<ComplexTypes::Word::CFFHelpText*>(poResult);
if ( c_oSerFFData::HTType == type )
{
pHelpText->m_oType.Init();
pHelpText->m_oType->SetValue((SimpleTypes::EInfoTextType)m_oBufferedStream.GetUChar());
}
else if ( c_oSerFFData::HTVal == type )
{
pHelpText->m_oVal.Init();
pHelpText->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadFFStatusText(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
ComplexTypes::Word::CFFStatusText* pStatusText = static_cast<ComplexTypes::Word::CFFStatusText*>(poResult);
if ( c_oSerFFData::HTType == type )
{
pStatusText->m_oType.Init();
pStatusText->m_oType->SetValue((SimpleTypes::EInfoTextType)m_oBufferedStream.GetUChar());
}
else if ( c_oSerFFData::HTVal == type )
{
pStatusText->m_oVal.Init();
pStatusText->m_oVal->SetValue(m_oBufferedStream.GetString3(length));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadTextInput(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CFFTextInput* pTextInput = static_cast<OOX::Logic::CFFTextInput*>(poResult);
if ( c_oSerFFData::TIDefault == type )
{
pTextInput->m_oDefault.Init();
pTextInput->m_oDefault->m_sVal.Init();
pTextInput->m_oDefault->m_sVal->append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::TIFormat == type )
{
pTextInput->m_oFormat.Init();
pTextInput->m_oFormat->m_sVal.Init();
pTextInput->m_oFormat->m_sVal->append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerFFData::TIMaxLength == type )
{
pTextInput->m_oMaxLength.Init();
pTextInput->m_oMaxLength->m_oVal.Init();
pTextInput->m_oMaxLength->m_oVal->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerFFData::TIType == type )
{
pTextInput->m_oType.Init();
pTextInput->m_oType->m_oVal.Init();
pTextInput->m_oType->m_oVal->SetValue((SimpleTypes::EFFTextType)m_oBufferedStream.GetUChar());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadHyperlink(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;

View File

@ -912,8 +912,7 @@ extern int g_nCurFormatVersion;
namespace c_oSer_FldSimpleType{ enum c_oSer_FldSimpleType
{
Content = 0,
Instr = 1,
FFData = 2
Instr = 1
};}
namespace c_oSer_ColorThemeType{ enum c_oSer_ColorThemeType
{
@ -1045,34 +1044,6 @@ extern int g_nCurFormatVersion;
Temporary = 34,
MultiLine = 35
};}
namespace c_oSerFFData{enum c_oSerFFData
{
CalcOnExit = 0,
CheckBox = 1,
DDList = 2,
Enabled = 3,
EntryMacro = 4,
ExitMacro = 5,
HelpText = 6,
Label = 7,
Name = 8,
StatusText = 9,
TabIndex = 10,
TextInput = 11,
CBChecked = 12,
CBDefault = 13,
CBSize = 14,
CBSizeAuto = 15,
DLDefault = 16,
DLResult = 17,
DLListEntry = 18,
HTType = 19,
HTVal = 20,
TIDefault = 21,
TIFormat = 22,
TIMaxLength = 23,
TIType = 24,
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

View File

@ -3321,208 +3321,11 @@ namespace BinDocxRW
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::Instr);
m_oBcw.m_oStream.WriteStringW3(*pFldSimple->m_sInstr);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
//FFData
if(pFldSimple->m_oFFData.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::FFData);
WriteFFData(pFldSimple->m_oFFData.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//Content
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::Content);
WriteParagraphContent(pFldSimple->m_arrItems);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
void WriteFFData(const OOX::Logic::CFFData& oFFData)
{
int nCurPos = 0;
if(oFFData.m_oCalcOnExit.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CalcOnExit);
m_oBcw.m_oStream.WriteBOOL(oFFData.m_oCalcOnExit->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oCheckBox.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CheckBox);
WriteFFCheckBox(oFFData.m_oCheckBox.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oDDList.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DDList);
WriteDDList(oFFData.m_oDDList.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oEnabled.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::Enabled);
m_oBcw.m_oStream.WriteBOOL(oFFData.m_oEnabled->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oEntryMacro.IsInit() && oFFData.m_oEntryMacro->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::EntryMacro);
m_oBcw.m_oStream.WriteStringW3(oFFData.m_oEntryMacro->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oExitMacro.IsInit() && oFFData.m_oExitMacro->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::ExitMacro);
m_oBcw.m_oStream.WriteStringW3(oFFData.m_oExitMacro->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oHelpText.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HelpText);
WriteFFHelpText(oFFData.m_oHelpText.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oLabel.IsInit() && oFFData.m_oLabel->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::Label);
m_oBcw.m_oStream.WriteLONG(oFFData.m_oLabel->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oName.IsInit() && oFFData.m_oName->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::Name);
m_oBcw.m_oStream.WriteStringW3(oFFData.m_oName->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oStatusText.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::StatusText);
WriteFFStatusText(oFFData.m_oStatusText.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oTabIndex.IsInit() && oFFData.m_oTabIndex->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TabIndex);
m_oBcw.m_oStream.WriteLONG(oFFData.m_oTabIndex->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oFFData.m_oTextInput.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TextInput);
WriteTextInput(oFFData.m_oTextInput.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteFFCheckBox(const OOX::Logic::CFFCheckBox& oCheckBox)
{
int nCurPos = 0;
if(oCheckBox.m_oChecked.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBChecked);
m_oBcw.m_oStream.WriteBOOL(oCheckBox.m_oChecked->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oCheckBox.m_oDefault.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBDefault);
m_oBcw.m_oStream.WriteBOOL(oCheckBox.m_oDefault->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oCheckBox.m_oSize.IsInit() && oCheckBox.m_oSize->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBSize);
m_oBcw.m_oStream.WriteULONG(oCheckBox.m_oSize->m_oVal->ToHps());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oCheckBox.m_oSizeAuto.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::CBSizeAuto);
m_oBcw.m_oStream.WriteBOOL(oCheckBox.m_oSizeAuto->m_oVal.ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteDDList(const OOX::Logic::CFFDDList& oDDList)
{
int nCurPos = 0;
if(oDDList.m_oDefault.IsInit() && oDDList.m_oDefault->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DLDefault);
m_oBcw.m_oStream.WriteLONG(oDDList.m_oDefault->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oDDList.m_oResult.IsInit() && oDDList.m_oResult->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DLResult);
m_oBcw.m_oStream.WriteLONG(oDDList.m_oResult->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
for(int i = 0 ; i < oDDList.m_arrListEntry.size(); ++i)
{
ComplexTypes::Word::String* pVal = oDDList.m_arrListEntry[i];
if(pVal->m_sVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::DLListEntry);
m_oBcw.m_oStream.WriteStringW3(pVal->m_sVal.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
void WriteFFHelpText(const ComplexTypes::Word::CFFHelpText& oHelpText)
{
int nCurPos = 0;
if(oHelpText.m_oType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTType);
m_oBcw.m_oStream.WriteBYTE(oHelpText.m_oType->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oHelpText.m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTVal);
m_oBcw.m_oStream.WriteStringW3(oHelpText.m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteFFStatusText(const ComplexTypes::Word::CFFStatusText& oStatusText)
{
int nCurPos = 0;
if(oStatusText.m_oType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTType);
m_oBcw.m_oStream.WriteBYTE(oStatusText.m_oType->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oStatusText.m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::HTVal);
m_oBcw.m_oStream.WriteStringW3(oStatusText.m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteTextInput(const OOX::Logic::CFFTextInput& oTextInput)
{
int nCurPos = 0;
if(oTextInput.m_oDefault.IsInit() && oTextInput.m_oDefault->m_sVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIDefault);
m_oBcw.m_oStream.WriteStringW3(oTextInput.m_oDefault->m_sVal.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oTextInput.m_oFormat.IsInit() && oTextInput.m_oFormat->m_sVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIFormat);
m_oBcw.m_oStream.WriteStringW3(oTextInput.m_oFormat->m_sVal.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oTextInput.m_oMaxLength.IsInit() && oTextInput.m_oMaxLength->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIMaxLength);
m_oBcw.m_oStream.WriteLONG(oTextInput.m_oMaxLength->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oTextInput.m_oType.IsInit() && oTextInput.m_oType->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerFFData::TIType);
m_oBcw.m_oStream.WriteBYTE(oTextInput.m_oType->m_oVal->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteHyperlink(OOX::Logic::CHyperlink* pHyperlink)
{

View File

@ -799,7 +799,7 @@ namespace ComplexTypes
if ( m_oVal.IsInit() )
{
sResult += _T("w:val=\"");
sResult += std::to_wstring(m_oVal->ToHps());
sResult += m_oVal->ToString();
sResult += _T("\" ");
}

View File

@ -3085,11 +3085,6 @@ namespace SimpleTypes
m_dValue = fabs( dValue * 72.0 );
return m_dValue;
}
virtual double FromHps(double dValue)
{
m_dValue = dValue / 2;
return m_dValue;
}
SimpleType_FromString (double)
SimpleType_Operator_Equal (CHpsMeasure)
UniversalMeasure_AdditionalOpearators(CHpsMeasure)

View File

@ -142,8 +142,6 @@ namespace OOX
pItem = new CSmartTag( oItem );
//else if ( _T("w:subDoc") == sName )
// pItem = new CSubDoc( oItem );
else if ( _T("w:ffData") == sName )
m_oFFData = new CFFData( oItem );
if ( pItem )
m_arrItems.push_back( pItem );
@ -234,8 +232,6 @@ namespace OOX
pItem = new CSmartTag( oReader );
//else if ( _T("w:subDoc") == sName )
// pItem = new CSubDoc( oReader );
else if ( _T("w:ffData") == sName )
m_oFFData = new CFFData( oReader );
if ( pItem )
m_arrItems.push_back( pItem );
@ -263,11 +259,6 @@ namespace OOX
sResult += _T(">");
if (m_oFFData.IsInit())
{
sResult += m_oFFData->toXML();
}
for (unsigned int nIndex = 0; nIndex < m_arrItems.size(); nIndex++ )
{
if ( m_arrItems[nIndex] )

View File

@ -38,7 +38,6 @@
#include "../WritingElement.h"
#include "../../Common/SimpleTypes_Word.h"
#include "../../Common/SimpleTypes_Shared.h"
#include "../../DocxFormat/Logic/FldChar.h"
namespace OOX
{
@ -121,7 +120,6 @@ namespace OOX
nullable<std::wstring > m_sInstr;
// Childs
nullable<OOX::Logic::CFFData > m_oFFData;
};
} // namespace Logic

View File

@ -1,5 +1,20 @@
DEFINES += HAVE_VA_COPY
core_static_link_xml_full {
DEFINES += \
LIBXML_READER_ENABLED \
LIBXML_PUSH_ENABLED \
LIBXML_HTML_ENABLED \
LIBXML_XPATH_ENABLED \
LIBXML_OUTPUT_ENABLED \
LIBXML_C14N_ENABLED \
LIBXML_SAX1_ENABLED \
LIBXML_TREE_ENABLED \
LIBXML_XPTR_ENABLED \
IN_LIBXML \
LIBXML_STATIC
}
INCLUDEPATH += \
$$PWD/../../libxml2/include \
$$PWD/../../libxml2/include/libxml \

View File

@ -1,17 +0,0 @@
#ifndef _XMLSIGNER_CERTIFICATE_H_
#define _XMLSIGNER_CERTIFICATE_H_
#ifdef WIN32
#include "XmlSigner_mscrypto.h"
#define CCertificate CCertificate_mscrypto
#endif
#if defined(_LINUX) && !defined(_MAC)
#endif
#ifdef _MAC
#endif
#endif // _XMLSIGNER_CERTIFICATE_H_

View File

@ -0,0 +1,23 @@
#ifndef _XML_OOXMLSIGNER_H_
#define _XML_OOXMLSIGNER_H_
#include "./XmlCertificate.h"
class COOXMLSigner_private;
class Q_DECL_EXPORT COOXMLSigner
{
public:
COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext);
~COOXMLSigner();
void SetGuid(const std::wstring& guid);
void SetImageValid(const std::wstring& file);
void SetImageInvalid(const std::wstring& file);
void Sign();
private:
COOXMLSigner_private* m_internal;
};
#endif //_XML_OOXMLSIGNER_H_

View File

@ -0,0 +1,48 @@
#ifndef _XML_OOXMLVERIFIER_H_
#define _XML_OOXMLVERIFIER_H_
#include "./XmlCertificate.h"
#define OOXML_SIGNATURE_VALID 0
#define OOXML_SIGNATURE_INVALID 1
#define OOXML_SIGNATURE_NOTSUPPORTED 2
#define OOXML_SIGNATURE_BAD 3
class COOXMLSignature_private;
class Q_DECL_EXPORT COOXMLSignature
{
public:
COOXMLSignature();
~COOXMLSignature();
public:
int GetValid();
std::string GetGuid();
ICertificate* GetCertificate();
std::string GetImageValidBase64();
std::string GetImageInvalidBase64();
public:
void Check();
friend class COOXMLVerifier_private;
friend class COOXMLVerifier;
private:
COOXMLSignature_private* m_internal;
};
class COOXMLVerifier_private;
class Q_DECL_EXPORT COOXMLVerifier
{
public:
COOXMLVerifier(const std::wstring& sFolder);
~COOXMLVerifier();
int GetSignatureCount();
COOXMLSignature* GetSignature(const int& index);
private:
COOXMLVerifier_private* m_internal;
};
#endif //_XML_OOXMLVERIFIER_H_

View File

@ -1,17 +1,14 @@
#ifndef _XMLSIGNER_BASE_H_
#define _XMLSIGNER_BASE_H_
#include "../../common/File.h"
#include "../../common/BigInteger.h"
#ifndef _XML_SERTIFICATE_BASE_H_
#define _XML_SERTIFICATE_BASE_H_
#include <string>
#include <vector>
#include <map>
#include "../../../common/base_export.h"
#define OOXML_HASH_ALG_SHA1 0
#define OOXML_HASH_ALG_INVALID 1
class ICertificate
class Q_DECL_EXPORT ICertificate
{
public:
ICertificate()
@ -36,20 +33,15 @@ public:
virtual std::string GetHash(std::wstring& sXmlFile, int nAlg) = 0;
virtual bool Verify(std::string& sXml, std::string& sXmlSignature, int nAlg) = 0;
virtual bool LoadFromBase64Data(const std::string& data) = 0;
virtual int ShowCertificate() = 0;
virtual bool LoadFromBase64Data(const std::string& data) = 0;
public:
virtual bool ShowSelectDialog() = 0;
virtual int ShowCertificate() = 0;
static int GetOOXMLHashAlg(const std::string& sAlg)
{
if ("http://www.w3.org/2000/09/xmldsig#rsa-sha1" == sAlg ||
"http://www.w3.org/2000/09/xmldsig#sha1" == sAlg)
return OOXML_HASH_ALG_SHA1;
return OOXML_HASH_ALG_INVALID;
}
public:
static int GetOOXMLHashAlg(const std::string& sAlg);
static ICertificate* CreateInstance();
};
#endif // _XMLSIGNER_BASE_H_
#endif // _XML_SERTIFICATE_BASE_H_

View File

@ -1,11 +1,7 @@
#ifndef _XML_OOXMLSIGNER_H_
#define _XML_OOXMLSIGNER_H_
#include "./../include/OOXMLSigner.h"
#include "./../src/XmlTransform.h"
#include "./XmlCanonicalizator.h"
#include "./XmlSignerBase.h"
#include "./XmlTransform.h"
class COOXMLSigner
class COOXMLSigner_private
{
public:
ICertificate* m_certificate;
@ -25,7 +21,7 @@ public:
std::wstring m_guid;
public:
COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext)
COOXMLSigner_private(const std::wstring& sFolder, ICertificate* pContext)
{
m_sFolder = sFolder;
m_certificate = pContext;
@ -35,7 +31,7 @@ public:
m_signed_info.WriteString("<CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>");
m_signed_info.WriteString("<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>");
}
~COOXMLSigner()
~COOXMLSigner_private()
{
}
@ -560,4 +556,32 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
}
};
#endif //_XML_OOXMLSIGNER_H_
COOXMLSigner::COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext)
{
m_internal = new COOXMLSigner_private(sFolder, pContext);
}
COOXMLSigner::~COOXMLSigner()
{
RELEASEOBJECT(m_internal);
}
void COOXMLSigner::SetGuid(const std::wstring& guid)
{
m_internal->SetGuid(guid);
}
void COOXMLSigner::SetImageValid(const std::wstring& file)
{
m_internal->SetImageValid(file);
}
void COOXMLSigner::SetImageInvalid(const std::wstring& file)
{
m_internal->SetImageInvalid(file);
}
void COOXMLSigner::Sign()
{
m_internal->Sign();
}

View File

@ -1,18 +1,10 @@
#ifndef _XML_OOXMLVERIFIER_H_
#define _XML_OOXMLVERIFIER_H_
#include "./XmlCanonicalizator.h"
#include "./XmlTransform.h"
#include "./XmlCertificate.h"
#include "./../include/OOXMLVerifier.h"
#define OOXML_SIGNATURE_VALID 0
#define OOXML_SIGNATURE_INVALID 1
#define OOXML_SIGNATURE_NOTSUPPORTED 2
#define OOXML_SIGNATURE_BAD 3
class COOXMLSignature
class COOXMLSignature_private
{
private:
public:
int m_valid;
std::string m_guid;
ICertificate* m_cert;
@ -22,7 +14,6 @@ private:
std::wstring m_sFolder;
private:
XmlUtils::CXmlNode m_node; // signature file
class CXmlStackNamespaces
@ -133,13 +124,13 @@ private:
};
public:
COOXMLSignature()
COOXMLSignature_private()
{
m_valid = OOXML_SIGNATURE_INVALID;
m_guid = "";
m_cert = NULL;
}
~COOXMLSignature()
~COOXMLSignature_private()
{
RELEASEOBJECT(m_cert);
}
@ -176,7 +167,7 @@ public:
m_valid = OOXML_SIGNATURE_NOTSUPPORTED;
return;
}
m_cert = new CCertificate();
m_cert = ICertificate::CreateInstance();
if (!m_cert->LoadFromBase64Data(U_TO_UTF8(oNodeCert.GetText())))
{
m_valid = OOXML_SIGNATURE_NOTSUPPORTED;
@ -273,7 +264,7 @@ public:
friend class COOXMLVerifier;
private:
public:
int CheckManifestReference(XmlUtils::CXmlNode& node)
{
@ -391,14 +382,54 @@ private:
}
};
class COOXMLVerifier
COOXMLSignature::COOXMLSignature()
{
m_internal = new COOXMLSignature_private();
}
COOXMLSignature::~COOXMLSignature()
{
RELEASEOBJECT(m_internal);
}
int COOXMLSignature::GetValid()
{
return m_internal->GetValid();
}
std::string COOXMLSignature::GetGuid()
{
return m_internal->GetGuid();
}
ICertificate* COOXMLSignature::GetCertificate()
{
return m_internal->GetCertificate();
}
std::string COOXMLSignature::GetImageValidBase64()
{
return m_internal->GetImageValidBase64();
}
std::string COOXMLSignature::GetImageInvalidBase64()
{
return m_internal->GetImageInvalidBase64();
}
void COOXMLSignature::Check()
{
m_internal->Check();
}
class COOXMLVerifier_private
{
public:
std::wstring m_sFolder;
std::vector<COOXMLSignature*> m_arSignatures;
public:
COOXMLVerifier(const std::wstring& sFolder)
COOXMLVerifier_private(const std::wstring& sFolder)
{
m_sFolder = sFolder;
@ -429,14 +460,14 @@ public:
continue;
COOXMLSignature* pSignature = new COOXMLSignature();
pSignature->m_node = nodeSig;
pSignature->m_sFolder = m_sFolder;
pSignature->m_internal->m_node = nodeSig;
pSignature->m_internal->m_sFolder = m_sFolder;
pSignature->Check();
m_arSignatures.push_back(pSignature);
}
}
~COOXMLVerifier()
~COOXMLVerifier_private()
{
for (std::vector<COOXMLSignature*>::iterator i = m_arSignatures.begin(); i != m_arSignatures.end(); i++)
{
@ -447,4 +478,22 @@ public:
}
};
#endif //_XML_OOXMLVERIFIER_H_
COOXMLVerifier::COOXMLVerifier(const std::wstring& sFolder)
{
m_internal = new COOXMLVerifier_private(sFolder);
}
COOXMLVerifier::~COOXMLVerifier()
{
RELEASEOBJECT(m_internal);
}
int COOXMLVerifier::GetSignatureCount()
{
return (int)m_internal->m_arSignatures.size();
}
COOXMLSignature* COOXMLVerifier::GetSignature(const int& index)
{
return m_internal->m_arSignatures[index];
}

View File

@ -1,12 +1,12 @@
#ifndef _XML_CANONICALIZATOR_H_
#define _XML_CANONICALIZATOR_H_
#include "../../common/File.h"
#include "../../common/Directory.h"
#include "../../../common/File.h"
#include "../../../common/Directory.h"
#include "../../common/StringBuilder.h"
#include "../../xml/include/xmlutils.h"
#include "../../xml/libxml2/include/libxml/c14n.h"
#include "../../../common/StringBuilder.h"
#include "../../../xml/include/xmlutils.h"
#include "../../../xml/libxml2/include/libxml/c14n.h"
#ifndef XML_UNUSED
#define XML_UNUSED( arg ) ( (arg) = (arg) )

View File

@ -0,0 +1,26 @@
#ifdef WIN32
#include "./XmlSigner_mscrypto.h"
#define CCertificate CCertificate_mscrypto
#endif
#if defined(_LINUX) && !defined(_MAC)
#endif
#ifdef _MAC
#endif
int ICertificate::GetOOXMLHashAlg(const std::string& sAlg)
{
if ("http://www.w3.org/2000/09/xmldsig#rsa-sha1" == sAlg ||
"http://www.w3.org/2000/09/xmldsig#sha1" == sAlg)
return OOXML_HASH_ALG_SHA1;
return OOXML_HASH_ALG_INVALID;
}
ICertificate* ICertificate::CreateInstance()
{
return new CCertificate();
}

View File

@ -1,13 +1,16 @@
#ifndef _XMLSIGNER_MSCRYPTO_H_
#define _XMLSIGNER_MSCRYPTO_H_
#include "./XmlSignerBase.h"
#include "./include/XmlCertificate.h"
#include <stdio.h>
#include <windows.h>
#include <wincrypt.h>
#include <cryptuiapi.h>
#include "../../../common/File.h"
#include "../../../common/BigInteger.h"
class CCertificate_mscrypto : public ICertificate
{
public:

View File

@ -0,0 +1,21 @@
#include "./XmlTransform.h"
IXmlTransform* IXmlTransform::GetFromType(const std::string& alg)
{
if (true)
{
CXmlTransformRelationship* transform = new CXmlTransformRelationship();
if (transform->m_algorithm == alg)
return transform;
RELEASEOBJECT(transform);
}
if (true)
{
CXmlTransformC14N* transform = new CXmlTransformC14N();
if (transform->CheckC14NTransform(alg))
return transform;
RELEASEOBJECT(transform);
}
return NULL;
}

View File

@ -122,26 +122,6 @@ public:
}
};
IXmlTransform* IXmlTransform::GetFromType(const std::string& alg)
{
if (true)
{
CXmlTransformRelationship* transform = new CXmlTransformRelationship();
if (transform->m_algorithm == alg)
return transform;
RELEASEOBJECT(transform);
}
if (true)
{
CXmlTransformC14N* transform = new CXmlTransformC14N();
if (transform->CheckC14NTransform(alg))
return transform;
RELEASEOBJECT(transform);
}
return NULL;
}
class CXmlTransforms
{
protected:

View File

@ -1,10 +1,8 @@
#include "../../src/XmlCertificate.h"
#include "../../src/OOXMLSigner.h"
#include "../../src/OOXMLVerifier.h"
#include "../../src/include/XmlCertificate.h"
#include "../../src/include/OOXMLSigner.h"
#include "../../src/include/OOXMLVerifier.h"
#pragma comment (lib, "crypt32.lib")
#pragma comment (lib, "cryptui.lib")
#pragma comment (lib, "Advapi32.lib")
#include "../../../common/File.h"
void main(void)
{
@ -17,31 +15,34 @@ void main(void)
{
std::wstring sSignId = L"{9792D33F-AB37-4E5B-A465-481B9465818B}";
CCertificate oCertificate;
if (!oCertificate.ShowSelectDialog())
ICertificate* pCertificate = ICertificate::CreateInstance();
if (!pCertificate->ShowSelectDialog())
{
RELEASEOBJECT(pCertificate);
return;
}
COOXMLSigner oOOXMLSigner(sFolderOOXML, &oCertificate);
COOXMLSigner oOOXMLSigner(sFolderOOXML, pCertificate);
oOOXMLSigner.SetGuid(sSignId);
oOOXMLSigner.SetImageValid(NSFile::GetProcessDirectory() + L"/../../../resources/valid.png");
oOOXMLSigner.SetImageInvalid(NSFile::GetProcessDirectory() + L"/../../../resources/invalid.png");
oOOXMLSigner.Sign();
RELEASEOBJECT(pCertificate);
}
else
{
COOXMLVerifier oVerifier(sFolderOOXML);
size_t nCount = oVerifier.m_arSignatures.size();
for (std::vector<COOXMLSignature*>::iterator i = oVerifier.m_arSignatures.begin(); i != oVerifier.m_arSignatures.end(); i++)
int nCount = oVerifier.GetSignatureCount();
for (int i = 0; i < nCount; i++)
{
COOXMLSignature* pSign = *i;
COOXMLSignature* pSign = oVerifier.GetSignature(i);
int nRes = pSign->GetValid();
XML_UNUSED(pSign);
XML_UNUSED(nRes);
pSign = pSign;
nRes = nRes;
}
XML_UNUSED(nCount);
}
}

View File

@ -10,26 +10,8 @@ CORE_ROOT_DIR = $$PWD/../../../../
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
DEFINES -= UNICODE
DEFINES += \
LIBXML_READER_ENABLED \
LIBXML_PUSH_ENABLED \
LIBXML_HTML_ENABLED \
LIBXML_XPATH_ENABLED \
LIBXML_OUTPUT_ENABLED \
LIBXML_C14N_ENABLED \
LIBXML_SAX1_ENABLED \
LIBXML_TREE_ENABLED \
LIBXML_XPTR_ENABLED \
LIBXML_STATIC
SOURCES += main.cpp
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxml
INCLUDEPATH += \
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include \
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include/libxml
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -looxmlsignature

View File

@ -45,8 +45,7 @@ namespace TestDocsWithChart
{
static void Main(string[] args)
{
getFilesConditional();
//getFilesPivot();
getFilesPivot();
//getFilesAlternateContent();
//getFiles();
//convertFiles();
@ -75,45 +74,6 @@ namespace TestDocsWithChart
}
}
static void getFilesConditional()
{
//string sFindText = "conditionalFormatting";
//string sDirInput = @"\\192.168.3.208\allusers\Files\XLSX";
//string sDirOutput = @"D:\Files\Conditional";
string sFindText = "type=\"expression\"";
string sDirInput = @"D:\Files\Conditional";
string sDirOutput = @"D:\Files\ConditionalFormulaExpression";
String[] allfiles = System.IO.Directory.GetFiles(sDirInput, "*.*", System.IO.SearchOption.AllDirectories);
for (var i = 0; i < allfiles.Length; ++i)
{
string file = allfiles[i];
try
{
ZipArchive zip = ZipFile.OpenRead(file);
string sOutputPath = Path.Combine(sDirOutput, Path.GetFileName(file));
foreach (ZipArchiveEntry entry in zip.Entries)
{
if (entry.FullName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
{
using (StreamReader reader = new StreamReader(entry.Open(), Encoding.UTF8))
{
string sXml = reader.ReadToEnd();
if (-1 != sXml.IndexOf(sFindText))
{
System.IO.File.Copy(file, sOutputPath, true);
}
}
}
}
}
catch (Exception e)
{
}
}
}
static void getFilesAlternateContent()
{
string sAlternateContent = ":Choice ";