mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Compare commits
19 Commits
core/devel
...
core-win-6
| Author | SHA1 | Date | |
|---|---|---|---|
| 244dafb02b | |||
| 149a1bdbd5 | |||
| a79d9041bc | |||
| 3954c42602 | |||
| 29dc0aee32 | |||
| d805972d6d | |||
| 549d5a46a6 | |||
| 771bf2d55c | |||
| 3c58cd96fc | |||
| e50864fa98 | |||
| c8c0924c74 | |||
| af732e4e85 | |||
| 47ffdae8cc | |||
| fd5870083b | |||
| 5ba62cb25d | |||
| 79e0588544 | |||
| ec4f4fe476 | |||
| 634509ae28 | |||
| 8197fb8900 |
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
|
||||
@ -282,6 +282,12 @@ namespace NSBinPptxRW
|
||||
m_pContentTypes->AddDefault(strExts.substr(1));
|
||||
}
|
||||
|
||||
if (oleData.empty() == false)
|
||||
{
|
||||
//plugins data - generate ole
|
||||
typeAdditional = 1;
|
||||
}
|
||||
|
||||
_imageManager2Info oImageManagerInfo = GenerateImageExec(strImage, strExts, strAdditional, typeAdditional, oleData);
|
||||
|
||||
if (!oImageManagerInfo.sFilepathAdditional.empty())
|
||||
|
||||
@ -187,8 +187,25 @@ namespace PPTX
|
||||
break;
|
||||
}
|
||||
case BULLET_TYPE_BULLET_BLIP:
|
||||
// TODO:
|
||||
break;
|
||||
{
|
||||
pReader->Skip(5); // len + type + start attr
|
||||
|
||||
Logic::BuBlip *pBuBlip = new Logic::BuBlip();
|
||||
pBuBlip->blip.fromPPTY(pReader);
|
||||
|
||||
if (pBuBlip->blip.embed.IsInit())
|
||||
{
|
||||
m_Bullet.reset(pBuBlip);
|
||||
}
|
||||
else
|
||||
{//??? сбой ???
|
||||
delete pBuBlip;
|
||||
|
||||
Logic::BuChar *pBuChar = new Logic::BuChar();
|
||||
pBuChar->Char = wchar_t(L'\x2022');
|
||||
m_Bullet.reset(pBuChar);
|
||||
}
|
||||
}break;
|
||||
default:
|
||||
m_Bullet.reset(new Logic::BuNone());
|
||||
break;
|
||||
|
||||
@ -257,5 +257,129 @@ namespace PPTX
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
void Blip::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
LONG _s2 = pReader->GetPos();
|
||||
LONG _e2 = _s2 + pReader->GetLong() + 4;
|
||||
|
||||
pReader->Skip(1);
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (NSBinPptxRW::g_nodeAttributeEnd == _at)
|
||||
break;
|
||||
|
||||
if (_at == 0)
|
||||
pReader->Skip(1);
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _e2)
|
||||
{
|
||||
BYTE _t = pReader->GetUChar();
|
||||
|
||||
switch (_t)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
// id. embed / link
|
||||
pReader->Skip(4);
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
case 11:
|
||||
{
|
||||
// id. embed / link
|
||||
pReader->GetString2();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
pReader->Skip(4);
|
||||
ULONG count_effects = pReader->GetULong();
|
||||
for (ULONG _eff = 0; _eff < count_effects; ++_eff)
|
||||
{
|
||||
pReader->Skip(1); // type
|
||||
ULONG rec_len = pReader->GetULong();
|
||||
if (0 == rec_len)
|
||||
continue;
|
||||
|
||||
BYTE rec = pReader->GetUChar();
|
||||
|
||||
if (rec == EFFECT_TYPE_ALPHAMODFIX)
|
||||
{
|
||||
// alpha!!!
|
||||
LONG _e22 = pReader->GetPos() + pReader->GetLong() + 4;
|
||||
|
||||
pReader->Skip(1); // startattr
|
||||
|
||||
PPTX::Logic::AlphaModFix* pEffect = new PPTX::Logic::AlphaModFix();
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (NSBinPptxRW::g_nodeAttributeEnd == _at)
|
||||
break;
|
||||
|
||||
if (_at == 0)
|
||||
pEffect->amt = pReader->GetLong();
|
||||
}
|
||||
|
||||
Effects.push_back(UniEffect());
|
||||
Effects[0].InitPointer(pEffect);
|
||||
|
||||
pReader->Seek(_e22);
|
||||
}
|
||||
else
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
pReader->Skip(6); // len + start attributes + type
|
||||
|
||||
std::wstring strImagePath = pReader->GetString2();
|
||||
|
||||
if (0 != strImagePath.find(_T("http:")) &&
|
||||
0 != strImagePath.find(_T("https:")) &&
|
||||
0 != strImagePath.find(_T("ftp:")) &&
|
||||
0 != strImagePath.find(_T("file:")))
|
||||
{
|
||||
if (0 == strImagePath.find(_T("theme")))
|
||||
{
|
||||
strImagePath = pReader->m_strFolderExternalThemes + FILE_SEPARATOR_STR + strImagePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
strImagePath = pReader->m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + strImagePath;
|
||||
}
|
||||
|
||||
OOX::CPath pathUrl = strImagePath;
|
||||
strImagePath = pathUrl.GetPath();
|
||||
}
|
||||
|
||||
smart_ptr<OOX::File> additionalFile;
|
||||
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, additionalFile, L"", L"");
|
||||
|
||||
if (oRelsGeneratorInfo.nImageRId > 0)
|
||||
{
|
||||
embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
|
||||
}
|
||||
pReader->Skip(1); // end attribute
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pReader->Seek(_e2);
|
||||
}
|
||||
} // namespace Logic
|
||||
} // namespace PPTX
|
||||
@ -91,6 +91,7 @@ namespace PPTX
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
virtual std::wstring GetFullPicName(OOX::IFileContainer* pRels = NULL)const;
|
||||
virtual std::wstring GetFullOleName(const OOX::RId& pRId, OOX::IFileContainer* pRels = NULL)const;
|
||||
|
||||
@ -447,7 +447,7 @@ namespace PPTX
|
||||
if (!blip.is_init())
|
||||
blip = new PPTX::Logic::Blip();
|
||||
|
||||
if (oRelsGeneratorInfo.nImageRId >= 0)
|
||||
if (oRelsGeneratorInfo.nImageRId > 0)
|
||||
{
|
||||
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
|
||||
}
|
||||
|
||||
@ -1136,8 +1136,18 @@ namespace PPTX
|
||||
}
|
||||
}
|
||||
|
||||
if (spPr.Geometry.is_init())
|
||||
bool bRect = bOle; //ole ВСЕГДА rect
|
||||
|
||||
if (spPr.Geometry.is<PPTX::Logic::PrstGeom>())
|
||||
{
|
||||
const PPTX::Logic::PrstGeom & lpGeom = spPr.Geometry.as<PPTX::Logic::PrstGeom>();
|
||||
|
||||
if( lpGeom.prst.get() == L"rect" )
|
||||
bRect = true;
|
||||
}
|
||||
|
||||
if (bRect == false)
|
||||
{//custom vml shape
|
||||
std::wstring strPath;
|
||||
std::wstring strTextRect;
|
||||
|
||||
|
||||
@ -1,19 +1,21 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
SET PLATFORM=win
|
||||
SET ARCH=_32
|
||||
|
||||
SET PLATFORM=win_32
|
||||
if defined ProgramFiles(x86) (
|
||||
SET ARCH=_64
|
||||
SET PLATFORM=win_64
|
||||
)
|
||||
|
||||
mkdir "%SCRIPTPATH%%PLATFORM%%ARCH%"
|
||||
cd "%SCRIPTPATH%%PLATFORM%%ARCH%"
|
||||
if defined TARGET (
|
||||
SET PLATFORM=%TARGET%
|
||||
)
|
||||
|
||||
mkdir "%SCRIPTPATH%%PLATFORM%"
|
||||
cd "%SCRIPTPATH%%PLATFORM%"
|
||||
|
||||
if exist "cef_binary.7z" (
|
||||
echo "cef_binary.7z already downloaded"
|
||||
) else (
|
||||
Powershell.exe Invoke-WebRequest -OutFile cef_binary.7z http://d2ettrnqo7v976.cloudfront.net/cef/2454/%PLATFORM%%ARCH%/cef_binary.7z
|
||||
Powershell.exe Invoke-WebRequest -OutFile cef_binary.7z http://d2ettrnqo7v976.cloudfront.net/cef/2454/%PLATFORM%/cef_binary.7z
|
||||
)
|
||||
|
||||
SET UNSIP_PROGRAMM="%ProgramFiles%\7-Zip\7z.exe"
|
||||
|
||||
@ -6,6 +6,10 @@ if defined ProgramFiles(x86) (
|
||||
SET platform=win_64
|
||||
)
|
||||
|
||||
if defined TARGET (
|
||||
SET platform=%TARGET%
|
||||
)
|
||||
|
||||
if not exist "%platform%" (
|
||||
md "%platform%"
|
||||
)
|
||||
|
||||
@ -158,7 +158,16 @@ namespace OOX
|
||||
else if ( pRelation->Type() == FileTypes::Document)
|
||||
return smart_ptr<OOX::File>(new CDocument( oRootPath, oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::Theme)
|
||||
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
|
||||
{
|
||||
if(NSFile::CFileBinary::Exists(oFileName.GetPath()))
|
||||
{
|
||||
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
|
||||
}
|
||||
else
|
||||
{
|
||||
return smart_ptr<OOX::File>( new UnknowTypeFile() );
|
||||
}
|
||||
}
|
||||
else if ( pRelation->Type() == FileTypes::ThemeOverride)
|
||||
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::Setting)
|
||||
|
||||
@ -1092,6 +1092,13 @@ namespace OOX
|
||||
et_x_SheetPr,
|
||||
et_x_Pane,
|
||||
et_x_ExternalBook,
|
||||
et_x_ExternalSheetNames,
|
||||
et_x_ExternalDefinedNames,
|
||||
et_x_ExternalDefinedName,
|
||||
et_x_ExternalSheetDataSet,
|
||||
et_x_ExternalSheetData,
|
||||
et_x_ExternalRow,
|
||||
et_x_ExternalCell,
|
||||
et_x_Selection,
|
||||
et_x_LegacyDrawingWorksheet,
|
||||
et_x_LegacyDrawingHFWorksheet,
|
||||
|
||||
@ -39,6 +39,427 @@ namespace OOX
|
||||
{
|
||||
namespace Spreadsheet
|
||||
{
|
||||
class CExternalSheetNames : public WritingElementWithChilds<ComplexTypes::Spreadsheet::String>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CExternalSheetNames)
|
||||
CExternalSheetNames()
|
||||
{
|
||||
}
|
||||
virtual ~CExternalSheetNames()
|
||||
{
|
||||
}
|
||||
|
||||
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"sheetName" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new ComplexTypes::Spreadsheet::String(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
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"/>");
|
||||
}
|
||||
writer.WriteString(L"</sheetNames>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_ExternalSheetNames;
|
||||
}
|
||||
};
|
||||
|
||||
class CExternalDefinedName : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CExternalDefinedName)
|
||||
CExternalDefinedName()
|
||||
{
|
||||
}
|
||||
virtual ~CExternalDefinedName()
|
||||
{
|
||||
}
|
||||
|
||||
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"<definedName");
|
||||
WritingStringNullableAttrEncodeXmlString(L"name", m_oName, m_oName.get());
|
||||
WritingStringNullableAttrEncodeXmlString(L"refersTo", m_oRefersTo, m_oRefersTo.get());
|
||||
WritingStringNullableAttrInt(L"sheetId", m_oSheetId, m_oSheetId->GetValue());
|
||||
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_ExternalDefinedName;
|
||||
}
|
||||
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("refersTo"), m_oRefersTo )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("sheetId"), m_oSheetId )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<std::wstring> m_oName;
|
||||
nullable<std::wstring> m_oRefersTo;
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSheetId;
|
||||
};
|
||||
|
||||
class CExternalDefinedNames : public WritingElementWithChilds<CExternalDefinedName>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CExternalDefinedNames)
|
||||
CExternalDefinedNames()
|
||||
{
|
||||
}
|
||||
virtual ~CExternalDefinedNames()
|
||||
{
|
||||
}
|
||||
|
||||
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"definedName" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new CExternalDefinedName(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<definedNames>");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</definedNames>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_ExternalDefinedNames;
|
||||
}
|
||||
};
|
||||
|
||||
class CExternalCell : public WritingElement
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CExternalCell)
|
||||
CExternalCell()
|
||||
{
|
||||
}
|
||||
virtual ~CExternalCell()
|
||||
{
|
||||
}
|
||||
|
||||
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"v" == sName)
|
||||
{
|
||||
m_oValue = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<cell");
|
||||
WritingStringNullableAttrString(L"r", m_oRef, m_oRef.get());
|
||||
WritingStringNullableAttrString(L"t", m_oType, m_oType->ToString());
|
||||
WritingStringNullableAttrInt(L"vm", m_oValueMetadata, m_oValueMetadata->GetValue());
|
||||
writer.WriteString(L">");
|
||||
if(m_oValue.IsInit())
|
||||
m_oValue->toXML2(writer, _T("v"));
|
||||
writer.WriteString(L"</cell>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_ExternalCell;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if( oReader, _T("r"), m_oRef )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("t"), m_oType )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("vm"), m_oValueMetadata )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<std::wstring> m_oRef;
|
||||
nullable<SimpleTypes::Spreadsheet::CCellTypeType<>> m_oType;
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oValueMetadata;
|
||||
|
||||
nullable<CText> m_oValue;
|
||||
};
|
||||
|
||||
class CExternalRow : public WritingElementWithChilds<CExternalCell>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CExternalRow)
|
||||
CExternalRow()
|
||||
{
|
||||
}
|
||||
virtual ~CExternalRow()
|
||||
{
|
||||
}
|
||||
|
||||
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"cell" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new CExternalCell(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<row");
|
||||
WritingStringNullableAttrInt(L"r", m_oR, m_oR->GetValue());
|
||||
writer.WriteString(L">");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</row>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_ExternalRow;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_ReadSingle( oReader, _T("r"), m_oR )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oR;
|
||||
};
|
||||
|
||||
class CExternalSheetData : public WritingElementWithChilds<CExternalRow>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CExternalSheetData)
|
||||
CExternalSheetData()
|
||||
{
|
||||
}
|
||||
virtual ~CExternalSheetData()
|
||||
{
|
||||
}
|
||||
|
||||
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"row" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new CExternalRow(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<sheetData");
|
||||
WritingStringNullableAttrInt(L"sheetId", m_oSheetId, m_oSheetId->GetValue());
|
||||
WritingStringNullableAttrBool(L"refreshError", m_oRefreshError);
|
||||
writer.WriteString(L">");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</sheetData>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_ExternalSheetData;
|
||||
}
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if( oReader, _T("sheetId"), m_oSheetId )
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("refreshError"), m_oRefreshError )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
public:
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSheetId;
|
||||
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oRefreshError;
|
||||
};
|
||||
|
||||
class CExternalSheetDataSet : public WritingElementWithChilds<CExternalSheetData>
|
||||
{
|
||||
public:
|
||||
WritingElement_AdditionConstructors(CExternalSheetDataSet)
|
||||
CExternalSheetDataSet()
|
||||
{
|
||||
}
|
||||
virtual ~CExternalSheetDataSet()
|
||||
{
|
||||
}
|
||||
|
||||
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"sheetData" == sName)
|
||||
{
|
||||
m_arrItems.push_back(new CExternalSheetData(oReader));
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
writer.WriteString(L"<sheetDataSet>");
|
||||
for (size_t i = 0; i < m_arrItems.size(); ++i)
|
||||
{
|
||||
m_arrItems[i]->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</sheetDataSet>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
NSStringUtils::CStringBuilder writer;
|
||||
toXML(writer);
|
||||
return writer.GetData().c_str();
|
||||
}
|
||||
virtual EElementType getType() const
|
||||
{
|
||||
return et_x_ExternalSheetDataSet;
|
||||
}
|
||||
};
|
||||
|
||||
class CExternalBook : public WritingElement
|
||||
{
|
||||
public:
|
||||
@ -67,6 +488,19 @@ namespace OOX
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = oReader.GetName();
|
||||
|
||||
if (L"sheetNames" == sName)
|
||||
{
|
||||
m_oSheetNames = oReader;
|
||||
}
|
||||
else if (L"definedNames" == sName)
|
||||
{
|
||||
m_oDefinedNames = oReader;
|
||||
}
|
||||
else if (L"sheetDataSet" == sName)
|
||||
{
|
||||
m_oSheetDataSet = oReader;
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
@ -78,7 +512,20 @@ namespace OOX
|
||||
writer.WriteString(m_oRid->ToString());
|
||||
writer.WriteString(L"\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
|
||||
}
|
||||
writer.WriteString(L"/>");
|
||||
writer.WriteString(L">");
|
||||
if (m_oSheetNames.IsInit())
|
||||
{
|
||||
m_oSheetNames->toXML(writer);
|
||||
}
|
||||
if (m_oDefinedNames.IsInit())
|
||||
{
|
||||
m_oDefinedNames->toXML(writer);
|
||||
}
|
||||
if (m_oSheetDataSet.IsInit())
|
||||
{
|
||||
m_oSheetDataSet->toXML(writer);
|
||||
}
|
||||
writer.WriteString(L"</externalBook>");
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
@ -99,6 +546,10 @@ namespace OOX
|
||||
public:
|
||||
|
||||
nullable<SimpleTypes::CRelationshipId > m_oRid;
|
||||
|
||||
nullable<CExternalSheetNames > m_oSheetNames;
|
||||
nullable<CExternalDefinedNames > m_oDefinedNames;
|
||||
nullable<CExternalSheetDataSet > m_oSheetDataSet;
|
||||
};
|
||||
|
||||
class CExternalLink : public OOX::FileGlobalEnumerated, public OOX::IFileContainer
|
||||
@ -106,9 +557,11 @@ namespace OOX
|
||||
public:
|
||||
CExternalLink()
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
}
|
||||
CExternalLink(const CPath& oRootPath, const CPath& oPath)
|
||||
{
|
||||
m_bSpreadsheets = true;
|
||||
read( oRootPath, oPath );
|
||||
}
|
||||
virtual ~CExternalLink()
|
||||
|
||||
@ -128,7 +128,16 @@ namespace OOX
|
||||
else if ( pRelation->Type() == FileTypes::Worksheet )
|
||||
return smart_ptr<OOX::File>(new CWorksheet( oRootPath, oFileName ));
|
||||
else if ( pRelation->Type() == OOX::FileTypes::Theme )
|
||||
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
|
||||
{
|
||||
if(NSFile::CFileBinary::Exists(oFileName.GetPath()))
|
||||
{
|
||||
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
|
||||
}
|
||||
else
|
||||
{
|
||||
return smart_ptr<OOX::File>( new UnknowTypeFile() );
|
||||
}
|
||||
}
|
||||
else if ( pRelation->Type() == OOX::FileTypes::ThemeOverride )
|
||||
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
|
||||
else if ( pRelation->Type() == FileTypes::Drawings )
|
||||
|
||||
294
DesktopEditor/xmlsec/test/openssl_linux/main.cpp
Normal file
294
DesktopEditor/xmlsec/test/openssl_linux/main.cpp
Normal file
@ -0,0 +1,294 @@
|
||||
#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 "../../../common/File.h"
|
||||
|
||||
static time_t 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 mktime(&t);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int main()
|
||||
{
|
||||
std::wstring sFolderW = NSFile::GetProcessDirectory();
|
||||
std::string sFolder = U_TO_UTF8(sFolderW);
|
||||
std::string __file = sFolder + "/settings.xml";
|
||||
std::string __key = sFolder + "/rsakey.pem";
|
||||
std::string __cert = sFolder + "/rsacert.pem";
|
||||
|
||||
ASN1_INTEGER *asn1_serial = NULL;
|
||||
BIO *certbio = NULL;
|
||||
BIO *outbio = NULL;
|
||||
X509 *cert = NULL;
|
||||
const char *neg;
|
||||
int ret, i;
|
||||
long l;
|
||||
|
||||
/* ---------------------------------------------------------- *
|
||||
* These function calls initialize openssl for correct work. *
|
||||
* ---------------------------------------------------------- */
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_BIO_strings();
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
/* ---------------------------------------------------------- *
|
||||
* Create the Input/Output BIO's. *
|
||||
* ---------------------------------------------------------- */
|
||||
certbio = BIO_new(BIO_s_file());
|
||||
outbio = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
|
||||
/* ---------------------------------------------------------- *
|
||||
* Load the certificate from file (PEM). *
|
||||
* ---------------------------------------------------------- */
|
||||
ret = BIO_read_filename(certbio, __cert.c_str());
|
||||
if (! (cert = PEM_read_bio_X509(certbio, NULL, 0, NULL)))
|
||||
{
|
||||
BIO_printf(outbio, "Error loading cert into memory\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- *
|
||||
* Extract the certificate's serial number. *
|
||||
* ---------------------------------------------------------- */
|
||||
asn1_serial = X509_get_serialNumber(cert);
|
||||
if (asn1_serial == NULL)
|
||||
BIO_printf(outbio, "Error getting serial number from certificate");
|
||||
|
||||
ASN1_TIME* _time = X509_get_notBefore(cert);
|
||||
const char* s = (const char*)_time->data;
|
||||
time_t time1 = ASN1_GetTimeT(_time);
|
||||
|
||||
/* ---------------------------------------------------------- *
|
||||
* Print the serial number value, openssl x509 -serial style *
|
||||
* ---------------------------------------------------------- */
|
||||
BIO_puts(outbio,"serial (openssl x509 -serial style): ");
|
||||
i2a_ASN1_INTEGER(outbio, asn1_serial);
|
||||
BIO_puts(outbio,"\n");
|
||||
|
||||
/* ---------------------------------------------------------- *
|
||||
* Print the serial number value, openssl x509 -text style *
|
||||
* ---------------------------------------------------------- */
|
||||
if (asn1_serial->length <= (int)sizeof(long))
|
||||
{
|
||||
l=ASN1_INTEGER_get(asn1_serial);
|
||||
if (asn1_serial->type == V_ASN1_NEG_INTEGER)
|
||||
{
|
||||
l= -l;
|
||||
neg="-";
|
||||
}
|
||||
else neg="";
|
||||
|
||||
if (BIO_printf(outbio," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0)
|
||||
BIO_printf(outbio, "Error during printing the serial.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
neg=(asn1_serial->type == V_ASN1_NEG_INTEGER)?" (Negative)":"";
|
||||
//if (BIO_printf(outbio,"\n%12s%s","",neg) <= 0)
|
||||
if (BIO_printf(outbio,"serial (openssl x509 -text style): %s","",neg) <= 0)
|
||||
BIO_printf(outbio, "Error during printing the serial.\n");
|
||||
|
||||
for (i=0; i<asn1_serial->length; i++)
|
||||
{
|
||||
char c[2];
|
||||
c[0] = asn1_serial->data[i];
|
||||
c[1] = '0';
|
||||
BIO_printf(outbio, c);
|
||||
}
|
||||
}
|
||||
|
||||
X509_free(cert);
|
||||
BIO_free_all(certbio);
|
||||
BIO_free_all(outbio);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::wstring sFolderW = NSFile::GetProcessDirectory();
|
||||
std::string sFolder = U_TO_UTF8(sFolderW);
|
||||
std::string __file = sFolder + "/settings.xml";
|
||||
std::string __key = sFolder + "/rsakey.pem";
|
||||
std::string __cert = sFolder + "/www.pfx";
|
||||
|
||||
std::string __export = sFolder + "/www.pem";
|
||||
|
||||
FILE *fp;
|
||||
EVP_PKEY *pkey;
|
||||
X509 *cert;
|
||||
STACK_OF(X509) *ca = NULL;
|
||||
PKCS12 *p12;
|
||||
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
if (!(fp = fopen(__cert.c_str(), "rb")))
|
||||
{
|
||||
fprintf(stderr, "Error opening file %s\n", __cert.c_str());
|
||||
exit(1);
|
||||
}
|
||||
p12 = d2i_PKCS12_fp(fp, NULL);
|
||||
fclose (fp);
|
||||
|
||||
if (!p12)
|
||||
{
|
||||
fprintf(stderr, "Error reading PKCS#12 file\n");
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!PKCS12_parse(p12, "111", &pkey, &cert, &ca))
|
||||
{
|
||||
fprintf(stderr, "Error parsing PKCS#12 file\n");
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit (1);
|
||||
}
|
||||
PKCS12_free(p12);
|
||||
|
||||
if (!(fp = fopen(__export.c_str(), "w")))
|
||||
{
|
||||
fprintf(stderr, "Error opening file %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
if (pkey)
|
||||
{
|
||||
fprintf(fp, "***Private Key***\n");
|
||||
PEM_write_PrivateKey(fp, pkey, NULL, NULL, 0, NULL, NULL);
|
||||
}
|
||||
if (cert)
|
||||
{
|
||||
fprintf(fp, "***User Certificate***\n");
|
||||
PEM_write_X509_AUX(fp, cert);
|
||||
}
|
||||
if (ca && sk_X509_num(ca))
|
||||
{
|
||||
fprintf(fp, "***Other Certificates***\n");
|
||||
int count = sk_X509_num(ca);
|
||||
for (int i = 0; i < count; i++)
|
||||
PEM_write_X509_AUX(fp, sk_X509_value(ca, i));
|
||||
}
|
||||
|
||||
sk_X509_pop_free(ca, X509_free);
|
||||
X509_free(cert);
|
||||
EVP_PKEY_free(pkey);
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int main()
|
||||
{
|
||||
unsigned char ibuf[] = "compute sha1";
|
||||
unsigned char obuf[20];
|
||||
|
||||
SHA1(ibuf, strlen((char*)ibuf), obuf);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 20; i++) {
|
||||
printf("%02x ", obuf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int main()
|
||||
{
|
||||
std::wstring sFolderW = NSFile::GetProcessDirectory();
|
||||
std::string sFolder = U_TO_UTF8(sFolderW);
|
||||
std::string __file = sFolder + "/settings.xml";
|
||||
|
||||
#if 1
|
||||
std::string __key = sFolder + "/www.pem";
|
||||
std::string __cert = sFolder + "/www.pem";
|
||||
#else
|
||||
std::string __key = sFolder + "/rsakey.pem";
|
||||
std::string __cert = sFolder + "/rsacert.pem";
|
||||
#endif
|
||||
|
||||
OpenSSL_add_all_algorithms();
|
||||
ERR_load_BIO_strings();
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
FILE* file_key = NSFile::CFileBinary::OpenFileNative(UTF8_TO_U(__key), L"r+");
|
||||
FILE* file_cert = NSFile::CFileBinary::OpenFileNative(UTF8_TO_U(__key), L"r+");
|
||||
|
||||
EVP_PKEY* pKey = NULL;
|
||||
PEM_read_PrivateKey(file_key, &pKey, NULL, NULL);
|
||||
|
||||
X509* pCert = NULL;
|
||||
PEM_read_X509(file_cert, &pCert, NULL, NULL);
|
||||
|
||||
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
|
||||
const EVP_MD* pDigest = EVP_sha1();
|
||||
|
||||
int n1 = EVP_SignInit(pCtx, pDigest);
|
||||
|
||||
BYTE* pDataSrc = NULL;
|
||||
DWORD nDataSrcLen = 0;
|
||||
NSFile::CFileBinary::ReadAllBytes(UTF8_TO_U(__file), &pDataSrc, nDataSrcLen);
|
||||
|
||||
int n2 = EVP_SignUpdate(pCtx, pDataSrc, (size_t)nDataSrcLen);
|
||||
|
||||
BYTE pSignature[4096];
|
||||
unsigned int nSignatureLen = 0;
|
||||
|
||||
int n3 = EVP_SignFinal(pCtx, pSignature, &nSignatureLen, pKey);
|
||||
|
||||
RELEASEARRAYOBJECTS(pDataSrc);
|
||||
|
||||
EVP_PKEY_free(pKey);
|
||||
X509_free(pCert);
|
||||
|
||||
EVP_MD_CTX_destroy(pCtx);
|
||||
|
||||
fclose(file_key);
|
||||
fclose(file_cert);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
24
DesktopEditor/xmlsec/test/openssl_linux/test.pro
Normal file
24
DesktopEditor/xmlsec/test/openssl_linux/test.pro
Normal file
@ -0,0 +1,24 @@
|
||||
QT -= core gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEFINES -= \
|
||||
UNICODE \
|
||||
_UNICODE
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
DEFINES += XMLSEC_OPENSSL_110
|
||||
|
||||
INCLUDEPATH += $$PWD/../../openssl/include
|
||||
|
||||
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
|
||||
|
||||
@ -1935,7 +1935,19 @@ namespace NExtractTools
|
||||
{
|
||||
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo)
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
if(params.hasPassword())
|
||||
{
|
||||
std::wstring sToMscrypt = sTemp + FILE_SEPARATOR_STR + _T("tomscrypt.docx");
|
||||
nRes = dir2zip(sFrom, sToMscrypt);
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = oox2mscrypt(sToMscrypt, sTo, sTemp, params);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
}
|
||||
}
|
||||
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC == nFormatTo)
|
||||
{
|
||||
@ -2104,7 +2116,19 @@ namespace NExtractTools
|
||||
{
|
||||
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatTo)
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
if(params.hasPassword())
|
||||
{
|
||||
std::wstring sToMscrypt = sTemp + FILE_SEPARATOR_STR + _T("tomscrypt.xlsx");
|
||||
nRes = dir2zip(sFrom, sToMscrypt);
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = oox2mscrypt(sToMscrypt, sTo, sTemp, params);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
}
|
||||
}
|
||||
//else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS == nFormatTo)
|
||||
else if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS == nFormatTo)
|
||||
@ -2246,7 +2270,19 @@ namespace NExtractTools
|
||||
{
|
||||
if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX == nFormatTo)
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
if(params.hasPassword())
|
||||
{
|
||||
std::wstring sToMscrypt = sTemp + FILE_SEPARATOR_STR + _T("tomscrypt.pptx");
|
||||
nRes = dir2zip(sFrom, sToMscrypt);
|
||||
if(SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
nRes = oox2mscrypt(sToMscrypt, sTo, sTemp, params);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nRes = dir2zip(sFrom, sTo);
|
||||
}
|
||||
}
|
||||
//else if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT == nFormatTo)
|
||||
else if(AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP == nFormatTo)
|
||||
@ -2521,7 +2557,54 @@ namespace NExtractTools
|
||||
}
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
int html2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
{
|
||||
std::wstring sResultDoctDir = NSFile::GetDirectoryName(sTo);
|
||||
|
||||
int nRes = html2doct_dir(sFrom, sResultDoctDir, sTemp, params);
|
||||
|
||||
return nRes;
|
||||
}
|
||||
int html2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
{
|
||||
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
|
||||
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
|
||||
|
||||
NSDirectory::CreateDirectory(sResultDoctDir);
|
||||
|
||||
int nRes = html2doct_dir(sFrom, sResultDoctDir, sTemp, params);
|
||||
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
int html2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
{
|
||||
std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
|
||||
std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
|
||||
|
||||
NSDirectory::CreateDirectory(sResultDoctDir);
|
||||
|
||||
int nRes = html2doct_dir(sFrom, sResultDoctDir, sTemp, params);
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked");
|
||||
NSDirectory::CreateDirectory(sDocxDir);
|
||||
|
||||
nRes = doct_bin2docx_dir(sResultDoctFileEditor, L"", sDocxDir, false, L"", params);
|
||||
if (SUCCEEDED_X2T(nRes))
|
||||
{
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sDocxDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
int fromInputParams(InputParams& oInputParams)
|
||||
{
|
||||
TConversionDirection conversion = oInputParams.getConversionDirection();
|
||||
@ -2828,6 +2911,26 @@ namespace NExtractTools
|
||||
result = mscrypt2oot_bin (sFileFrom, sFileTo, sTempDir, oInputParams);
|
||||
{
|
||||
}break;
|
||||
case TCD_HTML2DOCX:
|
||||
{
|
||||
result = html2docx (sFileFrom, sFileTo, sTempDir, oInputParams);
|
||||
}break;
|
||||
case TCD_HTML2DOCT:
|
||||
{
|
||||
result = html2doct (sFileFrom, sFileTo, sTempDir, oInputParams);
|
||||
}break;
|
||||
case TCD_HTML2DOCT_BIN:
|
||||
{
|
||||
result = html2doct_bin (sFileFrom, sFileTo, sTempDir, oInputParams);
|
||||
}break;
|
||||
|
||||
//TCD_FB22DOCX,
|
||||
//TCD_FB22DOCT,
|
||||
//TCD_FB22DOCT_BIN,
|
||||
|
||||
//TCD_EPUB2DOCX,
|
||||
//TCD_EPUB2DOCT,
|
||||
//TCD_EPUB2DOCT_BIN,
|
||||
}
|
||||
|
||||
// delete temp dir
|
||||
|
||||
@ -131,6 +131,10 @@ namespace NExtractTools
|
||||
|
||||
int oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
|
||||
int html2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
int html2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
int html2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
int dir2zip (const std::wstring &sFrom, const std::wstring &sTo);
|
||||
int zip2dir (const std::wstring &sFrom, const std::wstring &sTo);
|
||||
|
||||
@ -223,6 +223,24 @@ namespace NExtractTools
|
||||
else if (0 == sExt2.compare(_T(".pptt"))) res = TCD_MSCRYPT2PPTT;
|
||||
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_MSCRYPT2BIN;
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".docx"))) res = TCD_HTML2DOCX;
|
||||
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_HTML2DOCT;
|
||||
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_HTML2DOCT_BIN;
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".docx"))) res = TCD_FB22DOCX;
|
||||
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_FB22DOCT;
|
||||
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_FB22DOCT_BIN;
|
||||
}break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB:
|
||||
{
|
||||
if (0 == sExt2.compare(_T(".docx"))) res = TCD_EPUB2DOCX;
|
||||
else if (0 == sExt2.compare(_T(".doct"))) res = TCD_EPUB2DOCT;
|
||||
else if (0 == sExt2.compare(_T(".bin"))) res = TCD_EPUB2DOCT_BIN;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ namespace NExtractTools
|
||||
TCD_PPTT2ODP,
|
||||
TCD_PPTX_BIN2ODP,
|
||||
|
||||
TCD_XML2DOCX,
|
||||
TCD_XML2DOCX,
|
||||
TCD_DOCX2XML,
|
||||
//
|
||||
TCD_MSCRYPT2,
|
||||
@ -145,6 +145,18 @@ namespace NExtractTools
|
||||
TCD_MSCRYPT2PPTT,
|
||||
TCD_MSCRYPT2BIN,
|
||||
//
|
||||
TCD_HTML2DOCX,
|
||||
TCD_HTML2DOCT,
|
||||
TCD_HTML2DOCT_BIN,
|
||||
|
||||
TCD_FB22DOCX,
|
||||
TCD_FB22DOCT,
|
||||
TCD_FB22DOCT_BIN,
|
||||
|
||||
TCD_EPUB2DOCX,
|
||||
TCD_EPUB2DOCT,
|
||||
TCD_EPUB2DOCT_BIN,
|
||||
|
||||
TCD_MAILMERGE,
|
||||
TCD_T2,
|
||||
TCD_DOCT_BIN2,
|
||||
@ -499,6 +511,10 @@ namespace NExtractTools
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool hasPassword() const
|
||||
{
|
||||
return NULL != m_sPassword;
|
||||
}
|
||||
std::wstring getPassword() const
|
||||
{
|
||||
return (NULL != m_sPassword) ? (*m_sPassword) : L"";
|
||||
|
||||
@ -187,7 +187,8 @@ namespace BinXlsxRW
|
||||
ExternalReferences = 5,
|
||||
ExternalReference = 6,
|
||||
PivotCaches = 7,
|
||||
PivotCache = 8
|
||||
PivotCache = 8,
|
||||
ExternalBook = 9
|
||||
};}
|
||||
namespace c_oSerWorkbookPrTypes{enum c_oSerWorkbookPrTypes
|
||||
{
|
||||
@ -819,6 +820,27 @@ namespace BinXlsxRW
|
||||
cacheId = 3,
|
||||
table = 4
|
||||
};}
|
||||
namespace c_oSer_ExternalLinkTypes{enum c_oSer_ExternalLinkTypes
|
||||
{
|
||||
Id = 0,
|
||||
SheetNames = 1,
|
||||
SheetName = 2,
|
||||
DefinedNames = 3,
|
||||
DefinedName = 4,
|
||||
DefinedNameName = 5,
|
||||
DefinedNameRefersTo = 6,
|
||||
DefinedNameSheetId = 7,
|
||||
SheetDataSet = 8,
|
||||
SheetData = 9,
|
||||
SheetDataSheetId = 10,
|
||||
SheetDataRefreshError = 11,
|
||||
SheetDataRow = 12,
|
||||
SheetDataRowR = 13,
|
||||
SheetDataRowCell = 14,
|
||||
SheetDataRowCellRef = 15,
|
||||
SheetDataRowCellType = 16,
|
||||
SheetDataRowCellValue = 17
|
||||
};}
|
||||
}
|
||||
|
||||
#endif //
|
||||
|
||||
@ -1583,13 +1583,13 @@ namespace BinXlsxRW
|
||||
if(pExternalReference->m_oRid.IsInit())
|
||||
{
|
||||
smart_ptr<OOX::File> pFile = workbook.Find( OOX::RId(pExternalReference->m_oRid->GetValue()));
|
||||
|
||||
|
||||
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()))
|
||||
{
|
||||
std::wstring sLink;
|
||||
std::wstring sLink;
|
||||
if (pExternalLink->m_oExternalBook->m_oRid.IsInit())
|
||||
{
|
||||
smart_ptr<OOX::File> pFile = pExternalLink->Find( OOX::RId(pExternalLink->m_oExternalBook->m_oRid.get().GetValue()));
|
||||
@ -1597,12 +1597,12 @@ namespace BinXlsxRW
|
||||
{
|
||||
OOX::Spreadsheet::ExternalLinkPath* pLinkFile = static_cast<OOX::Spreadsheet::ExternalLinkPath*>(pFile.operator ->());
|
||||
sLink = pLinkFile->Uri().GetPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!sLink.empty())
|
||||
if(!sLink.empty())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::ExternalReference);
|
||||
m_oBcw.m_oStream.WriteStringW3(sLink);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::ExternalBook);
|
||||
WriteExternalBook(pExternalLink->m_oExternalBook.get(), sLink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
@ -1610,7 +1610,144 @@ namespace BinXlsxRW
|
||||
}
|
||||
}
|
||||
};
|
||||
void WriteExternalBook(const OOX::Spreadsheet::CExternalBook& externalBook, const std::wstring& sLink)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::Id);
|
||||
m_oBcw.m_oStream.WriteStringW3(sLink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
|
||||
if (externalBook.m_oSheetNames.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetNames);
|
||||
WriteExternalSheetNames(externalBook.m_oSheetNames.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (externalBook.m_oDefinedNames.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::DefinedNames);
|
||||
WriteExternalDefinedNames(externalBook.m_oDefinedNames.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (externalBook.m_oSheetDataSet.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataSet);
|
||||
WriteExternalSheetDataSet(externalBook.m_oSheetDataSet.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteExternalSheetNames(const OOX::Spreadsheet::CExternalSheetNames& sheetNames)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
for (size_t i = 0, length = sheetNames.m_arrItems.size(); i < length; ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetName);
|
||||
m_oBcw.m_oStream.WriteStringW3(sheetNames.m_arrItems[i]->ToString2());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteExternalDefinedNames(const OOX::Spreadsheet::CExternalDefinedNames& definedNames)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
for (size_t i = 0, length = definedNames.m_arrItems.size(); i < length; ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::DefinedName);
|
||||
WriteExternalDefinedName(*definedNames.m_arrItems[i]);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteExternalDefinedName(const OOX::Spreadsheet::CExternalDefinedName& definedName)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (definedName.m_oName.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::DefinedNameName);
|
||||
m_oBcw.m_oStream.WriteStringW3(definedName.m_oName.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (definedName.m_oRefersTo.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::DefinedNameRefersTo);
|
||||
m_oBcw.m_oStream.WriteStringW3(definedName.m_oRefersTo.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (definedName.m_oSheetId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::DefinedNameSheetId);
|
||||
m_oBcw.m_oStream.WriteULONG(definedName.m_oSheetId->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteExternalSheetDataSet(const OOX::Spreadsheet::CExternalSheetDataSet& sheetDataSet)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
for (size_t i = 0, length = sheetDataSet.m_arrItems.size(); i < length; ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetData);
|
||||
WriteExternalSheetData(*sheetDataSet.m_arrItems[i]);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteExternalSheetData(const OOX::Spreadsheet::CExternalSheetData& sheetData)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(sheetData.m_oSheetId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataSheetId);
|
||||
m_oBcw.m_oStream.WriteULONG(sheetData.m_oSheetId->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(sheetData.m_oRefreshError.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataRefreshError);
|
||||
m_oBcw.m_oStream.WriteBOOL(sheetData.m_oRefreshError->ToBool());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
for (size_t i = 0, length = sheetData.m_arrItems.size(); i < length; ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataRow);
|
||||
WriteExternalRow(*sheetData.m_arrItems[i]);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteExternalRow(const OOX::Spreadsheet::CExternalRow& row)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(row.m_oR.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataRowR);
|
||||
m_oBcw.m_oStream.WriteULONG(row.m_oR->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
for (size_t i = 0, length = row.m_arrItems.size(); i < length; ++i)
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataRowCell);
|
||||
WriteExternalCell(*row.m_arrItems[i]);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteExternalCell(const OOX::Spreadsheet::CExternalCell& cell)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(cell.m_oRef.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataRowCellRef);
|
||||
m_oBcw.m_oStream.WriteStringW3(cell.m_oRef.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(cell.m_oType.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataRowCellType);
|
||||
m_oBcw.m_oStream.WriteBYTE(cell.m_oType->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(cell.m_oValue.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_ExternalLinkTypes::SheetDataRowCellValue);
|
||||
m_oBcw.m_oStream.WriteStringW3(cell.m_oValue->ToString());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteDefinedName(const OOX::Spreadsheet::CDefinedName& definedName)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
@ -2686,10 +2823,11 @@ namespace BinXlsxRW
|
||||
|
||||
if (olePic->oleObject->m_OleObjectFile.IsInit())
|
||||
{
|
||||
//if (olePic->oleObject->m_OleObjectFile->isMsPackage() == false)
|
||||
olePic->blipFill.blip->oleFilepathBin = olePic->oleObject->m_OleObjectFile->filename().GetPath();
|
||||
}
|
||||
}
|
||||
OOX::Image* pImageFileCache = NULL;
|
||||
std::wstring sIdImageFileCache;
|
||||
if ((NULL != pShapeElem) && (OOX::et_v_shapetype != pShapeElem->getType()))
|
||||
{
|
||||
OOX::Vml::CShape* pShape = static_cast<OOX::Vml::CShape*>(pShapeElem);
|
||||
@ -2704,26 +2842,43 @@ namespace BinXlsxRW
|
||||
if(OOX::et_v_imagedata == pChildElemShape->getType())
|
||||
{
|
||||
OOX::Vml::CImageData* pImageData = static_cast<OOX::Vml::CImageData*>(pChildElemShape);
|
||||
|
||||
if (pImageData->m_oRelId.IsInit())
|
||||
|
||||
if (pImageData->m_oRelId.IsInit()) sIdImageFileCache = pImageData->m_oRelId->GetValue();
|
||||
else if (pImageData->m_rId.IsInit()) sIdImageFileCache = pImageData->m_rId->GetValue();
|
||||
|
||||
if (!sIdImageFileCache.empty())
|
||||
{
|
||||
olePic->blipFill.blip->embed = new OOX::RId(pImageData->m_oRelId->GetValue());
|
||||
//ищем физический файл ( rId относительно vml_drawing)
|
||||
smart_ptr<OOX::File> pFile = pVmlDrawing->Find(olePic->blipFill.blip->embed.get());
|
||||
//ищем физический файл ( rId относительно vml_drawing)
|
||||
smart_ptr<OOX::File> pFile = pVmlDrawing->Find(sIdImageFileCache);
|
||||
|
||||
if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type()))
|
||||
{
|
||||
OOX::Image* pImageFile = static_cast<OOX::Image*>(pFile.operator->());
|
||||
|
||||
OOX::CPath pathImage = pImageFile->filename();
|
||||
olePic->oleObject->m_OleObjectFile->set_filename_cache(pathImage);
|
||||
olePic->blipFill.blip->oleFilepathImage = pImageFile->filename().GetPath();
|
||||
pImageFileCache = static_cast<OOX::Image*>(pFile.operator->());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pImageFileCache == NULL && pOleObject->m_oObjectPr.IsInit() && pOleObject->m_oObjectPr->m_oRid.IsInit())
|
||||
{
|
||||
sIdImageFileCache = pOleObject->m_oObjectPr->m_oRid->GetValue();
|
||||
|
||||
smart_ptr<OOX::File> pFile = oWorksheet.Find(sIdImageFileCache);
|
||||
if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type()))
|
||||
{
|
||||
pImageFileCache = static_cast<OOX::Image*>(pFile.operator->());
|
||||
}
|
||||
}
|
||||
if (pImageFileCache)
|
||||
{
|
||||
OOX::CPath pathImage = pImageFileCache->filename();
|
||||
|
||||
olePic->oleObject->m_OleObjectFile->set_filename_cache(pathImage);
|
||||
|
||||
olePic->blipFill.blip->embed = new OOX::RId(sIdImageFileCache); //ваще то тут не важно что - приоритет у того что ниже..
|
||||
olePic->blipFill.blip->oleFilepathImage = pathImage.GetPath();
|
||||
}
|
||||
|
||||
pCellAnchor->m_oElement = new PPTX::Logic::SpTreeElem();
|
||||
pCellAnchor->m_oElement->InitElem(olePic);
|
||||
|
||||
@ -1592,34 +1592,27 @@ namespace BinXlsxRW {
|
||||
int ReadExternalReferences(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSerWorkbookTypes::ExternalReference == type)
|
||||
if(c_oSerWorkbookTypes::ExternalBook == type)
|
||||
{
|
||||
std::wstring sName(m_oBufferedStream.GetString3(length));
|
||||
|
||||
if (sName.empty() == false)
|
||||
OOX::Spreadsheet::CExternalLink *extLink = new OOX::Spreadsheet::CExternalLink();
|
||||
extLink->m_oExternalBook.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalBook, this, extLink);
|
||||
if (extLink->m_oExternalBook->m_oRid.IsInit())
|
||||
{
|
||||
OOX::Spreadsheet::CExternalReference* pExternalReference = new OOX::Spreadsheet::CExternalReference();
|
||||
|
||||
OOX::Spreadsheet::CExternalLink *extLink= new OOX::Spreadsheet::CExternalLink();
|
||||
smart_ptr<OOX::File> oCurFile(extLink);
|
||||
|
||||
const OOX::RId oRId = m_oWorkbook.Add(oCurFile);
|
||||
|
||||
pExternalReference->m_oRid.Init();
|
||||
pExternalReference->m_oRid->SetValue(oRId.get());
|
||||
|
||||
extLink->m_oExternalBook.Init();
|
||||
smart_ptr<OOX::File> oCurFile(extLink);
|
||||
const OOX::RId oRId = m_oWorkbook.Add(oCurFile);
|
||||
|
||||
OOX::Spreadsheet::ExternalLinkPath *link = new OOX::Spreadsheet::ExternalLinkPath(sName);
|
||||
smart_ptr<OOX::File> oLinkFile(link);
|
||||
const OOX::RId oRIdLink = extLink->Add(oLinkFile);
|
||||
|
||||
extLink->m_oExternalBook->m_oRid.Init();
|
||||
extLink->m_oExternalBook->m_oRid->SetValue(oRIdLink.get());
|
||||
pExternalReference->m_oRid.Init();
|
||||
pExternalReference->m_oRid->SetValue(oRId.get());
|
||||
|
||||
|
||||
m_oWorkbook.m_oExternalReferences->m_arrItems.push_back(pExternalReference);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASEOBJECT(extLink)
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1672,6 +1665,174 @@ namespace BinXlsxRW {
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalBook(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalLink* extLink = static_cast<OOX::Spreadsheet::CExternalLink*>(poResult);
|
||||
OOX::Spreadsheet::CExternalBook* pExternalBook = extLink->m_oExternalBook.GetPointer();
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::Id == type)
|
||||
{
|
||||
std::wstring sName(m_oBufferedStream.GetString3(length));
|
||||
|
||||
OOX::Spreadsheet::ExternalLinkPath *link = new OOX::Spreadsheet::ExternalLinkPath(sName);
|
||||
smart_ptr<OOX::File> oLinkFile(link);
|
||||
const OOX::RId oRIdLink = extLink->Add(oLinkFile);
|
||||
|
||||
pExternalBook->m_oRid.Init();
|
||||
pExternalBook->m_oRid->SetValue(oRIdLink.get());
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::SheetNames == type)
|
||||
{
|
||||
pExternalBook->m_oSheetNames.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalSheetNames, this, pExternalBook->m_oSheetNames.GetPointer());
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::DefinedNames == type)
|
||||
{
|
||||
pExternalBook->m_oDefinedNames.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalDefinedNames, this, pExternalBook->m_oDefinedNames.GetPointer());
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::SheetDataSet == type)
|
||||
{
|
||||
pExternalBook->m_oSheetDataSet.Init();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalSheetDataSet, this, pExternalBook->m_oSheetDataSet.GetPointer());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalSheetNames(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalSheetNames* pSheetNames = static_cast<OOX::Spreadsheet::CExternalSheetNames*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::SheetName == type)
|
||||
{
|
||||
ComplexTypes::Spreadsheet::String* pSheetName = new ComplexTypes::Spreadsheet::String();
|
||||
pSheetName->m_sVal.Init();
|
||||
pSheetName->m_sVal->append(m_oBufferedStream.GetString4(length));
|
||||
pSheetNames->m_arrItems.push_back(pSheetName);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalDefinedNames(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalDefinedNames* pDefinedNames = static_cast<OOX::Spreadsheet::CExternalDefinedNames*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::DefinedName == type)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalDefinedName* pDefinedName = new OOX::Spreadsheet::CExternalDefinedName();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalDefinedName, this, pDefinedName);
|
||||
pDefinedNames->m_arrItems.push_back(pDefinedName);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalDefinedName(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalDefinedName* pDefinedName = static_cast<OOX::Spreadsheet::CExternalDefinedName*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::DefinedNameName == type)
|
||||
{
|
||||
pDefinedName->m_oName.Init();
|
||||
pDefinedName->m_oName->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::DefinedNameRefersTo == type)
|
||||
{
|
||||
pDefinedName->m_oRefersTo.Init();
|
||||
pDefinedName->m_oRefersTo->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::DefinedNameSheetId == type)
|
||||
{
|
||||
pDefinedName->m_oSheetId.Init();
|
||||
pDefinedName->m_oSheetId->SetValue(m_oBufferedStream.GetULong());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalSheetDataSet(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalSheetDataSet* pSheetDataSet = static_cast<OOX::Spreadsheet::CExternalSheetDataSet*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::SheetData == type)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalSheetData* pSheetData = new OOX::Spreadsheet::CExternalSheetData();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalSheetData, this, pSheetData);
|
||||
pSheetDataSet->m_arrItems.push_back(pSheetData);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalSheetData(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalSheetData* pSheetData = static_cast<OOX::Spreadsheet::CExternalSheetData*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::SheetDataSheetId == type)
|
||||
{
|
||||
pSheetData->m_oSheetId.Init();
|
||||
pSheetData->m_oSheetId->SetValue(m_oBufferedStream.GetULong());
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::SheetDataRefreshError == type)
|
||||
{
|
||||
pSheetData->m_oRefreshError.Init();
|
||||
pSheetData->m_oRefreshError->FromBool(m_oBufferedStream.GetBool());
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::SheetDataRow == type)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalRow* pRow = new OOX::Spreadsheet::CExternalRow();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalRow, this, pRow);
|
||||
pSheetData->m_arrItems.push_back(pRow);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalRow(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalRow* pRow = static_cast<OOX::Spreadsheet::CExternalRow*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::SheetDataRowR == type)
|
||||
{
|
||||
pRow->m_oR.Init();
|
||||
pRow->m_oR->SetValue(m_oBufferedStream.GetULong());
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::SheetDataRowCell == type)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalCell* pCell = new OOX::Spreadsheet::CExternalCell();
|
||||
res = Read1(length, &BinaryWorkbookTableReader::ReadExternalCell, this, pCell);
|
||||
pRow->m_arrItems.push_back(pCell);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadExternalCell(BYTE type, long length, void* poResult)
|
||||
{
|
||||
OOX::Spreadsheet::CExternalCell* pCell = static_cast<OOX::Spreadsheet::CExternalCell*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if(c_oSer_ExternalLinkTypes::SheetDataRowCellRef == type)
|
||||
{
|
||||
pCell->m_oRef.Init();
|
||||
pCell->m_oRef->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::SheetDataRowCellType == type)
|
||||
{
|
||||
pCell->m_oType.Init();
|
||||
pCell->m_oType->SetValue((SimpleTypes::Spreadsheet::ECellTypeType)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else if(c_oSer_ExternalLinkTypes::SheetDataRowCellValue == type)
|
||||
{
|
||||
pCell->m_oValue.Init();
|
||||
pCell->m_oValue->m_sText.append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
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