Commit 36bdbad6 authored by Sergey Konovalov's avatar Sergey Konovalov

for bug 27765

external OleLink/DdeLink
parent 525b8285
......@@ -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())
......
......@@ -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_
\ No newline at end of file
#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
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment