mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Merge branch 'develop' into feature/add-xls-writing
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -197,48 +197,26 @@ namespace NSBinPptxRW
|
||||
CElement(const CElement& oSrc);
|
||||
};
|
||||
|
||||
|
||||
std::map<std::wstring, CShapePtr> m_mapShapeTypes;
|
||||
std::map<std::wstring, nullable<OOX::Logic::CBinData>> m_mapBinDatas;
|
||||
|
||||
NSBinPptxRW::CBinaryFileWriter* m_pBinaryWriter;
|
||||
int m_lNextId;
|
||||
unsigned int m_nDrawingMaxZIndex = 0; // для смешанных записей pict & Drawing
|
||||
|
||||
int m_lCurrentObjectTop;
|
||||
|
||||
NSBinPptxRW::CBinaryFileReader* m_pReader;
|
||||
NSBinPptxRW::CImageManager2* m_pImageManager;
|
||||
NSBinPptxRW::CXmlWriter* m_pXmlWriter;
|
||||
int m_nCurrentIndexObject;
|
||||
IRenderer* m_pOOXToVMLRenderer;
|
||||
bool m_bIsUseConvertion2007;
|
||||
bool m_bNeedMainProps;
|
||||
|
||||
NSCommon::smart_ptr<PPTX::Theme>* m_pTheme;
|
||||
NSCommon::smart_ptr<PPTX::Logic::ClrMap>* m_pClrMap;
|
||||
|
||||
std::wstring m_strFontDirectory;
|
||||
|
||||
CDrawingConverter();
|
||||
~CDrawingConverter();
|
||||
|
||||
void SetRelsPtr(OOX::IFileContainer *container);
|
||||
OOX::IFileContainer* GetRelsPtr();
|
||||
|
||||
void SetMainDocument (BinDocxRW::CDocxSerializer* pDocument);
|
||||
void SetDocxSerializer(BinDocxRW::CDocxSerializer* pDocument);
|
||||
|
||||
void SetSrcPath (const std::wstring& sPath, int nDocType = 1/*XMLWRITER_DOC_TYPE_DOCX*/);
|
||||
void SetDstPath (const std::wstring& sPath);
|
||||
|
||||
void SetTempPath (const std::wstring& sPath);
|
||||
void SetSrcPath(const std::wstring& sPath, int nDocType = 1/*XMLWRITER_DOC_TYPE_DOCX*/);
|
||||
void SetDstPath(const std::wstring& sPath);
|
||||
|
||||
void SetTempPath (const std::wstring& sPath);
|
||||
std::wstring GetTempPath();
|
||||
|
||||
void SetMediaDstPath (const std::wstring& sMediaPath);
|
||||
void SetEmbedDstPath (const std::wstring& sEmbedPath);
|
||||
void SetMediaDstPath(const std::wstring& sMediaPath);
|
||||
void SetEmbedDstPath(const std::wstring& sEmbedPath);
|
||||
|
||||
void Clear();
|
||||
HRESULT AddShapeType(const std::wstring& sXml);
|
||||
|
||||
void AddShapeType(const std::wstring& sXml);
|
||||
void AddShapeType(XmlUtils::CXmlNode& oNode);
|
||||
void AddBinData(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
@ -246,74 +224,84 @@ namespace NSBinPptxRW
|
||||
|
||||
void ConvertVml(const std::wstring& sXml, std::vector<nullable<PPTX::Logic::SpTreeElem>> &elements, NSCommon::nullable<OOX::WritingElement> &anchor);
|
||||
|
||||
HRESULT SaveObject(long lStart, long lLength, const std::wstring& sMainProps, std::wstring & sXml);
|
||||
HRESULT SaveObjectEx(long lStart, long lLength, const std::wstring& sMainProps, int nDocType, std::wstring & sXml);
|
||||
void SaveObjectEx(long lStart, long lLength, const std::wstring& sMainProps, int nDocType, std::wstring & sXml);
|
||||
|
||||
void SaveObjectExWriterInit (NSBinPptxRW::CXmlWriter& oXmlWriter, int lDocType);
|
||||
void SaveObjectExWriterRelease (NSBinPptxRW::CXmlWriter& oXmlWriter);
|
||||
|
||||
PPTX::Logic::SpTreeElem ObjectFromXml(const std::wstring& sXml, std::wstring** pMainProps);
|
||||
std::wstring ObjectToVML (const std::wstring& sXml);
|
||||
std::wstring ObjectToDrawingML (const std::wstring& sXml, int nDocType);
|
||||
|
||||
std::wstring SaveObjectBackground(LONG lStart, LONG lLength);
|
||||
|
||||
HRESULT GetRecordBinary (long lRecordType, const std::wstring& sXml);
|
||||
HRESULT GetRecordXml (long lStart, long lLength, long lRecType, int lDocType, std::wstring & sXml);
|
||||
|
||||
void SetDstContentRels ();
|
||||
void SaveDstContentRels (const std::wstring& sRelsPath);
|
||||
|
||||
HRESULT LoadClrMap (const std::wstring& sXml);
|
||||
HRESULT LoadClrMap(const std::wstring& sXml);
|
||||
|
||||
HRESULT(SetFontDir) (const std::wstring& sFontDir);
|
||||
void SetFontDir (const std::wstring& sFontDir);
|
||||
void SetFontPicker (COfficeFontPicker* pFontPicker);
|
||||
void SetFontManager(NSFonts::IFontManager* pFontManager);
|
||||
|
||||
HRESULT SetFontPicker (COfficeFontPicker* pFontPicker);
|
||||
void SetAdditionalParam(const std::wstring& ParamName, BYTE *pArray, size_t szCount);
|
||||
void GetAdditionalParam(const std::wstring& ParamName, BYTE** pArray, size_t& szCount) {}
|
||||
|
||||
HRESULT SetAdditionalParam(const std::wstring& ParamName, BYTE *pArray, size_t szCount);
|
||||
HRESULT GetAdditionalParam(const std::wstring& ParamName, BYTE **pArray, size_t& szCount);
|
||||
|
||||
void WriteRels (const std::wstring& sType, const std::wstring& sTarget, const std::wstring& sTargetMode, unsigned int* lId);
|
||||
void Registration (const std::wstring& sType, const std::wstring& oDirectory, const std::wstring& oFilename);
|
||||
|
||||
void SetFontManager (NSFonts::IFontManager* pFontManager);
|
||||
void SetDstContentRels();
|
||||
void SaveDstContentRels(const std::wstring& sRelsPath);
|
||||
void WriteRels(const std::wstring& sType, const std::wstring& sTarget, const std::wstring& sTargetMode, unsigned int* lId);
|
||||
void Registration(const std::wstring& sType, const std::wstring& oDirectory, const std::wstring& oFilename);
|
||||
|
||||
OOX::CContentTypes* GetContentTypes();
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
std::map<std::wstring, CShapePtr> m_mapShapeTypes;
|
||||
std::map<std::wstring, nullable<OOX::Logic::CBinData>> m_mapBinDatas;
|
||||
|
||||
NSBinPptxRW::CBinaryFileWriter* m_pBinaryWriter;
|
||||
NSBinPptxRW::CBinaryFileReader* m_pBinaryReader;
|
||||
|
||||
int m_lNextId;
|
||||
unsigned int m_nDrawingMaxZIndex = 0; // для смешанных записей pict & Drawing
|
||||
|
||||
int m_lCurrentObjectTop;
|
||||
|
||||
NSBinPptxRW::CImageManager2* m_pImageManager;
|
||||
NSBinPptxRW::CXmlWriter* m_pXmlWriter;
|
||||
|
||||
int m_nCurrentIndexObject;
|
||||
IRenderer* m_pOOXToVMLRenderer;
|
||||
bool m_bIsUseConvertion2007;
|
||||
bool m_bNeedMainProps;
|
||||
|
||||
NSCommon::smart_ptr<PPTX::Theme>* m_pTheme;
|
||||
NSCommon::smart_ptr<PPTX::Logic::ClrMap>* m_pClrMap;
|
||||
|
||||
std::wstring m_strFontDirectory;
|
||||
|
||||
protected:
|
||||
nullable<PPTX::Logic::Xfrm> m_oxfrm_override;
|
||||
|
||||
bool ParceObject (const std::wstring& strXml, std::wstring** pMainProps);
|
||||
void SendMainProps (const std::wstring& strMainProps, std::wstring**& pMainProps);
|
||||
bool ParceObject(const std::wstring& strXml, std::wstring** pMainProps);
|
||||
void SendMainProps(const std::wstring& strMainProps, std::wstring**& pMainProps);
|
||||
|
||||
void ConvertDiagram (PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
|
||||
void ConvertShape (PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
|
||||
void ConvertGroup (PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
|
||||
void ConvertDrawing (PPTX::Logic::SpTreeElem *result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
|
||||
void ConvertShape(PPTX::Logic::SpTreeElem* result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
|
||||
void ConvertGroup(PPTX::Logic::SpTreeElem* result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
|
||||
void ConvertDrawing(PPTX::Logic::SpTreeElem* result, XmlUtils::CXmlNode& oNode, std::wstring**& pMainProps, bool bIsTop = true);
|
||||
void ConvertWordArtShape(PPTX::Logic::SpTreeElem* result, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
|
||||
std::wstring GetVMLShapeXml (CPPTShape* pPPTShape);
|
||||
std::wstring GetVMLShapeXml (PPTX::Logic::SpTreeElem& oElem);
|
||||
void CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
void CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
void CheckBorderShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
void CheckEffectShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
|
||||
void CheckBrushShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
void CheckPenShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
void CheckBorderShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
void CheckEffectShape (PPTX::Logic::SpTreeElem* oElem, XmlUtils::CXmlNode& oNode, CPPTShape* pPPTShape);
|
||||
void ConvertColor(PPTX::Logic::UniColor& uniColor, nullable_string& sColor, nullable_string& sOpacity);
|
||||
|
||||
void ConvertColor (PPTX::Logic::UniColor& uniColor, nullable_string& sColor, nullable_string& sOpacity);
|
||||
void LoadCoordSize (XmlUtils::CXmlNode& oNode, ::CShapePtr pShape);
|
||||
void LoadCoordPos (XmlUtils::CXmlNode& oNode, ::CShapePtr pShape);
|
||||
|
||||
std::wstring GetDrawingMainProps (XmlUtils::CXmlNode& oNode, PPTX::CCSS& oCssStyles, CSpTreeElemProps& oProps);
|
||||
void LoadCoordSize(XmlUtils::CXmlNode& oNode, ::CShapePtr pShape);
|
||||
void LoadCoordPos(XmlUtils::CXmlNode& oNode, ::CShapePtr pShape);
|
||||
|
||||
void ConvertMainPropsToVML (const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem);
|
||||
void ConvertPicVML (PPTX::Logic::SpTreeElem& oElem, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter);
|
||||
void ConvertShapeVML (PPTX::Logic::SpTreeElem& oShape, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter, bool bSignature = false);
|
||||
void ConvertGroupVML (PPTX::Logic::SpTreeElem& oGroup, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter);
|
||||
std::wstring GetDrawingMainProps(XmlUtils::CXmlNode& oNode, PPTX::CCSS& oCssStyles, CSpTreeElemProps& oProps);
|
||||
|
||||
void ConvertTextVML (XmlUtils::CXmlNode &node, PPTX::Logic::Shape* pShape);
|
||||
void ConvertParaVML (XmlUtils::CXmlNode& node, PPTX::Logic::Paragraph* p);
|
||||
void ConvertMainPropsToVML(const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem);
|
||||
void ConvertPicVML(PPTX::Logic::SpTreeElem& oElem, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter);
|
||||
void ConvertShapeVML(PPTX::Logic::SpTreeElem& oShape, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter, bool bSignature = false);
|
||||
void ConvertGroupVML(PPTX::Logic::SpTreeElem& oGroup, const std::wstring& sMainProps, NSBinPptxRW::CXmlWriter& oWriter);
|
||||
|
||||
HRESULT SetCurrentRelsPath();
|
||||
void ConvertTextVML(XmlUtils::CXmlNode& node, PPTX::Logic::Shape* pShape);
|
||||
void ConvertParaVML(XmlUtils::CXmlNode& node, PPTX::Logic::Paragraph* p);
|
||||
|
||||
void SaveObject(long lStart, long lLength, const std::wstring& sMainProps, std::wstring& sXml);
|
||||
};
|
||||
}
|
||||
|
||||
@ -111,6 +111,7 @@ namespace PPTX
|
||||
pWriter->WriteString2(0, attrName);
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
pWriter->ClearCurShapeSize();
|
||||
pWriter->WriteRecord2(0, bg);
|
||||
|
||||
pWriter->StartRecord(1);
|
||||
@ -122,7 +123,7 @@ namespace PPTX
|
||||
pWriter->WriteULONG((_UINT32)spTree.SpTreeElems.size());
|
||||
for (size_t i = 0; i < spTree.SpTreeElems.size(); i++)
|
||||
{
|
||||
pWriter->m_bInGroup = false;
|
||||
pWriter->ClearCurShapeSize();
|
||||
pWriter->WriteRecord1(0, spTree.SpTreeElems[i]);
|
||||
}
|
||||
pWriter->EndRecord();
|
||||
|
||||
@ -302,11 +302,8 @@ namespace PPTX
|
||||
|
||||
pWriter->EndRecord();
|
||||
|
||||
double dX = pWriter->GetShapeX(); //mm
|
||||
double dY = pWriter->GetShapeY();
|
||||
|
||||
double dW = pWriter->GetShapeWidth(); //mm
|
||||
double dH = pWriter->GetShapeHeight();
|
||||
double dW = pWriter->GetShapeWidth() / 12700. ; //emu to pt
|
||||
double dH = pWriter->GetShapeHeight() / 12700.;
|
||||
|
||||
OOX::IFileContainer* pRels = pWriter->GetRelsPtr();
|
||||
|
||||
@ -335,21 +332,21 @@ namespace PPTX
|
||||
NSShapeImageGen::CMediaInfo oId;
|
||||
if (!dataFilepathImageA.empty())
|
||||
{
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(dataFilepathImageA, dX, dY, dW, dH, additionalPath, additionalType);
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(dataFilepathImageA, dW, dH, additionalPath, additionalType);
|
||||
}
|
||||
else if (!dataFilepathImage.empty())
|
||||
{
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(dataFilepathImage, dX, dY, dW, dH, additionalPath, additionalType);
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(dataFilepathImage, dW, dH, additionalPath, additionalType);
|
||||
}
|
||||
else if (!oleFilepathImage.empty())
|
||||
{
|
||||
std::wstring imagePath = oleFilepathImage;
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(imagePath, dX, dY, dW, dH, additionalPath, additionalType);
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(imagePath, dW, dH, additionalPath, additionalType);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring imagePath = this->GetFullPicName(pRels);
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(imagePath, dX, dY, dW, dH, additionalPath, additionalType);
|
||||
oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(imagePath, dW, dH, additionalPath, additionalType);
|
||||
}
|
||||
|
||||
std::wstring s = oId.GetPath2();
|
||||
|
||||
@ -216,6 +216,92 @@ namespace PPTX
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
void GradFill::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
pReader->Skip(4); // len
|
||||
BYTE _type = pReader->GetUChar(); // FILL_TYPE_GRAD
|
||||
LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4;
|
||||
|
||||
pReader->Skip(1);
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0:
|
||||
flip = pReader->GetUChar();
|
||||
break;
|
||||
case 1:
|
||||
rotWithShape = pReader->GetBool();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _e)
|
||||
{
|
||||
BYTE rec = pReader->GetUChar();
|
||||
|
||||
switch (rec)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
LONG _s1 = pReader->GetPos();
|
||||
LONG _e1 = _s1 + pReader->GetLong() + 4;
|
||||
|
||||
ULONG _count = pReader->GetULong();
|
||||
for (ULONG i = 0; i < _count; ++i)
|
||||
{
|
||||
if (pReader->GetPos() >= _e1)
|
||||
break;
|
||||
|
||||
pReader->Skip(1); // type
|
||||
pReader->Skip(4); // len
|
||||
|
||||
size_t _countGs = GsLst.size();
|
||||
GsLst.push_back(Gs());
|
||||
|
||||
pReader->Skip(1); // start attr
|
||||
pReader->Skip(1); // pos type
|
||||
GsLst[_countGs].pos = pReader->GetLong();
|
||||
pReader->Skip(1); // end attr
|
||||
|
||||
pReader->Skip(1);
|
||||
GsLst[_countGs].color.fromPPTY(pReader);
|
||||
}
|
||||
|
||||
pReader->Seek(_e1);
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
lin = new PPTX::Logic::Lin();
|
||||
lin->fromPPTY(pReader);
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
path = new PPTX::Logic::Path();
|
||||
path->fromPPTY(pReader);
|
||||
}break;
|
||||
case 3:
|
||||
{
|
||||
tileRect = new PPTX::Logic::Rect();
|
||||
tileRect->m_name = L"a:tileRect";
|
||||
tileRect->fromPPTY(pReader);
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
pReader->Seek(_e);
|
||||
}
|
||||
void GradFill::Merge(GradFill& fill)const
|
||||
{
|
||||
if(flip.IsInit())
|
||||
|
||||
@ -62,6 +62,7 @@ namespace PPTX
|
||||
virtual std::wstring toXML() const;
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
void Merge(GradFill& fill) const;
|
||||
UniColor GetFrontColor() const;
|
||||
|
||||
@ -159,6 +159,52 @@ namespace PPTX
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
void PattFill::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
pReader->Skip(4); // len
|
||||
BYTE _type = pReader->GetUChar(); // FILL_TYPE_PATT
|
||||
LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4;
|
||||
|
||||
pReader->Skip(1);
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0:
|
||||
prst = pReader->GetUChar();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _e)
|
||||
{
|
||||
BYTE rec = pReader->GetUChar();
|
||||
|
||||
switch (rec)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
fgClr.fromPPTY(pReader);
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
bgClr.fromPPTY(pReader);
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
pReader->Seek(_e);
|
||||
}
|
||||
void PattFill::FillParentPointersForChilds()
|
||||
{
|
||||
fgClr.SetParentPointer(this);
|
||||
|
||||
@ -56,11 +56,11 @@ namespace PPTX
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual std::wstring toXML() const;
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
public:
|
||||
nullable_limit<Limit::PattFillVal> prst;
|
||||
|
||||
UniColor fgClr;
|
||||
|
||||
@ -109,6 +109,17 @@ namespace PPTX
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
void SolidFill::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
pReader->Skip(4); // len
|
||||
BYTE _type = pReader->GetUChar(); // FILL_TYPE_SOLID
|
||||
LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4;
|
||||
|
||||
pReader->Skip(1);
|
||||
|
||||
Color.fromPPTY(pReader);
|
||||
pReader->Seek(_e);
|
||||
}
|
||||
void SolidFill::Merge(SolidFill& fill)const
|
||||
{
|
||||
if(Color.is_init())
|
||||
|
||||
@ -53,9 +53,10 @@ namespace PPTX
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual std::wstring toXML() const;
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
void Merge(SolidFill& fill) const;
|
||||
|
||||
|
||||
@ -195,9 +195,6 @@ namespace PPTX
|
||||
pWriter->WriteLimit2(0, bwMode);
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
pWriter->m_dCxCurShape = pWriter->m_dCyCurShape = 1;
|
||||
pWriter->m_bInGroup = true;
|
||||
|
||||
pWriter->WriteRecord2(0, xfrm);
|
||||
pWriter->WriteRecord1(1, Fill);
|
||||
pWriter->WriteRecord1(2, EffectList);
|
||||
|
||||
@ -411,16 +411,16 @@ namespace PPTX
|
||||
office_checker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM)
|
||||
{
|
||||
embedded_type = 1;
|
||||
BinDocxRW::CDocxSerializer* old_serializer = pWriter->m_pMainDocument;
|
||||
BinDocxRW::CDocxSerializer* old_serializer = pWriter->m_pDocxSerializer;
|
||||
|
||||
BinDocxRW::CDocxSerializer oDocxSerializer;
|
||||
oDrawingConverter.m_pBinaryWriter->m_pMainDocument = &oDocxSerializer;
|
||||
oDrawingConverter.m_pBinaryWriter->m_pDocxSerializer = &oDocxSerializer;
|
||||
oDocxSerializer.m_pParamsWriter = new BinDocxRW::ParamsWriter(oDrawingConverter.m_pBinaryWriter, &oFontProcessor, &oDrawingConverter, NULL);
|
||||
|
||||
BinDocxRW::BinaryFileWriter oBinaryFileWriter(*oDocxSerializer.m_pParamsWriter);
|
||||
oBinaryFileWriter.intoBindoc(oox_unpacked.GetPath());
|
||||
|
||||
pWriter->m_pMainDocument = old_serializer;
|
||||
pWriter->m_pDocxSerializer = old_serializer;
|
||||
}
|
||||
else if (office_checker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX ||
|
||||
office_checker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM ||
|
||||
@ -614,16 +614,16 @@ namespace PPTX
|
||||
{
|
||||
pReader->Seek(pReader->GetPos() - 4); //roll back to size record
|
||||
std::wstring sXmlContent;
|
||||
if (pReader->m_pMainDocument)
|
||||
if (pReader->m_pDocxSerializer)
|
||||
{
|
||||
pReader->m_pMainDocument->getXmlContentElem(OOX::et_m_oMathPara, *pReader, sXmlContent);
|
||||
pReader->m_pDocxSerializer->getXmlContentElem(OOX::et_m_oMathPara, *pReader, sXmlContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
BinDocxRW::CDocxSerializer oDocxSerializer;
|
||||
NSBinPptxRW::CDrawingConverter oDrawingConverter;
|
||||
BinDocxRW::CDocxSerializer oDocxSerializer;
|
||||
NSBinPptxRW::CDrawingConverter oDrawingConverter;
|
||||
|
||||
oDrawingConverter.SetMainDocument(&oDocxSerializer);
|
||||
oDrawingConverter.SetDocxSerializer(&oDocxSerializer);
|
||||
|
||||
//oDocxSerializer.m_pParamsWriter = new BinDocxRW::ParamsWriter(oDrawingConverter.m_pBinaryWriter, &oFontProcessor, &oDrawingConverter, NULL);
|
||||
oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(L"", L"", false, 111, &oDrawingConverter, L"");
|
||||
@ -1839,9 +1839,9 @@ namespace PPTX
|
||||
std::wstring sThemePath, sMediaPath, sEmbedPath;
|
||||
oDocxSerializer.CreateDocxFolders(sDstEmbeddedTemp, sThemePath, sMediaPath, sEmbedPath);
|
||||
|
||||
oDrawingConverter.m_pReader->Init(pData, 0, length);
|
||||
oDrawingConverter.m_pBinaryReader->Init(pData, 0, length);
|
||||
|
||||
oDrawingConverter.SetMainDocument(&oDocxSerializer);
|
||||
oDrawingConverter.SetDocxSerializer(&oDocxSerializer);
|
||||
|
||||
oDrawingConverter.SetDstPath(sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"word");
|
||||
oDrawingConverter.SetSrcPath(pReader->m_strFolder, XMLWRITER_DOC_TYPE_DOCX);
|
||||
@ -1851,7 +1851,7 @@ namespace PPTX
|
||||
|
||||
std::wstring sDocxFilename = L"Microsoft_Word_Document" + std::to_wstring(id) + L".docx";
|
||||
|
||||
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pReader;
|
||||
NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pBinaryReader;
|
||||
|
||||
oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(sDstEmbeddedTemp, L"", false, 111, &oDrawingConverter, sThemePath);
|
||||
|
||||
@ -1914,7 +1914,7 @@ namespace PPTX
|
||||
|
||||
oXlsx.m_mapEnumeratedGlobal.clear();
|
||||
|
||||
oDrawingConverter.m_pReader->Init(pData, 0, length);
|
||||
oDrawingConverter.m_pBinaryReader->Init(pData, 0, length);
|
||||
|
||||
oDrawingConverter.SetDstPath(sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl");
|
||||
oDrawingConverter.SetSrcPath(pReader->m_strFolder, XMLWRITER_DOC_TYPE_XLSX);
|
||||
@ -1922,7 +1922,7 @@ namespace PPTX
|
||||
oDrawingConverter.SetMediaDstPath(sMediaPath);
|
||||
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
|
||||
|
||||
oEmbeddedReader.ReadMainTable(oXlsx, *oDrawingConverter.m_pReader, pReader->m_strFolder, sDstEmbeddedTemp, oSaveParams, &oDrawingConverter);
|
||||
oEmbeddedReader.ReadMainTable(oXlsx, *oDrawingConverter.m_pBinaryReader, pReader->m_strFolder, sDstEmbeddedTemp, oSaveParams, &oDrawingConverter);
|
||||
|
||||
oXlsx.PrepareToWrite();
|
||||
|
||||
@ -1951,7 +1951,7 @@ namespace PPTX
|
||||
|
||||
NSBinPptxRW::CDrawingConverter oDrawingConverter;
|
||||
|
||||
oDrawingConverter.m_pReader->Init(pData, 0, length);
|
||||
oDrawingConverter.m_pBinaryReader->Init(pData, 0, length);
|
||||
|
||||
std::wstring sXmlOptions, sMediaPath, sEmbedPath;
|
||||
BinVsdxRW::CVsdxSerializer::CreateVsdxFolders(sDstEmbeddedTemp, sMediaPath, sEmbedPath);
|
||||
@ -1967,7 +1967,7 @@ namespace PPTX
|
||||
|
||||
BinVsdxRW::BinaryFileReader oEmbeddedReader;
|
||||
BinVsdxRW::SaveParams oSaveParams(true);
|
||||
oEmbeddedReader.ReadContent(oVsdx, *oDrawingConverter.m_pReader, pReader->m_strFolder, sDstEmbeddedTemp, oSaveParams);
|
||||
oEmbeddedReader.ReadContent(oVsdx, *oDrawingConverter.m_pBinaryReader, pReader->m_strFolder, sDstEmbeddedTemp, oSaveParams);
|
||||
|
||||
OOX::CContentTypes oContentTypes;
|
||||
oVsdx.Write(sDstEmbeddedTemp, oContentTypes);
|
||||
|
||||
@ -160,9 +160,9 @@ xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\">\
|
||||
{
|
||||
pWriter->StartRecord(nRecordType);
|
||||
long lDataSize = 0;
|
||||
if(NULL != pWriter->m_pMainDocument)
|
||||
if(NULL != pWriter->m_pDocxSerializer)
|
||||
{
|
||||
pWriter->m_pMainDocument->getBinaryContentElem(eElemType, pElem, *pWriter, lDataSize);
|
||||
pWriter->m_pDocxSerializer->getBinaryContentElem(eElemType, pElem, *pWriter, lDataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -200,15 +200,15 @@ xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\">\
|
||||
NSBinPptxRW::CDrawingConverter oDrawingConverter;
|
||||
|
||||
NSBinPptxRW::CImageManager2* pOldImageManager = oDrawingConverter.m_pImageManager;
|
||||
NSBinPptxRW::CBinaryFileReader* pOldReader = oDrawingConverter.m_pReader;
|
||||
NSBinPptxRW::CBinaryFileReader* pOldReader = oDrawingConverter.m_pBinaryReader;
|
||||
|
||||
oDrawingConverter.m_pImageManager = pReader->m_pRels->m_pManager;
|
||||
oDrawingConverter.m_pReader = pReader;
|
||||
oDrawingConverter.m_pBinaryReader = pReader;
|
||||
|
||||
oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(L"", L"", true, BinDocxRW::g_nFormatVersion, &oDrawingConverter, L"");
|
||||
oDocxSerializer.getXmlContentElem(eType, *pReader, sXml);
|
||||
|
||||
oDrawingConverter.m_pReader = pOldReader;
|
||||
oDrawingConverter.m_pBinaryReader = pOldReader;
|
||||
oDrawingConverter.m_pImageManager = pOldImageManager;
|
||||
RELEASEOBJECT(oDocxSerializer.m_pCurFileWriter);
|
||||
|
||||
|
||||
@ -409,7 +409,7 @@ namespace PPTX
|
||||
}break;
|
||||
case 4:
|
||||
{
|
||||
if (NULL != pReader->m_pMainDocument)
|
||||
if (NULL != pReader->m_pDocxSerializer)
|
||||
{
|
||||
LONG lLenRec = pReader->GetLong();
|
||||
|
||||
@ -418,7 +418,7 @@ namespace PPTX
|
||||
BYTE* pData_Reader = pReader->GetData();
|
||||
|
||||
std::wstring sXmlContent;
|
||||
pReader->m_pMainDocument->getXmlContent(*pReader, lLenRec, sXmlContent);
|
||||
pReader->m_pDocxSerializer->getXmlContent(*pReader, lLenRec, sXmlContent);
|
||||
|
||||
std::wstring strC = L"<w:txbxContent>";
|
||||
strC += sXmlContent;
|
||||
@ -505,7 +505,7 @@ namespace PPTX
|
||||
pWriter->WriteRecord1(1, spPr);
|
||||
pWriter->WriteRecord2(2, style);
|
||||
|
||||
if (pWriter->m_pMainDocument != NULL)
|
||||
if (pWriter->m_pDocxSerializer != NULL)
|
||||
{
|
||||
if (oTextBoxShape.is_init())
|
||||
{
|
||||
@ -514,7 +514,7 @@ namespace PPTX
|
||||
pWriter->SetPosition(lPos);
|
||||
|
||||
pWriter->StartRecord(4);
|
||||
pWriter->m_pMainDocument->getBinaryContentElem(OOX::et_w_sdtContent, oTextBoxShape.GetPointer(), *pWriter, lDataSize);
|
||||
pWriter->m_pDocxSerializer->getBinaryContentElem(OOX::et_w_sdtContent, oTextBoxShape.GetPointer(), *pWriter, lDataSize);
|
||||
pWriter->EndRecord();
|
||||
|
||||
if (oTextBoxBodyPr.is_init())
|
||||
@ -531,7 +531,7 @@ namespace PPTX
|
||||
pWriter->SetPosition(lPos);
|
||||
|
||||
pWriter->StartRecord(4);
|
||||
pWriter->m_pMainDocument->getBinaryContent(strTextBoxShape.get(), *pWriter, lDataSize);
|
||||
pWriter->m_pDocxSerializer->getBinaryContent(strTextBoxShape.get(), *pWriter, lDataSize);
|
||||
pWriter->EndRecord();
|
||||
|
||||
if (oTextBoxBodyPr.is_init())
|
||||
@ -550,7 +550,7 @@ namespace PPTX
|
||||
ULONG lPos = pWriter->GetPosition();
|
||||
pWriter->SetPosition(lPos);
|
||||
pWriter->StartRecord(4);
|
||||
pWriter->m_pMainDocument->getBinaryContent(strContent, *pWriter, lDataSize);
|
||||
pWriter->m_pDocxSerializer->getBinaryContent(strContent, *pWriter, lDataSize);
|
||||
pWriter->EndRecord();
|
||||
|
||||
pWriter->WriteRecord2(5, txBody->bodyPr);
|
||||
|
||||
@ -178,8 +178,8 @@ namespace PPTX
|
||||
{
|
||||
OOX::IFileContainer* pDocumentRels = pWriter->GetRelsPtr();
|
||||
|
||||
BinDocxRW::CDocxSerializer *main_document = pWriter->m_pMainDocument;
|
||||
pWriter->m_pMainDocument = NULL;
|
||||
BinDocxRW::CDocxSerializer *main_document = pWriter->m_pDocxSerializer;
|
||||
pWriter->m_pDocxSerializer = NULL;
|
||||
if (id_data.IsInit())
|
||||
{
|
||||
smart_ptr<OOX::File> oFileData;
|
||||
@ -280,7 +280,7 @@ namespace PPTX
|
||||
}
|
||||
}
|
||||
pWriter->SetRelsPtr(pDocumentRels);
|
||||
pWriter->m_pMainDocument = main_document;
|
||||
pWriter->m_pDocxSerializer = main_document;
|
||||
}
|
||||
void SmartArt::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
@ -622,9 +622,9 @@ namespace PPTX
|
||||
//----------------------------------------------------------------
|
||||
NSBinPptxRW::CDrawingConverter oDrawingConverter;
|
||||
NSBinPptxRW::CBinaryFileWriter *pOldDrawingWriter = oDrawingConverter.m_pBinaryWriter;
|
||||
BinDocxRW::CDocxSerializer *pOldMainDocument = pWriter->m_pMainDocument;
|
||||
BinDocxRW::CDocxSerializer *pOldMainDocument = pWriter->m_pDocxSerializer;
|
||||
|
||||
pWriter->m_pMainDocument = NULL;
|
||||
pWriter->m_pDocxSerializer = NULL;
|
||||
oDrawingConverter.m_pBinaryWriter = pWriter;
|
||||
OOX::IFileContainer* oldRels = oDrawingConverter.GetRelsPtr();
|
||||
oDrawingConverter.SetRelsPtr(dynamic_cast<OOX::IFileContainer*>(file.GetPointer()));
|
||||
@ -672,7 +672,7 @@ namespace PPTX
|
||||
oDrawingConverter.SetRelsPtr(oldRels);
|
||||
|
||||
oDrawingConverter.m_pBinaryWriter = pOldDrawingWriter;
|
||||
pWriter->m_pMainDocument = pOldMainDocument;
|
||||
pWriter->m_pDocxSerializer = pOldMainDocument;
|
||||
|
||||
}
|
||||
std::wstring ChartRec::toXML() const
|
||||
@ -707,10 +707,10 @@ namespace PPTX
|
||||
NSBinPptxRW::CDrawingConverter oDrawingConverter;
|
||||
|
||||
NSBinPptxRW::CImageManager2* pOldImageManager = oDrawingConverter.m_pImageManager;
|
||||
NSBinPptxRW::CBinaryFileReader* pOldReader = oDrawingConverter.m_pReader;
|
||||
NSBinPptxRW::CBinaryFileReader* pOldReader = oDrawingConverter.m_pBinaryReader;
|
||||
|
||||
oDrawingConverter.m_pImageManager = pReader->m_pRels->m_pManager;
|
||||
oDrawingConverter.m_pReader = pReader;
|
||||
oDrawingConverter.m_pBinaryReader = pReader;
|
||||
|
||||
oXlsxSerializer.setDrawingConverter(&oDrawingConverter);
|
||||
|
||||
@ -745,8 +745,8 @@ namespace PPTX
|
||||
id_data = new OOX::RId(nRId);
|
||||
}
|
||||
}
|
||||
oDrawingConverter.m_pReader = pOldReader;
|
||||
oDrawingConverter.m_pImageManager = pOldImageManager;
|
||||
oDrawingConverter.m_pBinaryReader = pOldReader;
|
||||
oDrawingConverter.m_pImageManager = pOldImageManager;
|
||||
}
|
||||
void ChartRec::FillParentPointersForChilds()
|
||||
{
|
||||
|
||||
@ -409,15 +409,9 @@ namespace PPTX
|
||||
_UINT32 len = (_UINT32)SpTreeElems.size();
|
||||
pWriter->WriteULONG(len);
|
||||
|
||||
double oldCxCurShape = pWriter->m_dCxCurShape;
|
||||
double oldCyCurShape = pWriter->m_dCyCurShape;
|
||||
|
||||
for (_UINT32 i = 0; i < len; ++i)
|
||||
{
|
||||
pWriter->WriteRecord1(0, SpTreeElems[i]);
|
||||
|
||||
pWriter->m_dCxCurShape = oldCxCurShape;
|
||||
pWriter->m_dCyCurShape = oldCyCurShape;
|
||||
pWriter->WriteRecord1(0, SpTreeElems[i]);
|
||||
}
|
||||
pWriter->EndRecord();
|
||||
//---------------------------------------------------------------------------------------
|
||||
@ -551,8 +545,8 @@ namespace PPTX
|
||||
}
|
||||
void LockedCanvas::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
BinDocxRW::CDocxSerializer* docx = pWriter->m_pMainDocument;
|
||||
pWriter->m_pMainDocument = NULL;
|
||||
BinDocxRW::CDocxSerializer* docx = pWriter->m_pDocxSerializer;
|
||||
pWriter->m_pDocxSerializer = NULL;
|
||||
|
||||
pWriter->StartRecord(SPTREE_TYPE_LOCKED_CANVAS);
|
||||
|
||||
@ -561,7 +555,7 @@ namespace PPTX
|
||||
pWriter->WriteRecordArray(2, 0, SpTreeElems);
|
||||
|
||||
pWriter->EndRecord();
|
||||
pWriter->m_pMainDocument = docx;
|
||||
pWriter->m_pDocxSerializer = docx;
|
||||
}
|
||||
void LockedCanvas::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
@ -569,8 +563,8 @@ namespace PPTX
|
||||
|
||||
pReader->Skip(5); // type + len
|
||||
|
||||
BinDocxRW::CDocxSerializer* docx = pReader->m_pMainDocument;
|
||||
pReader->m_pMainDocument = NULL;
|
||||
BinDocxRW::CDocxSerializer* docx = pReader->m_pDocxSerializer;
|
||||
pReader->m_pDocxSerializer = NULL;
|
||||
|
||||
while (pReader->GetPos() < _end_rec)
|
||||
{
|
||||
@ -621,7 +615,7 @@ namespace PPTX
|
||||
}
|
||||
}
|
||||
pReader->Seek(_end_rec);
|
||||
pReader->m_pMainDocument = docx;
|
||||
pReader->m_pDocxSerializer = docx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,14 +115,37 @@ namespace PPTX
|
||||
{
|
||||
Paragrs.clear();
|
||||
|
||||
m_name = node.GetName();
|
||||
m_name = node.GetName();
|
||||
|
||||
bodyPr = node.ReadNode(L"a:bodyPr");
|
||||
lstStyle = node.ReadNode(L"a:lstStyle");
|
||||
sp3d = node.ReadNode(L"a:sp3d");
|
||||
std::vector<XmlUtils::CXmlNode> oNodes;
|
||||
if (node.GetNodes(_T("*"), oNodes))
|
||||
{
|
||||
size_t count = oNodes.size();
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode& oNode = oNodes[i];
|
||||
|
||||
XmlMacroLoadArray(node, L"a:p", Paragrs, Paragraph);
|
||||
std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName());
|
||||
|
||||
if (L"bodyPr" == strName)
|
||||
{
|
||||
bodyPr = oNode;
|
||||
}
|
||||
else if (L"lstStyle" == strName)
|
||||
{
|
||||
lstStyle = oNode;
|
||||
}
|
||||
else if (L"sp3d" == strName)
|
||||
{
|
||||
sp3d = oNode;
|
||||
}
|
||||
else if (L"p" == strName)
|
||||
{
|
||||
Paragrs.emplace_back();
|
||||
Paragrs.back().fromXML(oNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
FillParentPointersForChilds();
|
||||
}
|
||||
std::wstring TxBody::toXML() const
|
||||
|
||||
@ -188,415 +188,49 @@ namespace PPTX
|
||||
void UniFill::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
LONG read_start = pReader->GetPos();
|
||||
LONG read_end = read_start + pReader->GetLong() + 4;
|
||||
LONG read_end = read_start + pReader->GetRecordSize() + 4;
|
||||
|
||||
m_type = notInit;
|
||||
|
||||
if (pReader->GetPos() < read_end)
|
||||
{
|
||||
BYTE _type = pReader->GetUChar();
|
||||
LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4;
|
||||
pReader->Seek(read_start);
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case FILL_TYPE_BLIP:
|
||||
{
|
||||
pReader->Skip(1);
|
||||
|
||||
PPTX::Logic::BlipFill* pFill = new PPTX::Logic::BlipFill();
|
||||
pFill->m_namespace = _T("a");
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0:
|
||||
pFill->dpi = pReader->GetLong();
|
||||
break;
|
||||
case 1:
|
||||
pFill->rotWithShape = pReader->GetBool();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _e)
|
||||
{
|
||||
BYTE rec = pReader->GetUChar();
|
||||
|
||||
switch (rec)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
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:
|
||||
{
|
||||
if (!pFill->blip.is_init())
|
||||
pFill->blip = new PPTX::Logic::Blip();
|
||||
|
||||
pReader->Skip(4);
|
||||
ULONG count_effects = pReader->GetULong();
|
||||
for (ULONG _eff = 0; _eff < count_effects; ++_eff)
|
||||
{
|
||||
pReader->Skip(1); // type
|
||||
|
||||
pFill->blip->Effects.push_back(UniEffect());
|
||||
pFill->blip->Effects.back().fromPPTY(pReader);
|
||||
|
||||
if (false == pFill->blip->Effects.back().is_init())
|
||||
{
|
||||
pFill->blip->Effects.pop_back();
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case 3:
|
||||
{
|
||||
pReader->Skip(6); // len + start attributes + type
|
||||
|
||||
// -------------------
|
||||
std::wstring strUrl = pReader->GetString2(true);
|
||||
std::wstring strTempFile;
|
||||
std::wstring strOrigBase64;
|
||||
|
||||
|
||||
if (0 == strUrl.find(_T("data:")))
|
||||
{
|
||||
bool bBase64 = false;
|
||||
|
||||
strOrigBase64 = strUrl;
|
||||
int nFind = (int)strUrl.find(_T(","));
|
||||
|
||||
std::wstring sImageExtension;
|
||||
|
||||
std::wstring sFormatDataString = XmlUtils::GetLower(strUrl.substr(5, nFind - 5));
|
||||
{
|
||||
int nFind1 = (int)sFormatDataString.find(_T("base64"));
|
||||
if (nFind1 >=0 ) bBase64 = true;
|
||||
|
||||
nFind1 = (int)sFormatDataString.find(_T("image/"));
|
||||
if (nFind1>=0)
|
||||
{
|
||||
int nFind2 = (int)sFormatDataString.find(_T(";"));
|
||||
if (nFind2 < 0) nFind2 = (int)sFormatDataString.length();
|
||||
|
||||
sImageExtension = sFormatDataString.substr(nFind1 + 6, nFind2 - 6 - nFind1);
|
||||
}
|
||||
}
|
||||
strUrl.erase(0, nFind + 1);
|
||||
|
||||
std::string __s = std::string(strUrl.begin(), strUrl.end());
|
||||
int len =(int)__s.length();
|
||||
BYTE* pDstBuffer = NULL;
|
||||
int dstLen = 0;
|
||||
|
||||
if (true)//(bBase64)
|
||||
{
|
||||
bBase64 = true;
|
||||
int dstLenTemp = Base64::Base64DecodeGetRequiredLength(len);
|
||||
|
||||
pDstBuffer = new BYTE[dstLenTemp];
|
||||
dstLen = dstLenTemp;
|
||||
Base64::Base64Decode(__s.c_str(), len, pDstBuffer, &dstLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
pDstBuffer = (BYTE*) __s.c_str();
|
||||
dstLen = len;
|
||||
}
|
||||
CImageFileFormatChecker checker;
|
||||
std::wstring detectImageExtension = checker.DetectFormatByData(pDstBuffer, dstLen);
|
||||
|
||||
if (false == detectImageExtension.empty())
|
||||
{
|
||||
sImageExtension = detectImageExtension;
|
||||
|
||||
//папки media может не быть в случае, когда все картинки base64(поскольку файл временный, папку media не создаем)
|
||||
std::wstring tempFilePath = pReader->m_strFolder + FILE_SEPARATOR_STR;
|
||||
|
||||
OOX::CPath pathTemp = NSFile::CFileBinary::CreateTempFileWithUniqueName(tempFilePath, _T("img")) + _T(".") + sImageExtension;
|
||||
|
||||
NSFile::CFileBinary oTempFile;
|
||||
oTempFile.CreateFile(pathTemp.GetPath());
|
||||
oTempFile.WriteFile((void*)pDstBuffer, (DWORD)dstLen);
|
||||
oTempFile.CloseFile();
|
||||
|
||||
strUrl = strTempFile =pathTemp.GetPath(); // strTempFile для удаления
|
||||
if (bBase64)
|
||||
{
|
||||
RELEASEARRAYOBJECTS(pDstBuffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{// бяка
|
||||
strUrl.clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != strUrl.find(_T("http:")) &&
|
||||
0 != strUrl.find(_T("https:")) &&
|
||||
0 != strUrl.find(_T("ftp:")) &&
|
||||
0 != strUrl.find(_T("file:")))
|
||||
{
|
||||
if (0 == strUrl.find(_T("theme")))
|
||||
{
|
||||
strUrl = pReader->m_strFolderExternalThemes + FILE_SEPARATOR_STR + strUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
strUrl = pReader->m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + strUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------
|
||||
|
||||
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, pFill->additionalFiles, pFill->oleData, strOrigBase64);
|
||||
|
||||
// -------------------
|
||||
if (!strTempFile.empty())
|
||||
{
|
||||
CDirectory::DeleteFile(strTempFile);
|
||||
}
|
||||
// -------------------
|
||||
|
||||
if (!pFill->blip.is_init())
|
||||
pFill->blip = new PPTX::Logic::Blip();
|
||||
|
||||
pFill->blip->embed = new OOX::RId(oRelsGeneratorInfo.nImageRId);
|
||||
pFill->blip->imageFilepath = oRelsGeneratorInfo.sFilepathImage;
|
||||
|
||||
if (pFill->blip.is_init())
|
||||
pFill->blip->m_namespace = _T("a");
|
||||
|
||||
if(oRelsGeneratorInfo.nOleRId > 0)
|
||||
{
|
||||
pFill->blip->oleRid = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
|
||||
pFill->blip->oleFilepathBin = oRelsGeneratorInfo.sFilepathOle;
|
||||
}
|
||||
if(oRelsGeneratorInfo.nMediaRId > 0)
|
||||
{
|
||||
pFill->blip->mediaRid = OOX::RId((size_t)oRelsGeneratorInfo.nMediaRId).get();
|
||||
pFill->blip->mediaFilepath = oRelsGeneratorInfo.sFilepathMedia;
|
||||
}
|
||||
pReader->Skip(1); // end attribute
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
pReader->Seek(_e2);
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
pFill->srcRect = new PPTX::Logic::Rect();
|
||||
pFill->srcRect->m_name = L"a:srcRect";
|
||||
pFill->srcRect->fromPPTY(pReader);
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
pFill->tile = new PPTX::Logic::Tile();
|
||||
pFill->tile->fromPPTY(pReader);
|
||||
}break;
|
||||
case 3:
|
||||
{
|
||||
pFill->stretch = new PPTX::Logic::Stretch();
|
||||
pFill->stretch->fromPPTY(pReader);
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
pFill->fromPPTY(pReader);
|
||||
|
||||
m_type = blipFill;
|
||||
Fill = pFill;
|
||||
}break;
|
||||
case FILL_TYPE_GRAD:
|
||||
{
|
||||
pReader->Skip(1);
|
||||
|
||||
PPTX::Logic::GradFill* pFill = new PPTX::Logic::GradFill();
|
||||
pFill->m_namespace = _T("a");
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0:
|
||||
pFill->flip = pReader->GetUChar();
|
||||
break;
|
||||
case 1:
|
||||
pFill->rotWithShape = pReader->GetBool();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _e)
|
||||
{
|
||||
BYTE rec = pReader->GetUChar();
|
||||
|
||||
switch (rec)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
LONG _s1 = pReader->GetPos();
|
||||
LONG _e1 = _s1 + pReader->GetLong() + 4;
|
||||
|
||||
ULONG _count = pReader->GetULong();
|
||||
for (ULONG i = 0; i < _count; ++i)
|
||||
{
|
||||
if (pReader->GetPos() >= _e1)
|
||||
break;
|
||||
|
||||
pReader->Skip(1); // type
|
||||
pReader->Skip(4); // len
|
||||
|
||||
size_t _countGs = pFill->GsLst.size();
|
||||
pFill->GsLst.push_back(Gs());
|
||||
|
||||
pReader->Skip(1); // start attr
|
||||
pReader->Skip(1); // pos type
|
||||
pFill->GsLst[_countGs].pos = pReader->GetLong();
|
||||
pReader->Skip(1); // end attr
|
||||
|
||||
pReader->Skip(1);
|
||||
pFill->GsLst[_countGs].color.fromPPTY(pReader);
|
||||
}
|
||||
|
||||
pReader->Seek(_e1);
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
pFill->lin = new PPTX::Logic::Lin();
|
||||
pFill->lin->fromPPTY(pReader);
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
pFill->path = new PPTX::Logic::Path();
|
||||
pFill->path->fromPPTY(pReader);
|
||||
}break;
|
||||
case 3:
|
||||
{
|
||||
pFill->tileRect = new PPTX::Logic::Rect();
|
||||
pFill->tileRect->m_name = L"a:tileRect";
|
||||
pFill->tileRect->fromPPTY(pReader);
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
pReader->SkipRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
pFill->fromPPTY(pReader);
|
||||
|
||||
m_type = gradFill;
|
||||
Fill = pFill;
|
||||
}break;
|
||||
case FILL_TYPE_PATT:
|
||||
{
|
||||
pReader->Skip(1);
|
||||
PPTX::Logic::PattFill* pFill = new PPTX::Logic::PattFill();
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
switch (_at)
|
||||
{
|
||||
case 0:
|
||||
pFill->prst = pReader->GetUChar();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (pReader->GetPos() < _e)
|
||||
{
|
||||
BYTE rec = pReader->GetUChar();
|
||||
|
||||
switch (rec)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
pFill->fgClr.fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
pFill->bgClr.fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// пока никаких настроек градиента нет
|
||||
pReader->SkipRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pFill->m_namespace = _T("a");
|
||||
pFill->fromPPTY(pReader);
|
||||
|
||||
m_type = pattFill;
|
||||
Fill = pFill;
|
||||
|
||||
Fill = pFill;
|
||||
}break;
|
||||
case FILL_TYPE_SOLID:
|
||||
{
|
||||
pReader->Skip(1); // type + len
|
||||
|
||||
PPTX::Logic::SolidFill* pFill = new PPTX::Logic::SolidFill();
|
||||
pFill->m_namespace = _T("a");
|
||||
|
||||
pFill->Color.fromPPTY(pReader);
|
||||
pFill->fromPPTY(pReader);
|
||||
|
||||
m_type = solidFill;
|
||||
Fill = pFill;
|
||||
@ -604,7 +238,7 @@ namespace PPTX
|
||||
case FILL_TYPE_NOFILL:
|
||||
{
|
||||
m_type = noFill;
|
||||
Fill = new PPTX::Logic::NoFill();
|
||||
Fill = new PPTX::Logic::NoFill();
|
||||
}break;
|
||||
case FILL_TYPE_GRP:
|
||||
{
|
||||
|
||||
@ -291,16 +291,18 @@ namespace PPTX
|
||||
}
|
||||
void Xfrm::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
if (chExtX.IsInit() && extX.IsInit())
|
||||
pWriter->m_dCxCurShape = pWriter->m_dCxCurShape * (double)*extX / (double)*chExtX;
|
||||
else if (extX.IsInit())
|
||||
pWriter->m_dCxCurShape = ((pWriter->m_bInGroup && pWriter->m_dCxCurShape > 0) ? pWriter->m_dCxCurShape : 1) * *extX;
|
||||
|
||||
if (chExtY.IsInit() && extY.IsInit())
|
||||
pWriter->m_dCyCurShape = pWriter->m_dCyCurShape * (double)*extY / (double)*chExtY;
|
||||
else if (extY.IsInit())
|
||||
pWriter->m_dCyCurShape = ((pWriter->m_bInGroup && pWriter->m_dCyCurShape > 0) ? pWriter->m_dCyCurShape : 1) * *extY;
|
||||
if (pWriter->GetShapeWidth() < 1 || pWriter->GetShapeHeight() < 1)
|
||||
{
|
||||
double cx = 0, cy = 0;
|
||||
|
||||
if (extX.IsInit())
|
||||
cx = *extX;
|
||||
|
||||
if (extY.IsInit())
|
||||
cy = *extY;
|
||||
|
||||
pWriter->SetCurShapeSize(cx, cy);
|
||||
}
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
pWriter->WriteInt2(0, offX);
|
||||
pWriter->WriteInt2(1, offY);
|
||||
|
||||
Reference in New Issue
Block a user