mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
13 Commits
core-windo
...
v4.4.0.185
| Author | SHA1 | Date | |
|---|---|---|---|
| 227d4f18d6 | |||
| 36bdbad685 | |||
| 525b828540 | |||
| f64ee80a1a | |||
| f6402813c4 | |||
| 224ac7d6e2 | |||
| 2e2bd8989d | |||
| 8f434efb95 | |||
| 244dafb02b | |||
| 149a1bdbd5 | |||
| a79d9041bc | |||
| 3954c42602 | |||
| 29dc0aee32 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,6 +20,7 @@ Common/3dParty/v8/win_32
|
||||
Common/3dParty/v8/linux_64
|
||||
Common/3dParty/v8/linux_32
|
||||
Common/3dParty/v8/mac_64
|
||||
Common/3dParty/openssl/openssl
|
||||
**/core_build
|
||||
**/Release
|
||||
**/Debug
|
||||
|
||||
15
.travis.yml
15
.travis.yml
@ -1 +1,14 @@
|
||||
language: cpp
|
||||
language: cpp
|
||||
compiler: gcc
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- p7zip-full
|
||||
script:
|
||||
- exit 0
|
||||
# Build fails anyway. See explanation in
|
||||
# https://github.com/ONLYOFFICE/core/pull/29#issuecomment-306773327
|
||||
- cd Common/3dParty && ./make.sh
|
||||
- cd ../../
|
||||
- make
|
||||
@ -137,7 +137,7 @@ namespace PPTX
|
||||
pWriter->WriteLimit2(4, m_oDrawAspect);
|
||||
pWriter->WriteLimit2(5, m_oType);
|
||||
pWriter->WriteLimit2(6, m_oUpdateMode);
|
||||
if (ole_file.IsInit() == false || ole_file->isMsPackage() == false)
|
||||
if (ole_file.IsInit() && ole_file->isMsPackage() == false)
|
||||
{
|
||||
std::wstring sExt = ole_file->filename().GetExtention(false);
|
||||
if (!sExt.empty())
|
||||
|
||||
@ -189,8 +189,8 @@ namespace PPTX
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("lvl"), lvl)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("algn"), algn)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("fontAlgn"),fontAlgn)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marL"), marR)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marR"), marL)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marL"), marL)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marR"), marR)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("indent"), indent)
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("defTabSz"),defTabSz)
|
||||
WritingElement_ReadAttributes_End ( oReader )
|
||||
@ -541,4 +541,4 @@ namespace PPTX
|
||||
} // namespace Logic
|
||||
} // namespace PPTX
|
||||
|
||||
#endif // PPTX_LOGIC_TEXTPARAGRAPHPR_INCLUDE_H_
|
||||
#endif // PPTX_LOGIC_TEXTPARAGRAPHPR_INCLUDE_H_
|
||||
|
||||
12
Common/3dParty/openssl/build.sh
Normal file
12
Common/3dParty/openssl/build.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=`pwd`/depot_tools:"$PATH"
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
cd "$SCRIPTPATH"/openssl
|
||||
|
||||
perl ./Configure linux-64
|
||||
./config
|
||||
make
|
||||
8
Common/3dParty/openssl/fetch.sh
Normal file
8
Common/3dParty/openssl/fetch.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
cd "$SCRIPTPATH"
|
||||
|
||||
git clone https://github.com/openssl/openssl.git
|
||||
@ -1099,6 +1099,14 @@ namespace OOX
|
||||
et_x_ExternalSheetData,
|
||||
et_x_ExternalRow,
|
||||
et_x_ExternalCell,
|
||||
et_x_OleLink,
|
||||
et_x_OleItems,
|
||||
et_x_OleItem,
|
||||
et_x_DdeLink,
|
||||
et_x_DdeItems,
|
||||
et_x_DdeItem,
|
||||
et_x_DdeValues,
|
||||
et_x_DdeValue,
|
||||
et_x_Selection,
|
||||
et_x_LegacyDrawingWorksheet,
|
||||
et_x_LegacyDrawingHFWorksheet,
|
||||
|
||||
@ -68,7 +68,35 @@ namespace OOX
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
};
|
||||
class ExternalOleObject : public External
|
||||
{
|
||||
public:
|
||||
ExternalOleObject()
|
||||
{
|
||||
}
|
||||
ExternalOleObject(const CPath& uri)
|
||||
{
|
||||
read(uri);
|
||||
}
|
||||
~ExternalOleObject()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const FileType type() const
|
||||
{
|
||||
return OOX::FileTypes::OleObject;
|
||||
}
|
||||
virtual const CPath DefaultDirectory() const
|
||||
{
|
||||
return type().DefaultDirectory();
|
||||
}
|
||||
virtual const CPath DefaultFileName() const
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
};
|
||||
}// namespace Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
#endif // OOX_EXTERNALLINKPATH_INCLUDE_H_
|
||||
#endif // OOX_EXTERNALLINKPATH_INCLUDE_H_
|
||||
|
||||
@ -76,8 +76,8 @@ namespace OOX
|
||||
writer.WriteString(L"<sheetNames>");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
writer.WriteString(L"<sheetName ");
|
||||
writer.WriteEncodeXmlString(m_arrItems[i]->ToString());
|
||||
writer.WriteString(L"<sheetName");
|
||||
WritingStringAttrEncodeXmlString(L"val", m_arrItems[i]->ToString2());
|
||||
writer.WriteString(L"/>");
|
||||
}
|
||||
writer.WriteString(L"</sheetNames>");
|
||||
@ -552,6 +552,529 @@ namespace OOX
|
||||
nullable<CExternalSheetDataSet > m_oSheetDataSet;
|
||||
};
|
||||
|
||||
class CDdeValue : public WritingElementWithChilds<CText>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CDdeValue)
|
||||
CDdeValue()
|
||||
{
|
||||
}
|
||||
virtual ~CDdeValue()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes(oReader);
|
||||
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"val" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new CText(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<value");
|
||||
WritingStringNullableAttrString(L"t", m_oType, m_oType->ToString());
|
||||
writer.WriteString(L">");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML2(writer, L"val");
|
||||
}
|
||||
writer.WriteString(L"</value>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_DdeValue;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_ReadSingle( oReader, _T("t"), m_oType )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<SimpleTypes::Spreadsheet::CDdeValueType<> > m_oType;
|
||||
};
|
||||
|
||||
class CDdeValues : public WritingElementWithChilds<CDdeValue>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CDdeValues)
|
||||
CDdeValues()
|
||||
{
|
||||
}
|
||||
virtual ~CDdeValues()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes(oReader);
|
||||
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"value" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new CDdeValue(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<values");
|
||||
WritingStringNullableAttrInt(L"rows", m_oRows, m_oRows->GetValue());
|
||||
WritingStringNullableAttrInt(L"cols", m_oCols, m_oCols->GetValue());
|
||||
writer.WriteString(L">");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</values>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_DdeValues;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if( oReader, _T("rows"), m_oRows )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("cols"), m_oCols )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRows;
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCols;
|
||||
};
|
||||
|
||||
class CDdeItem : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CDdeItem)
|
||||
CDdeItem()
|
||||
{
|
||||
}
|
||||
virtual ~CDdeItem()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes(oReader);
|
||||
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"values" == sName)
|
||||
{
|
||||
m_oDdeValues = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<ddeItem");
|
||||
WritingStringNullableAttrEncodeXmlString(L"name", m_oName, m_oName.get());
|
||||
WritingStringNullableAttrBool(L"ole", m_oOle);
|
||||
WritingStringNullableAttrBool(L"advise", m_oAdvise);
|
||||
WritingStringNullableAttrBool(L"preferPic", m_oPreferPic);
|
||||
writer.WriteString(L">");
|
||||
if (m_oDdeValues.IsInit())
|
||||
{
|
||||
m_oDdeValues->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</ddeItem>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_OleItem;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if( oReader, _T("name"), m_oName )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("ole"), m_oOle )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("advise"), m_oAdvise )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("preferPic"), m_oPreferPic )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<std::wstring > m_oName;
|
||||
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oOle;
|
||||
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oAdvise;
|
||||
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oPreferPic;
|
||||
|
||||
nullable<CDdeValues> m_oDdeValues;
|
||||
};
|
||||
|
||||
class CDdeItems : public WritingElementWithChilds<CDdeItem>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CDdeItems)
|
||||
CDdeItems()
|
||||
{
|
||||
}
|
||||
virtual ~CDdeItems()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"ddeItem" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new CDdeItem(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<ddeItems>");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</ddeItems>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_DdeItems;
|
||||
}
|
||||
};
|
||||
|
||||
class CDdeLink : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CDdeLink)
|
||||
CDdeLink()
|
||||
{
|
||||
}
|
||||
virtual ~CDdeLink()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes(oReader);
|
||||
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"ddeItems" == sName)
|
||||
{
|
||||
m_oDdeItems = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<ddeLink xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
|
||||
WritingStringNullableAttrEncodeXmlString(L"ddeService", m_oDdeService, m_oDdeService.get());
|
||||
WritingStringNullableAttrEncodeXmlString(L"ddeTopic", m_oDdeTopic, m_oDdeTopic.get());
|
||||
writer.WriteString(L">");
|
||||
if (m_oDdeItems.IsInit())
|
||||
{
|
||||
m_oDdeItems->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</ddeLink>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_DdeLink;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if( oReader, _T("ddeService"), m_oDdeService )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("ddeTopic"), m_oDdeTopic )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
|
||||
nullable<std::wstring > m_oDdeService;
|
||||
nullable<std::wstring > m_oDdeTopic;
|
||||
|
||||
nullable<CDdeItems > m_oDdeItems;
|
||||
};
|
||||
|
||||
class COleItem : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(COleItem)
|
||||
COleItem()
|
||||
{
|
||||
}
|
||||
virtual ~COleItem()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes(oReader);
|
||||
|
||||
if ( !oReader.IsEmptyNode() )
|
||||
oReader.ReadTillEnd();
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<oleItem");
|
||||
WritingStringNullableAttrEncodeXmlString(L"name", m_oName, m_oName.get());
|
||||
WritingStringNullableAttrBool(L"icon", m_oIcon);
|
||||
WritingStringNullableAttrBool(L"advise", m_oAdvise);
|
||||
WritingStringNullableAttrBool(L"preferPic", m_oPreferPic);
|
||||
writer.WriteString(L"/>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_OleItem;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if( oReader, _T("name"), m_oName )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("icon"), m_oIcon )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("advise"), m_oAdvise )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("preferPic"), m_oPreferPic )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<std::wstring > m_oName;
|
||||
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oIcon;
|
||||
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oAdvise;
|
||||
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oPreferPic;
|
||||
};
|
||||
|
||||
class COleItems : public WritingElementWithChilds<COleItem>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(COleItems)
|
||||
COleItems()
|
||||
{
|
||||
}
|
||||
virtual ~COleItems()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"oleItem" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new COleItem(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<oleItems>");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</oleItems>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_OleItems;
|
||||
}
|
||||
};
|
||||
|
||||
class COleLink : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(COleLink)
|
||||
COleLink()
|
||||
{
|
||||
}
|
||||
virtual ~COleLink()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& oNode)
|
||||
{
|
||||
// TO DO: Реализовать
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
ReadAttributes(oReader);
|
||||
|
||||
if ( oReader.IsEmptyNode() )
|
||||
return;
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"oleItems" == sName)
|
||||
{
|
||||
m_oOleItems = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<oleLink xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
|
||||
WritingStringNullableAttrString(L"r:id", m_oRid, m_oRid->ToString());
|
||||
WritingStringNullableAttrEncodeXmlString(L"progId", m_oProgId, m_oProgId.get());
|
||||
writer.WriteString(L">");
|
||||
if (m_oOleItems.IsInit())
|
||||
{
|
||||
m_oOleItems->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</oleLink>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_OleLink;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if( oReader, _T("r:id"), m_oRid )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("progId"), m_oProgId )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
|
||||
nullable<SimpleTypes::CRelationshipId > m_oRid;
|
||||
nullable<std::wstring > m_oProgId;
|
||||
|
||||
nullable<COleItems > m_oOleItems;
|
||||
};
|
||||
|
||||
class CExternalLink : public OOX::FileGlobalEnumerated, public OOX::IFileContainer
|
||||
{
|
||||
public:
|
||||
@ -604,6 +1127,14 @@ namespace OOX
|
||||
{
|
||||
m_oExternalBook = oReader;
|
||||
}
|
||||
else if ( _T("oleLink") == sName )
|
||||
{
|
||||
m_oOleLink = oReader;
|
||||
}
|
||||
else if ( _T("ddeLink") == sName )
|
||||
{
|
||||
m_oDdeLink = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -615,10 +1146,18 @@ namespace OOX
|
||||
sXml.WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
|
||||
sXml.WriteString(_T("<externalLink xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">"));
|
||||
|
||||
if(m_oExternalBook.IsInit())
|
||||
if (m_oExternalBook.IsInit())
|
||||
{
|
||||
m_oExternalBook->toXML(sXml);
|
||||
}
|
||||
if (m_oOleLink.IsInit())
|
||||
{
|
||||
m_oOleLink->toXML(sXml);
|
||||
}
|
||||
if (m_oDdeLink.IsInit())
|
||||
{
|
||||
m_oDdeLink->toXML(sXml);
|
||||
}
|
||||
|
||||
sXml.WriteString(_T("</externalLink>"));
|
||||
|
||||
@ -651,6 +1190,8 @@ namespace OOX
|
||||
}
|
||||
|
||||
nullable<CExternalBook> m_oExternalBook;
|
||||
nullable<COleLink> m_oOleLink;
|
||||
nullable<CDdeLink> m_oDdeLink;
|
||||
private:
|
||||
CPath m_oReadPath;
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
|
||||
@ -161,7 +161,16 @@ namespace OOX
|
||||
else if ( pRelation->Type() == OOX::FileTypes::ExternalLinkPath)
|
||||
return smart_ptr<OOX::File>(new ExternalLinkPath( oRelationFilename ));
|
||||
else if ( pRelation->Type() == OOX::FileTypes::OleObject)
|
||||
return smart_ptr<OOX::File>(new OOX::OleObject( oFileName ));
|
||||
{
|
||||
if (pRelation->IsExternal())
|
||||
{
|
||||
return smart_ptr<OOX::File>(new OOX::OleObject( oRelationFilename ));
|
||||
}
|
||||
else
|
||||
{
|
||||
return smart_ptr<OOX::File>(new OOX::OleObject( oFileName ));
|
||||
}
|
||||
}
|
||||
else if ( pRelation->Type() == OOX::FileTypes::Data)
|
||||
return smart_ptr<OOX::File>(new OOX::CDiagramData( oRootPath, oFileName ));
|
||||
else if ( pRelation->Type() == OOX::FileTypes::DiagDrawing)
|
||||
|
||||
@ -2608,5 +2608,48 @@ namespace SimpleTypes
|
||||
SimpleType_FromString (EPaneState)
|
||||
SimpleType_Operator_Equal (CPaneState)
|
||||
};
|
||||
|
||||
enum EDdeValueType
|
||||
{
|
||||
ddevaluetypeNil = 0,
|
||||
ddevaluetypeB = 1,
|
||||
ddevaluetypeN = 2,
|
||||
ddevaluetypeE = 3,
|
||||
ddevaluetypeStr = 4
|
||||
};
|
||||
|
||||
template<EDdeValueType eDefValue = ddevaluetypeNil>
|
||||
class CDdeValueType : public CSimpleType<EDdeValueType, eDefValue>
|
||||
{
|
||||
public:
|
||||
CDdeValueType() {}
|
||||
|
||||
virtual EDdeValueType FromString(std::wstring &sValue)
|
||||
{
|
||||
if ( _T("nil") == sValue ) this->m_eValue = ddevaluetypeNil;
|
||||
else if ( _T("b") == sValue ) this->m_eValue = ddevaluetypeB;
|
||||
else if ( _T("n") == sValue ) this->m_eValue = ddevaluetypeN;
|
||||
else if ( _T("e") == sValue ) this->m_eValue = ddevaluetypeE;
|
||||
else if ( _T("str") == sValue ) this->m_eValue = ddevaluetypeStr;
|
||||
else this->m_eValue = eDefValue;
|
||||
return this->m_eValue;
|
||||
}
|
||||
|
||||
virtual std::wstring ToString () const
|
||||
{
|
||||
switch(this->m_eValue)
|
||||
{
|
||||
case ddevaluetypeNil : return _T("nil");
|
||||
case ddevaluetypeB : return _T("b");
|
||||
case ddevaluetypeN : return _T("n");
|
||||
case ddevaluetypeE : return _T("e");
|
||||
case ddevaluetypeStr : return _T("str");
|
||||
default : return _T("nil");
|
||||
}
|
||||
}
|
||||
|
||||
SimpleType_FromString (EDdeValueType)
|
||||
SimpleType_Operator_Equal (CDdeValueType)
|
||||
};
|
||||
};// Spreadsheet
|
||||
} // SimpleTypes
|
||||
|
||||
@ -745,6 +745,7 @@
|
||||
#define ASC_MENU_EVENT_TYPE_USER_ZOOM 301
|
||||
|
||||
#define ASC_MENU_EVENT_TYPE_INSERT_CHART 400
|
||||
#define ASC_MENU_EVENT_TYPE_GET_CHART_DATA 450
|
||||
|
||||
#define ASC_MENU_EVENT_TYPE_ERROR 500
|
||||
|
||||
|
||||
@ -452,6 +452,14 @@ namespace NSStringExt
|
||||
|
||||
return arrElements;
|
||||
}
|
||||
static inline void ToLower(std::string& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towlower);
|
||||
}
|
||||
static inline void ToUpper(std::string& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towupper);
|
||||
}
|
||||
static inline void ToLower(std::wstring& wsString)
|
||||
{
|
||||
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towlower);
|
||||
|
||||
@ -8,6 +8,27 @@
|
||||
#define OOXML_HASH_ALG_SHA1 0
|
||||
#define OOXML_HASH_ALG_INVALID 1
|
||||
|
||||
class Q_DECL_EXPORT ICertificateSelectDialogOpenSsl
|
||||
{
|
||||
public:
|
||||
ICertificateSelectDialogOpenSsl()
|
||||
{
|
||||
}
|
||||
virtual ~ICertificateSelectDialogOpenSsl()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::wstring GetCertificatePath() = 0;
|
||||
virtual std::wstring GetCertificatePassword() = 0;
|
||||
|
||||
virtual std::wstring GetKeyPath() = 0;
|
||||
virtual std::wstring GetKeyPassword() = 0;
|
||||
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate() = 0;
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT CCertificateInfo
|
||||
{
|
||||
public:
|
||||
@ -58,6 +79,8 @@ public:
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate() = 0;
|
||||
|
||||
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog) {}
|
||||
|
||||
static CCertificateInfo GetDefault();
|
||||
static ICertificate* GetById(const std::string& id);
|
||||
|
||||
|
||||
@ -46,3 +46,13 @@ core_windows {
|
||||
LIBS += -lAdvapi32
|
||||
|
||||
}
|
||||
|
||||
core_linux {
|
||||
|
||||
DEFINES += XMLSEC_OPENSSL_110
|
||||
INCLUDEPATH += $$CORE_ROOT_DIR/Common/3dParty/openssl/openssl/include
|
||||
|
||||
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lssl
|
||||
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lcrypto
|
||||
|
||||
}
|
||||
|
||||
@ -4,65 +4,204 @@
|
||||
#include "./include/XmlCertificate.h"
|
||||
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/String.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/engine.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/conf.h>
|
||||
|
||||
#define OPEN_SSL_WARNING_OK 0
|
||||
#define OPEN_SSL_WARNING_ERR 1
|
||||
#define OPEN_SSL_WARNING_ALL_OK 2
|
||||
#define OPEN_SSL_WARNING_PASS 4
|
||||
|
||||
class CCertificate_openssl : public ICertificate
|
||||
{
|
||||
public:
|
||||
|
||||
protected:
|
||||
ICertificateSelectDialogOpenSsl* m_pDialog;
|
||||
|
||||
BYTE* m_rawData;
|
||||
int m_rawDataLen;
|
||||
|
||||
X509* m_cert;
|
||||
EVP_PKEY* m_key;
|
||||
|
||||
public:
|
||||
CCertificate_openssl() : ICertificate()
|
||||
{
|
||||
m_pDialog = NULL;
|
||||
|
||||
m_rawData = NULL;
|
||||
m_rawDataLen = 0;
|
||||
|
||||
m_cert = NULL;
|
||||
m_key = NULL;
|
||||
}
|
||||
virtual ~CCertificate_openssl()
|
||||
{
|
||||
{
|
||||
if (NULL != m_cert)
|
||||
X509_free(m_cert);
|
||||
if (NULL != m_key)
|
||||
EVP_PKEY_free(m_key);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string GetNumber()
|
||||
{
|
||||
return "";
|
||||
if (NULL == m_cert)
|
||||
return "";
|
||||
|
||||
ASN1_INTEGER* asn1_serial = X509_get_serialNumber(m_cert);
|
||||
if (asn1_serial == NULL)
|
||||
return "";
|
||||
|
||||
BIGNUM* bn = ASN1_INTEGER_to_BN(asn1_serial, NULL);
|
||||
if (!bn)
|
||||
{
|
||||
ASN1_INTEGER_free(asn1_serial);
|
||||
return "";
|
||||
}
|
||||
|
||||
char *tmp = BN_bn2dec(bn);
|
||||
std::string sReturn(tmp);
|
||||
|
||||
BN_free(bn);
|
||||
ASN1_INTEGER_free(asn1_serial);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
virtual std::wstring GetSignerName()
|
||||
{
|
||||
return L"";
|
||||
if (NULL == m_cert)
|
||||
return L"";
|
||||
|
||||
X509_NAME* name = X509_get_issuer_name(m_cert);
|
||||
char* utf_8_name = X509_NAME_oneline(name, NULL, 0);
|
||||
|
||||
std::string sName(utf_8_name);
|
||||
std::wstring sNameW = UTF8_TO_U(sName);
|
||||
|
||||
OPENSSL_free(utf_8_name);
|
||||
|
||||
return sNameW;
|
||||
}
|
||||
|
||||
virtual std::string GetCertificateBase64()
|
||||
{
|
||||
return "";
|
||||
if (NULL == m_cert)
|
||||
return "";
|
||||
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
PEM_write_bio_X509_AUX(bio, m_cert);
|
||||
|
||||
unsigned char *data;
|
||||
unsigned int len = 0;
|
||||
len = BIO_get_mem_data(bio, &data);
|
||||
|
||||
std::string sReturn((char*)data, (size_t)len);
|
||||
|
||||
BIO_free(bio);
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
virtual std::string GetCertificateHash()
|
||||
{
|
||||
std::string sBase64 = GetCertificateBase64();
|
||||
BYTE* pData = NULL;
|
||||
int nLen = 0;
|
||||
if (NSFile::CBase64Converter::Decode(sBase64.c_str(), (int)sBase64.length(), pData, nLen))
|
||||
{
|
||||
std::string sHash = GetHash(pData, (unsigned int)nLen, OOXML_HASH_ALG_SHA1);
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sHash;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual std::string GetDate()
|
||||
{
|
||||
return "";
|
||||
if (NULL == m_cert)
|
||||
return "";
|
||||
|
||||
ASN1_TIME* _time1 = X509_get_notBefore(m_cert);
|
||||
struct tm t1 = this->ASN1_GetTimeT(_time1);
|
||||
ASN1_TIME_free(_time1);
|
||||
|
||||
ASN1_TIME* _time2 = X509_get_notAfter(m_cert);
|
||||
struct tm t2 = this->ASN1_GetTimeT(_time2);
|
||||
ASN1_TIME_free(_time2);
|
||||
|
||||
std::string sRet = std::to_string(t1.tm_mday) +
|
||||
"/" +
|
||||
std::to_string(t1.tm_mon + 1) +
|
||||
"/" +
|
||||
std::to_string(t1.tm_year + 1900) +
|
||||
" - " +
|
||||
std::to_string(t1.tm_mday) +
|
||||
"/" +
|
||||
std::to_string(t2.tm_mon + 1) +
|
||||
"/" +
|
||||
std::to_string(t2.tm_year + 1900);
|
||||
return sRet;
|
||||
}
|
||||
|
||||
virtual std::string GetId()
|
||||
{
|
||||
return "";
|
||||
// TODO: + public key?
|
||||
return GetNumber();
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string Sign(const std::string& sXml)
|
||||
{
|
||||
return "";
|
||||
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
|
||||
const EVP_MD* pDigest = EVP_sha1();
|
||||
|
||||
int n1 = EVP_SignInit(pCtx, pDigest);
|
||||
n1 = n1;
|
||||
|
||||
int n2 = EVP_SignUpdate(pCtx, sXml.c_str(), sXml.length());
|
||||
n2 = n2;
|
||||
|
||||
BYTE pSignature[4096];
|
||||
unsigned int nSignatureLen = 0;
|
||||
|
||||
int n3 = EVP_SignFinal(pCtx, pSignature, &nSignatureLen, m_key);
|
||||
n3 = n3;
|
||||
|
||||
EVP_MD_CTX_destroy(pCtx);
|
||||
|
||||
return std::string((char*)pSignature, (size_t)nSignatureLen);
|
||||
}
|
||||
|
||||
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
|
||||
{
|
||||
if (nAlg == OOXML_HASH_ALG_SHA1)
|
||||
{
|
||||
unsigned char obuf[20];
|
||||
SHA1(pData, (size_t)nSize, obuf);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(obuf, 20, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
std::string sReturn(pBase64_hash, nBase64Len_hash);
|
||||
delete [] pBase64_hash;
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -88,24 +227,324 @@ public:
|
||||
|
||||
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
|
||||
{
|
||||
return false;
|
||||
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
|
||||
const EVP_MD* pDigest = EVP_sha1();
|
||||
|
||||
int n1 = EVP_VerifyInit(pCtx, pDigest);
|
||||
n1 = n1;
|
||||
|
||||
BYTE* pDigestValue = NULL;
|
||||
int nDigestLen = 0;
|
||||
NSFile::CBase64Converter::Decode(sXmlSignature.c_str(), (int)sXmlSignature.length(), pDigestValue, nDigestLen);
|
||||
|
||||
int n2 = EVP_VerifyUpdate(pCtx, pDigestValue, (size_t)nDigestLen);
|
||||
n2 = n2;
|
||||
|
||||
EVP_PKEY* pubkey = X509_get_pubkey(m_cert);
|
||||
|
||||
int n3 = EVP_VerifyFinal(pCtx, (BYTE*)sXml.c_str(), (unsigned int)sXml.length(), pubkey);
|
||||
n3 = n3;
|
||||
|
||||
EVP_MD_CTX_destroy(pCtx);
|
||||
EVP_PKEY_free(pubkey);
|
||||
|
||||
RELEASEARRAYOBJECTS(pDigestValue);
|
||||
|
||||
return (1 == n3) ? true : false;
|
||||
}
|
||||
|
||||
virtual bool LoadFromBase64Data(const std::string& data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BYTE* pData = NULL;
|
||||
int nLen = 0;
|
||||
if (NSFile::CBase64Converter::Decode(data.c_str(), (int)data.length(), pData, nLen))
|
||||
{
|
||||
X509* pCert = NULL;
|
||||
int nErr = LoadCert(pData, (DWORD)nLen, "", &pCert);
|
||||
|
||||
virtual int ShowCertificate()
|
||||
{
|
||||
return 1;
|
||||
if (nErr == OPEN_SSL_WARNING_OK || nErr == OPEN_SSL_WARNING_ALL_OK)
|
||||
{
|
||||
m_cert = pCert;
|
||||
}
|
||||
else
|
||||
{
|
||||
X509_free(pCert);
|
||||
m_cert = NULL;
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return (NULL == m_cert) ? false : true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog()
|
||||
{
|
||||
if (m_pDialog)
|
||||
return m_pDialog->ShowSelectDialog();
|
||||
return false;
|
||||
}
|
||||
virtual int ShowCertificate()
|
||||
{
|
||||
if (m_pDialog)
|
||||
return m_pDialog->ShowCertificate();
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog)
|
||||
{
|
||||
m_pDialog = pDialog;
|
||||
}
|
||||
|
||||
protected:
|
||||
tm ASN1_GetTimeT(ASN1_TIME* time)
|
||||
{
|
||||
struct tm t;
|
||||
const char* str = (const char*) time->data;
|
||||
size_t i = 0;
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
if (time->type == V_ASN1_UTCTIME)
|
||||
{
|
||||
/* two digit year */
|
||||
t.tm_year = (str[i++] - '0') * 10;
|
||||
t.tm_year += (str[i++] - '0');
|
||||
if (t.tm_year < 70)
|
||||
t.tm_year += 100;
|
||||
}
|
||||
else if (time->type == V_ASN1_GENERALIZEDTIME)
|
||||
{
|
||||
/* four digit year */
|
||||
t.tm_year = (str[i++] - '0') * 1000;
|
||||
t.tm_year+= (str[i++] - '0') * 100;
|
||||
t.tm_year+= (str[i++] - '0') * 10;
|
||||
t.tm_year+= (str[i++] - '0');
|
||||
t.tm_year -= 1900;
|
||||
}
|
||||
t.tm_mon = (str[i++] - '0') * 10;
|
||||
t.tm_mon += (str[i++] - '0') - 1; // -1 since January is 0 not 1.
|
||||
t.tm_mday = (str[i++] - '0') * 10;
|
||||
t.tm_mday+= (str[i++] - '0');
|
||||
t.tm_hour = (str[i++] - '0') * 10;
|
||||
t.tm_hour+= (str[i++] - '0');
|
||||
t.tm_min = (str[i++] - '0') * 10;
|
||||
t.tm_min += (str[i++] - '0');
|
||||
t.tm_sec = (str[i++] - '0') * 10;
|
||||
t.tm_sec += (str[i++] - '0');
|
||||
|
||||
/* Note: we did not adjust the time based on time zone information */
|
||||
return t;
|
||||
}
|
||||
|
||||
public:
|
||||
static std::string GetOpenSslErrors()
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
ERR_print_errors(bio);
|
||||
char *buf = NULL;
|
||||
size_t len = BIO_get_mem_data(bio, &buf);
|
||||
std::string sRet((char*)buf, len);
|
||||
NSStringExt::ToLower(sRet);
|
||||
BIO_free (bio);
|
||||
return sRet;
|
||||
}
|
||||
static bool IsOpenSslPasswordError(const std::string& str)
|
||||
{
|
||||
if (std::string::npos != str.find("mac verify error"))
|
||||
return true;
|
||||
if (std::string::npos != str.find("mac verify failure"))
|
||||
return true;
|
||||
if (std::string::npos != str.find("password"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int LoadKey(BYTE* pData, DWORD dwDataLen, std::string password, EVP_PKEY** ppKey)
|
||||
{
|
||||
int nErr = OPEN_SSL_WARNING_ERR;
|
||||
std::string sError = "";
|
||||
|
||||
PKCS12* p12 = NULL;
|
||||
EVP_PKEY* pKey = NULL;
|
||||
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
|
||||
|
||||
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (PEM_read_bio_PrivateKey(bio, &pKey, NULL, (void*)pPassword))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_OK;
|
||||
goto end;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_PASS;
|
||||
goto end;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (d2i_PrivateKey_bio(bio, &pKey))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_OK;
|
||||
goto end;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_PASS;
|
||||
goto end;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (d2i_PKCS8PrivateKey_bio(bio, &pKey, NULL, (void*)pPassword))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_OK;
|
||||
goto end;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_PASS;
|
||||
goto end;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
|
||||
p12 = d2i_PKCS12_bio(bio, NULL);
|
||||
if (p12)
|
||||
{
|
||||
X509* pCert = NULL;
|
||||
STACK_OF(X509)* pCa = NULL;
|
||||
|
||||
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
|
||||
{
|
||||
sk_X509_pop_free(pCa, X509_free);
|
||||
X509_free(pCert);
|
||||
PKCS12_free(p12);
|
||||
nErr = OPEN_SSL_WARNING_ALL_OK;
|
||||
goto end;
|
||||
}
|
||||
PKCS12_free(p12);
|
||||
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_PASS;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (NULL == ppKey)
|
||||
EVP_PKEY_free(pKey);
|
||||
else
|
||||
*ppKey = pKey;
|
||||
|
||||
BIO_free(bio);
|
||||
return nErr;
|
||||
}
|
||||
|
||||
static int LoadKey(std::wstring file, std::string password, EVP_PKEY** ppKey)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
DWORD dwDataLen;
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
|
||||
return OPEN_SSL_WARNING_ERR;
|
||||
|
||||
int nErr = LoadKey(pData, dwDataLen, password, ppKey);
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return nErr;
|
||||
}
|
||||
|
||||
static int LoadCert(BYTE* pData, DWORD dwDataLen, std::string password, X509** ppCert)
|
||||
{
|
||||
int nErr = OPEN_SSL_WARNING_ERR;
|
||||
std::string sError = "";
|
||||
|
||||
PKCS12* p12 = NULL;
|
||||
X509* pCert = NULL;
|
||||
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
|
||||
|
||||
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (PEM_read_bio_X509(bio, &pCert, NULL, (void*)pPassword))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_OK;
|
||||
goto end;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_PASS;
|
||||
goto end;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (d2i_X509_bio(bio, &pCert))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_OK;
|
||||
goto end;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_PASS;
|
||||
goto end;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
|
||||
p12 = d2i_PKCS12_bio(bio, NULL);
|
||||
if (p12)
|
||||
{
|
||||
EVP_PKEY* pKey = NULL;
|
||||
STACK_OF(X509)* pCa = NULL;
|
||||
|
||||
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
|
||||
{
|
||||
sk_X509_pop_free(pCa, X509_free);
|
||||
EVP_PKEY_free(pKey);
|
||||
PKCS12_free(p12);
|
||||
BIO_free(bio);
|
||||
nErr = OPEN_SSL_WARNING_ALL_OK;
|
||||
goto end;
|
||||
}
|
||||
|
||||
PKCS12_free(p12);
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
nErr = OPEN_SSL_WARNING_PASS;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (NULL == ppCert)
|
||||
X509_free(pCert);
|
||||
else
|
||||
*ppCert = pCert;
|
||||
|
||||
BIO_free(bio);
|
||||
return nErr;
|
||||
}
|
||||
|
||||
static int LoadCert(std::wstring file, std::string password, X509** ppCert)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
DWORD dwDataLen;
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
|
||||
return OPEN_SSL_WARNING_ERR;
|
||||
|
||||
int nErr = LoadCert(pData, dwDataLen, password, ppCert);
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return nErr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _XMLSIGNER_OPENSSL_H_
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2017-06-05T12:59:43
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
QT += widgets
|
||||
|
||||
TARGET = OpenSSL_gui_test
|
||||
TEMPLATE = app
|
||||
|
||||
DEFINES -= \
|
||||
UNICODE \
|
||||
_UNICODE
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
core_linux {
|
||||
QMAKE_LFLAGS += -Wl,--rpath=./
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
}
|
||||
|
||||
DEFINES += XMLSEC_OPENSSL_110
|
||||
#DEFINES += "OPENSSL_API_COMPAT=\"0x10100000\""
|
||||
|
||||
INCLUDEPATH += $$CORE_ROOT_DIR/Common/3dParty/openssl/openssl/include
|
||||
|
||||
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lssl
|
||||
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lcrypto
|
||||
|
||||
LIBS += -ldl
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h
|
||||
|
||||
HEADERS += opensslwrapper.h
|
||||
SOURCES += opensslwrapper.cpp
|
||||
11
DesktopEditor/xmlsec/test/OpenSSL_gui_test/main.cpp
Normal file
11
DesktopEditor/xmlsec/test/OpenSSL_gui_test/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
110
DesktopEditor/xmlsec/test/OpenSSL_gui_test/mainwindow.cpp
Normal file
110
DesktopEditor/xmlsec/test/OpenSSL_gui_test/mainwindow.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QGridLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QtNetwork/QSslSocket>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent)
|
||||
{
|
||||
QRect rect = this->geometry();
|
||||
this->setGeometry(rect.x(), rect.y(), 600, 170);
|
||||
|
||||
QGridLayout *mainGridLayout = new QGridLayout();
|
||||
mainGridLayout->setSpacing( 0 );
|
||||
mainGridLayout->setMargin( 0 );
|
||||
setLayout( mainGridLayout );
|
||||
|
||||
QWidget *centralWidget = new QWidget( this );
|
||||
centralWidget->setObjectName( "centralWidget" );
|
||||
centralWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
|
||||
this->setCentralWidget(centralWidget);
|
||||
|
||||
m_pKeyFile = new QPlainTextEdit(centralWidget);
|
||||
m_pKeyPassword = new QPlainTextEdit(centralWidget);
|
||||
|
||||
m_pCertFile = new QPlainTextEdit(centralWidget);
|
||||
m_pCertPassword = new QPlainTextEdit(centralWidget);
|
||||
|
||||
m_pKeyDialog = new QPushButton(centralWidget);
|
||||
m_pCertDialog = new QPushButton(centralWidget);
|
||||
m_pOK = new QPushButton(centralWidget);
|
||||
|
||||
m_pKeyDialog->setText("...");
|
||||
m_pCertDialog->setText("...");
|
||||
m_pOK->setText("OK");
|
||||
|
||||
m_pKeyFile->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_pKeyPassword->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_pCertFile->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_pCertPassword->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
QObject::connect( m_pKeyDialog, SIGNAL( clicked() ), this, SLOT( pushButtonKeyClicked()) );
|
||||
QObject::connect( m_pCertDialog, SIGNAL( clicked() ), this, SLOT( pushButtonCertClicked()) );
|
||||
QObject::connect( m_pOK, SIGNAL( clicked() ), this, SLOT( pushButtonOKClicked()) );
|
||||
|
||||
CalculatePlaces();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
CalculatePlaces();
|
||||
}
|
||||
|
||||
void MainWindow::CalculatePlaces()
|
||||
{
|
||||
int nWidth = this->width();
|
||||
int nHeight = this->height();
|
||||
|
||||
int nWidthBetween = 30;
|
||||
int nWidthButton = 40;
|
||||
int nWidthPassword = 40;
|
||||
int nHeightLine = 30;
|
||||
int nWidthPath = nWidth - 40 - 2 * nWidthBetween - nWidthButton - nWidthPassword;
|
||||
if (nWidthPath < 20)
|
||||
nWidthPath = 20;
|
||||
|
||||
int nTop1 = 20;
|
||||
m_pKeyFile->setGeometry(20, nTop1, nWidthPath, nHeightLine);
|
||||
m_pKeyPassword->setGeometry(20 + nWidthPath + nWidthBetween, nTop1, nWidthPassword, nHeightLine);
|
||||
m_pKeyDialog->setGeometry(nWidth - 20 - nWidthButton, nTop1, nWidthButton, nHeightLine);
|
||||
|
||||
nTop1 = 20 + nHeightLine + 20;
|
||||
m_pCertFile->setGeometry(20, nTop1, nWidthPath, nHeightLine);
|
||||
m_pCertPassword->setGeometry(20 + nWidthPath + nWidthBetween, nTop1, nWidthPassword, nHeightLine);
|
||||
m_pCertDialog->setGeometry(nWidth - 20 - nWidthButton, nTop1, nWidthButton, nHeightLine);
|
||||
|
||||
m_pOK->setGeometry((nWidth - 40) >> 1, nTop1 + nHeightLine + 20, 40, nHeightLine);
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonKeyClicked()
|
||||
{
|
||||
std::wstring sFile = QFileDialog::getOpenFileName(NULL, QString(), QString()).toStdWString();
|
||||
if (sFile.empty())
|
||||
return;
|
||||
|
||||
m_pKeyFile->setPlainText(QString::fromStdWString(sFile));
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonCertClicked()
|
||||
{
|
||||
std::wstring sFile = QFileDialog::getOpenFileName(NULL, QString(), QString()).toStdWString();
|
||||
if (sFile.empty())
|
||||
return;
|
||||
|
||||
m_pCertFile->setPlainText(QString::fromStdWString(sFile));
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonOKClicked()
|
||||
{
|
||||
COpenssl_library library;
|
||||
int nKeyValue = library.LoadKey(m_pKeyFile->toPlainText().toStdWString(), m_pKeyPassword->toPlainText().toStdString());
|
||||
int nCertValue = library.LoadCert(m_pCertFile->toPlainText().toStdWString(), m_pCertPassword->toPlainText().toStdString());
|
||||
|
||||
int y = 0;
|
||||
y++;
|
||||
}
|
||||
44
DesktopEditor/xmlsec/test/OpenSSL_gui_test/mainwindow.h
Normal file
44
DesktopEditor/xmlsec/test/OpenSSL_gui_test/mainwindow.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QResizeEvent>
|
||||
#include <QPlainTextEdit>
|
||||
#include "opensslwrapper.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
virtual void resizeEvent(QResizeEvent*);
|
||||
void CalculatePlaces();
|
||||
|
||||
public:
|
||||
|
||||
QPlainTextEdit* m_pKeyFile;
|
||||
QPlainTextEdit* m_pKeyPassword;
|
||||
QPushButton* m_pKeyDialog;
|
||||
|
||||
QPlainTextEdit* m_pCertFile;
|
||||
QPlainTextEdit* m_pCertPassword;
|
||||
QPushButton* m_pCertDialog;
|
||||
|
||||
QPushButton* m_pOK;
|
||||
|
||||
public slots:
|
||||
void pushButtonKeyClicked();
|
||||
void pushButtonCertClicked();
|
||||
void pushButtonOKClicked();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
247
DesktopEditor/xmlsec/test/OpenSSL_gui_test/opensslwrapper.cpp
Normal file
247
DesktopEditor/xmlsec/test/OpenSSL_gui_test/opensslwrapper.cpp
Normal file
@ -0,0 +1,247 @@
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/engine.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/conf.h>
|
||||
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/String.h"
|
||||
#include "opensslwrapper.h"
|
||||
|
||||
class COpenssl_library_private
|
||||
{
|
||||
private:
|
||||
static bool m_bInit;
|
||||
|
||||
public:
|
||||
EVP_PKEY* m_key;
|
||||
|
||||
public:
|
||||
COpenssl_library_private()
|
||||
{
|
||||
if (!m_bInit)
|
||||
{
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_BIO_strings();
|
||||
ERR_load_crypto_strings();
|
||||
m_bInit = true;
|
||||
}
|
||||
}
|
||||
~COpenssl_library_private()
|
||||
{
|
||||
ENGINE_cleanup();
|
||||
CONF_modules_unload(1);
|
||||
ERR_free_strings();
|
||||
EVP_cleanup();
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
}
|
||||
};
|
||||
|
||||
bool COpenssl_library_private::m_bInit = false;
|
||||
|
||||
std::string GetOpenSslErrors()
|
||||
{
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
ERR_print_errors(bio);
|
||||
char *buf = NULL;
|
||||
size_t len = BIO_get_mem_data(bio, &buf);
|
||||
std::string sRet((char*)buf, len);
|
||||
NSStringExt::ToLower(sRet);
|
||||
BIO_free (bio);
|
||||
return sRet;
|
||||
}
|
||||
bool IsOpenSslPasswordError(const std::string& str)
|
||||
{
|
||||
if (std::string::npos != str.find("mac verify error"))
|
||||
return true;
|
||||
if (std::string::npos != str.find("mac verify failure"))
|
||||
return true;
|
||||
if (std::string::npos != str.find("password"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
COpenssl_library::COpenssl_library()
|
||||
{
|
||||
m_internal = new COpenssl_library_private();
|
||||
}
|
||||
|
||||
COpenssl_library::~COpenssl_library()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
int COpenssl_library::LoadKey(std::wstring file, std::string password)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
DWORD dwDataLen;
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
|
||||
return OPEN_SSL_WARNING_ERR;
|
||||
|
||||
EVP_PKEY* pKey = NULL;
|
||||
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
|
||||
|
||||
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (PEM_read_bio_PrivateKey(bio, &pKey, NULL, (void*)pPassword))
|
||||
{
|
||||
EVP_PKEY_free(pKey);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
}
|
||||
std::string sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
EVP_PKEY_free(pKey);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_PASS;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (d2i_PrivateKey_bio(bio, &pKey))
|
||||
{
|
||||
EVP_PKEY_free(pKey);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
EVP_PKEY_free(pKey);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_PASS;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (d2i_PKCS8PrivateKey_bio(bio, &pKey, NULL, (void*)pPassword))
|
||||
{
|
||||
EVP_PKEY_free(pKey);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
EVP_PKEY_free(pKey);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_PASS;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
|
||||
PKCS12* p12 = d2i_PKCS12_bio(bio, NULL);
|
||||
if (p12)
|
||||
{
|
||||
X509* pCert = NULL;
|
||||
STACK_OF(X509)* pCa = NULL;
|
||||
|
||||
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
|
||||
{
|
||||
sk_X509_pop_free(pCa, X509_free);
|
||||
X509_free(pCert);
|
||||
EVP_PKEY_free(pKey);
|
||||
PKCS12_free(p12);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_ALL_OK;
|
||||
}
|
||||
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
PKCS12_free(p12);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_PASS;
|
||||
}
|
||||
|
||||
PKCS12_free(p12);
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
|
||||
return OPEN_SSL_WARNING_ERR;
|
||||
}
|
||||
|
||||
int COpenssl_library::LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
DWORD dwDataLen;
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
|
||||
return OPEN_SSL_WARNING_ERR;
|
||||
|
||||
X509* pCert = NULL;
|
||||
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
|
||||
|
||||
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (PEM_read_bio_X509(bio, &pCert, NULL, (void*)pPassword))
|
||||
{
|
||||
X509_free(pCert);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
}
|
||||
std::string sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
X509_free(pCert);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_PASS;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
if (d2i_X509_bio(bio, &pCert))
|
||||
{
|
||||
X509_free(pCert);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
}
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
X509_free(pCert);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_PASS;
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
|
||||
|
||||
PKCS12* p12 = d2i_PKCS12_bio(bio, NULL);
|
||||
if (p12)
|
||||
{
|
||||
EVP_PKEY* pKey = NULL;
|
||||
STACK_OF(X509)* pCa = NULL;
|
||||
|
||||
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
|
||||
{
|
||||
sk_X509_pop_free(pCa, X509_free);
|
||||
X509_free(pCert);
|
||||
EVP_PKEY_free(pKey);
|
||||
PKCS12_free(p12);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_ALL_OK;
|
||||
}
|
||||
|
||||
sError = GetOpenSslErrors();
|
||||
if (IsOpenSslPasswordError(sError))
|
||||
{
|
||||
PKCS12_free(p12);
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_PASS;
|
||||
}
|
||||
|
||||
PKCS12_free(p12);
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
return OPEN_SSL_WARNING_ERR;
|
||||
}
|
||||
23
DesktopEditor/xmlsec/test/OpenSSL_gui_test/opensslwrapper.h
Normal file
23
DesktopEditor/xmlsec/test/OpenSSL_gui_test/opensslwrapper.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef OPENSSL_WRAPPER
|
||||
#define OPENSSL_WRAPPER
|
||||
|
||||
#define OPEN_SSL_WARNING_OK 0
|
||||
#define OPEN_SSL_WARNING_ERR 1
|
||||
#define OPEN_SSL_WARNING_ALL_OK 2
|
||||
#define OPEN_SSL_WARNING_PASS 4
|
||||
|
||||
class COpenssl_library_private;
|
||||
class COpenssl_library
|
||||
{
|
||||
private:
|
||||
COpenssl_library_private* m_internal;
|
||||
|
||||
public:
|
||||
COpenssl_library();
|
||||
~COpenssl_library();
|
||||
|
||||
int LoadKey(std::wstring file, std::string password);
|
||||
int LoadCert(std::wstring file, std::string password);
|
||||
};
|
||||
|
||||
#endif // OPENSSL_WRAPPER
|
||||
@ -5,6 +5,7 @@
|
||||
#include <openssl/pkcs12.h>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include "../../../common/File.h"
|
||||
|
||||
@ -157,6 +158,7 @@ int main(int argc, char **argv)
|
||||
STACK_OF(X509) *ca = NULL;
|
||||
PKCS12 *p12;
|
||||
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ DEFINES += XMLSEC_OPENSSL_110
|
||||
|
||||
INCLUDEPATH += $$PWD/../../openssl/include
|
||||
|
||||
LIBS += -L$$PWD/../../openssl -lcrypto -lssl
|
||||
LIBS += -L$$PWD/../../openssl -lssl -lcrypto
|
||||
LIBS += -ldl
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
6
Makefile
6
Makefile
@ -21,11 +21,11 @@ else
|
||||
LIB_PREFIX := lib
|
||||
MAKE := make -j $(shell grep -c ^processor /proc/cpuinfo)
|
||||
endif
|
||||
UNAME_P := $(shell uname -p)
|
||||
ifeq ($(UNAME_P),x86_64)
|
||||
UNAME_M := $(shell uname -m)
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
ARCHITECTURE := 64
|
||||
endif
|
||||
ifneq ($(filter %86,$(UNAME_P)),)
|
||||
ifneq ($(filter %86,$(UNAME_M)),)
|
||||
ARCHITECTURE := 32
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -188,7 +188,9 @@ namespace BinXlsxRW
|
||||
ExternalReference = 6,
|
||||
PivotCaches = 7,
|
||||
PivotCache = 8,
|
||||
ExternalBook = 9
|
||||
ExternalBook = 9,
|
||||
OleLink = 10,
|
||||
DdeLink = 11
|
||||
};}
|
||||
namespace c_oSerWorkbookPrTypes{enum c_oSerWorkbookPrTypes
|
||||
{
|
||||
@ -841,6 +843,32 @@ namespace BinXlsxRW
|
||||
SheetDataRowCellType = 16,
|
||||
SheetDataRowCellValue = 17
|
||||
};}
|
||||
namespace c_oSer_OleLinkTypes{enum c_oSer_OleLinkTypes
|
||||
{
|
||||
Id = 0,
|
||||
ProgId = 1,
|
||||
OleItem = 2,
|
||||
Name = 3,
|
||||
Icon = 4,
|
||||
Advise = 5,
|
||||
PreferPic = 6
|
||||
};}
|
||||
namespace c_oSer_DdeLinkTypes{enum c_oSer_DdeLinkTypes
|
||||
{
|
||||
DdeService = 0,
|
||||
DdeTopic = 1,
|
||||
DdeItem = 2,
|
||||
Name = 3,
|
||||
Ole = 4,
|
||||
Advise = 5,
|
||||
PreferPic = 6,
|
||||
DdeValues = 7,
|
||||
DdeValuesRows = 8,
|
||||
DdeValuesCols = 9,
|
||||
DdeValue = 10,
|
||||
DdeValueType = 11,
|
||||
DdeValueVal = 12
|
||||
};}
|
||||
}
|
||||
|
||||
#endif //
|
||||
|
||||
@ -1587,22 +1587,50 @@ namespace BinXlsxRW
|
||||
if (pFile.IsInit() && OOX::Spreadsheet::FileTypes::ExternalLinks == pFile->type())
|
||||
{
|
||||
OOX::Spreadsheet::CExternalLink* pExternalLink = static_cast<OOX::Spreadsheet::CExternalLink*>(pFile.operator ->());
|
||||
if ((pExternalLink) && (pExternalLink->m_oExternalBook.IsInit()))
|
||||
if (pExternalLink)
|
||||
{
|
||||
std::wstring sLink;
|
||||
if (pExternalLink->m_oExternalBook->m_oRid.IsInit())
|
||||
if(pExternalLink->m_oExternalBook.IsInit())
|
||||
{
|
||||
smart_ptr<OOX::File> pFile = pExternalLink->Find( OOX::RId(pExternalLink->m_oExternalBook->m_oRid.get().GetValue()));
|
||||
if (pFile.IsInit() && OOX::FileTypes::ExternalLinkPath == pFile->type())
|
||||
std::wstring sLink;
|
||||
if (pExternalLink->m_oExternalBook->m_oRid.IsInit())
|
||||
{
|
||||
OOX::Spreadsheet::ExternalLinkPath* pLinkFile = static_cast<OOX::Spreadsheet::ExternalLinkPath*>(pFile.operator ->());
|
||||
sLink = pLinkFile->Uri().GetPath();
|
||||
smart_ptr<OOX::File> pFile = pExternalLink->Find( OOX::RId(pExternalLink->m_oExternalBook->m_oRid.get().GetValue()));
|
||||
if (pFile.IsInit() && OOX::FileTypes::ExternalLinkPath == pFile->type())
|
||||
{
|
||||
OOX::Spreadsheet::ExternalLinkPath* pLinkFile = static_cast<OOX::Spreadsheet::ExternalLinkPath*>(pFile.operator ->());
|
||||
sLink = pLinkFile->Uri().GetPath();
|
||||
}
|
||||
}
|
||||
if(!sLink.empty())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::ExternalBook);
|
||||
WriteExternalBook(pExternalLink->m_oExternalBook.get(), sLink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
if(!sLink.empty())
|
||||
else if(pExternalLink->m_oOleLink.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::ExternalBook);
|
||||
WriteExternalBook(pExternalLink->m_oExternalBook.get(), sLink);
|
||||
std::wstring sLink;
|
||||
if (pExternalLink->m_oOleLink->m_oRid.IsInit())
|
||||
{
|
||||
smart_ptr<OOX::File> pFile = pExternalLink->Find( OOX::RId(pExternalLink->m_oOleLink->m_oRid.get().GetValue()));
|
||||
if (pFile.IsInit() && OOX::FileTypes::OleObject == pFile->type())
|
||||
{
|
||||
OOX::OleObject* pLinkFile = static_cast<OOX::OleObject*>(pFile.operator ->());
|
||||
sLink = pLinkFile->filename().GetPath();
|
||||
}
|
||||
}
|
||||
if(!sLink.empty())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::OleLink);
|
||||
WriteOleLink(pExternalLink->m_oOleLink.get(), sLink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
else if(pExternalLink->m_oDdeLink.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::DdeLink);
|
||||
WriteDdeLink(pExternalLink->m_oDdeLink.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
@ -1748,6 +1776,155 @@ namespace BinXlsxRW
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteOleLink(const OOX::Spreadsheet::COleLink& oleLink, const std::wstring& sLink)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Id);
|
||||
m_oBcw.m_oStream.WriteStringW3(sLink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
|
||||
if (oleLink.m_oProgId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::ProgId);
|
||||
m_oBcw.m_oStream.WriteStringW3(oleLink.m_oProgId.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oleLink.m_oOleItems.IsInit())
|
||||
{
|
||||
for(size_t i = 0; i < oleLink.m_oOleItems->m_arrItems.size(); ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::OleItem);
|
||||
WriteOleItem(*oleLink.m_oOleItems->m_arrItems[i]);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
void WriteOleItem(const OOX::Spreadsheet::COleItem& oleItem)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (oleItem.m_oName.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Name);
|
||||
m_oBcw.m_oStream.WriteStringW3(oleItem.m_oName.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oleItem.m_oIcon.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Icon);
|
||||
m_oBcw.m_oStream.WriteBOOL(oleItem.m_oIcon->ToBool());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oleItem.m_oAdvise.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Advise);
|
||||
m_oBcw.m_oStream.WriteBOOL(oleItem.m_oAdvise->ToBool());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oleItem.m_oPreferPic.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::PreferPic);
|
||||
m_oBcw.m_oStream.WriteBOOL(oleItem.m_oPreferPic->ToBool());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteDdeLink(const OOX::Spreadsheet::CDdeLink& ddeLink)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (ddeLink.m_oDdeService.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeService);
|
||||
m_oBcw.m_oStream.WriteStringW3(ddeLink.m_oDdeService.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (ddeLink.m_oDdeTopic.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeTopic);
|
||||
m_oBcw.m_oStream.WriteStringW3(ddeLink.m_oDdeTopic.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (ddeLink.m_oDdeItems.IsInit())
|
||||
{
|
||||
for(size_t i = 0; i < ddeLink.m_oDdeItems->m_arrItems.size(); ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeItem);
|
||||
WriteDdeItem(*ddeLink.m_oDdeItems->m_arrItems[i]);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
void WriteDdeItem(const OOX::Spreadsheet::CDdeItem& ddeItem)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (ddeItem.m_oName.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::Name);
|
||||
m_oBcw.m_oStream.WriteStringW3(ddeItem.m_oName.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (ddeItem.m_oOle.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::Ole);
|
||||
m_oBcw.m_oStream.WriteBOOL(ddeItem.m_oOle->ToBool());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (ddeItem.m_oAdvise.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::Advise);
|
||||
m_oBcw.m_oStream.WriteBOOL(ddeItem.m_oAdvise->ToBool());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (ddeItem.m_oPreferPic.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::PreferPic);
|
||||
m_oBcw.m_oStream.WriteBOOL(ddeItem.m_oPreferPic->ToBool());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (ddeItem.m_oDdeValues.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValues);
|
||||
WriteDdeValues(ddeItem.m_oDdeValues.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteDdeValues(const OOX::Spreadsheet::CDdeValues& ddeValues)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (ddeValues.m_oRows.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValuesRows);
|
||||
m_oBcw.m_oStream.WriteULONG(ddeValues.m_oRows->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (ddeValues.m_oCols.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValuesCols);
|
||||
m_oBcw.m_oStream.WriteULONG(ddeValues.m_oCols->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
for(size_t i = 0; i < ddeValues.m_arrItems.size(); ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValue);
|
||||
WriteDdeValue(*ddeValues.m_arrItems[i]);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteDdeValue(const OOX::Spreadsheet::CDdeValue& ddeValue)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (ddeValue.m_oType.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValueType);
|
||||
m_oBcw.m_oStream.WriteBYTE(ddeValue.m_oType->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
for (size_t i = 0; i < ddeValue.m_arrItems.size(); ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValueVal);
|
||||
m_oBcw.m_oStream.WriteStringW3(ddeValue.m_arrItems[i]->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
|
||||
void WriteDefinedName(const OOX::Spreadsheet::CDefinedName& definedName)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
@ -2874,7 +3051,10 @@ namespace BinXlsxRW
|
||||
{
|
||||
OOX::CPath pathImage = pImageFileCache->filename();
|
||||
|
||||
olePic->oleObject->m_OleObjectFile->set_filename_cache(pathImage);
|
||||
if (olePic->oleObject->m_OleObjectFile.IsInit())
|
||||
{
|
||||
olePic->oleObject->m_OleObjectFile->set_filename_cache(pathImage);
|
||||
}
|
||||
|
||||
olePic->blipFill.blip->embed = new OOX::RId(sIdImageFileCache); //ваще то тут не важно что - приоритет у того что ниже..
|
||||
olePic->blipFill.blip->oleFilepathImage = pathImage.GetPath();
|
||||
|
||||
@ -1615,6 +1615,40 @@ namespace BinXlsxRW {
|
||||
RELEASEOBJECT(extLink)
|
||||
}
|
||||
}
|
||||
else if(c_oSerWorkbookTypes::OleLink == type)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalLink *extLink = new OOX::Spreadsheet::CExternalLink();
|
||||
extLink->m_oOleLink.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadOleLink, this, extLink);
|
||||
if (extLink->m_oOleLink->m_oRid.IsInit())
|
||||
{
|
||||
smart_ptr<OOX::File> oCurFile(extLink);
|
||||
const OOX::RId oRId = m_oWorkbook.Add(oCurFile);
|
||||
|
||||
OOX::Spreadsheet::CExternalReference* pExternalReference = new OOX::Spreadsheet::CExternalReference();
|
||||
pExternalReference->m_oRid.Init();
|
||||
pExternalReference->m_oRid->SetValue(oRId.get());
|
||||
m_oWorkbook.m_oExternalReferences->m_arrItems.push_back(pExternalReference);
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASEOBJECT(extLink)
|
||||
}
|
||||
}
|
||||
else if(c_oSerWorkbookTypes::DdeLink == type)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalLink *extLink = new OOX::Spreadsheet::CExternalLink();
|
||||
extLink->m_oDdeLink.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeLink, this, extLink->m_oDdeLink.GetPointer());
|
||||
|
||||
smart_ptr<OOX::File> oCurFile(extLink);
|
||||
const OOX::RId oRId = m_oWorkbook.Add(oCurFile);
|
||||
|
||||
OOX::Spreadsheet::CExternalReference* pExternalReference = new OOX::Spreadsheet::CExternalReference();
|
||||
pExternalReference->m_oRid.Init();
|
||||
pExternalReference->m_oRid->SetValue(oRId.get());
|
||||
m_oWorkbook.m_oExternalReferences->m_arrItems.push_back(pExternalReference);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -1832,7 +1866,173 @@ namespace BinXlsxRW {
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadOleLink(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalLink* extLink = static_cast<OOX::Spreadsheet::CExternalLink*>(poResult);
|
||||
OOX::Spreadsheet::COleLink* oleLink = extLink->m_oOleLink.GetPointer();
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_OleLinkTypes::Id == type)
|
||||
{
|
||||
std::wstring sName(m_oBufferedStream.GetString3(length));
|
||||
|
||||
OOX::Spreadsheet::ExternalOleObject *link = new OOX::Spreadsheet::ExternalOleObject(sName);
|
||||
smart_ptr<OOX::File> oLinkFile(link);
|
||||
const OOX::RId oRIdLink = extLink->Add(oLinkFile);
|
||||
|
||||
oleLink->m_oRid.Init();
|
||||
oleLink->m_oRid->SetValue(oRIdLink.get());
|
||||
}
|
||||
else if(c_oSer_OleLinkTypes::ProgId == type)
|
||||
{
|
||||
oleLink->m_oProgId.Init();
|
||||
oleLink->m_oProgId->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_OleLinkTypes::OleItem == type)
|
||||
{
|
||||
if (!oleLink->m_oOleItems.IsInit())
|
||||
{
|
||||
oleLink->m_oOleItems.Init();
|
||||
}
|
||||
OOX::Spreadsheet::COleItem* pOleItem = new OOX::Spreadsheet::COleItem();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadOleItem, this, pOleItem);
|
||||
oleLink->m_oOleItems->m_arrItems.push_back(pOleItem);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadOleItem(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::COleItem* pOleItem = static_cast<OOX::Spreadsheet::COleItem*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_OleLinkTypes::Name == type)
|
||||
{
|
||||
pOleItem->m_oName.Init();
|
||||
pOleItem->m_oName->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_OleLinkTypes::Icon == type)
|
||||
{
|
||||
pOleItem->m_oIcon.Init();
|
||||
pOleItem->m_oIcon->FromBool(m_oBufferedStream.GetBool());
|
||||
}
|
||||
else if(c_oSer_OleLinkTypes::Advise == type)
|
||||
{
|
||||
pOleItem->m_oAdvise.Init();
|
||||
pOleItem->m_oAdvise->FromBool(m_oBufferedStream.GetBool());
|
||||
}
|
||||
else if(c_oSer_OleLinkTypes::PreferPic == type)
|
||||
{
|
||||
pOleItem->m_oPreferPic.Init();
|
||||
pOleItem->m_oPreferPic->FromBool(m_oBufferedStream.GetBool());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadDdeLink(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CDdeLink* ddeLink = static_cast<OOX::Spreadsheet::CDdeLink*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_DdeLinkTypes::DdeService == type)
|
||||
{
|
||||
ddeLink->m_oDdeService.Init();
|
||||
ddeLink->m_oDdeService->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::DdeTopic == type)
|
||||
{
|
||||
ddeLink->m_oDdeTopic.Init();
|
||||
ddeLink->m_oDdeTopic->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::DdeItem == type)
|
||||
{
|
||||
if (!ddeLink->m_oDdeItems.IsInit())
|
||||
{
|
||||
ddeLink->m_oDdeItems.Init();
|
||||
}
|
||||
OOX::Spreadsheet::CDdeItem* pDdeItem = new OOX::Spreadsheet::CDdeItem();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeItem, this, pDdeItem);
|
||||
ddeLink->m_oDdeItems->m_arrItems.push_back(pDdeItem);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadDdeItem(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CDdeItem* pDdeItem = static_cast<OOX::Spreadsheet::CDdeItem*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_DdeLinkTypes::Name == type)
|
||||
{
|
||||
pDdeItem->m_oName.Init();
|
||||
pDdeItem->m_oName->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::Ole == type)
|
||||
{
|
||||
pDdeItem->m_oOle.Init();
|
||||
pDdeItem->m_oOle->FromBool(m_oBufferedStream.GetBool());
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::Advise == type)
|
||||
{
|
||||
pDdeItem->m_oAdvise.Init();
|
||||
pDdeItem->m_oAdvise->FromBool(m_oBufferedStream.GetBool());
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::PreferPic == type)
|
||||
{
|
||||
pDdeItem->m_oPreferPic.Init();
|
||||
pDdeItem->m_oPreferPic->FromBool(m_oBufferedStream.GetBool());
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::DdeValues == type)
|
||||
{
|
||||
pDdeItem->m_oDdeValues.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeValues, this, pDdeItem->m_oDdeValues.GetPointer());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadDdeValues(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CDdeValues* pDdeValues = static_cast<OOX::Spreadsheet::CDdeValues*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_DdeLinkTypes::DdeValuesRows == type)
|
||||
{
|
||||
pDdeValues->m_oRows.Init();
|
||||
pDdeValues->m_oRows->SetValue(m_oBufferedStream.GetULong());
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::DdeValuesCols == type)
|
||||
{
|
||||
pDdeValues->m_oCols.Init();
|
||||
pDdeValues->m_oCols->SetValue(m_oBufferedStream.GetULong());
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::DdeValue == type)
|
||||
{
|
||||
OOX::Spreadsheet::CDdeValue* pDdeValue = new OOX::Spreadsheet::CDdeValue();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeValue, this, pDdeValue);
|
||||
pDdeValues->m_arrItems.push_back(pDdeValue);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadDdeValue(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CDdeValue* pDdeValue = static_cast<OOX::Spreadsheet::CDdeValue*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_DdeLinkTypes::DdeValueType == type)
|
||||
{
|
||||
pDdeValue->m_oType.Init();
|
||||
pDdeValue->m_oType->SetValue((SimpleTypes::Spreadsheet::EDdeValueType)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else if(c_oSer_DdeLinkTypes::DdeValueVal == type)
|
||||
{
|
||||
OOX::Spreadsheet::CText* pText = new OOX::Spreadsheet::CText();
|
||||
pText->m_sText.append(m_oBufferedStream.GetString3(length));
|
||||
pDdeValue->m_arrItems.push_back(pText);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadPivotCaches(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
|
||||
Reference in New Issue
Block a user