Compare commits

..

16 Commits

16 changed files with 275 additions and 94 deletions

View File

@ -2089,11 +2089,11 @@ void variable_set::docx_convert(oox::docx_conversion_context & Context)
Context.output_stream() << L"<w:id w:val=\"" + std::to_wstring(Context.get_drawing_context().get_current_shape_id()) + L"\"/>";
if (name_)
{
Context.output_stream() << L"<w:placeholder>";
Context.output_stream() << L"<w:placeholder/>";
Context.output_stream() << L"<w:docPart w:val=\"" + xml::utils::replace_text_to_xml(*name_) + L"\"/>";
}
Context.output_stream() << L"<w:showingPlcHdr/>";
//Context.output_stream() << L"<w:text/>";
Context.output_stream() << L"<w:text/>";
}
Context.output_stream() << L"</w:sdtPr>";
Context.output_stream() << L"<w:sdtContent>";

View File

@ -52,6 +52,7 @@ void Animation::Convert(PPTX::Logic::Timing &oTiming)
{
if (m_pPPT10)
{
m_isPPT10Broken = false;
// It must be first to write some reference from ExtTimeNodeContainer
if (m_pPPT10->m_haveBuildList && !m_pPPT10->m_pBuildListContainer->n_arrRgChildRec.empty())
{
@ -66,7 +67,7 @@ void Animation::Convert(PPTX::Logic::Timing &oTiming)
FillTnLst(m_pPPT10->m_pExtTimeNodeContainer, *(oTiming.tnLst));
}
}
if (!m_arrOldAnim.empty() || m_isPPT10Broken)
if (!m_arrOldAnim.empty() && m_isPPT10Broken)
{
oTiming = PPTX::Logic::Timing();
InitTimingTags(oTiming);
@ -162,8 +163,8 @@ void Animation::FillAnim(
}
auto tavTime = animValue->m_oTimeAnimationValueAtom.m_nTime;
if (tavTime < 1000 && tavTime >= 0)
tav.tm = std::to_wstring((1000 - tavTime) * 100);
if (tavTime <= 1000 && tavTime >= 0) // todo check
tav.tm = std::to_wstring((/*1000 - */tavTime) * 100);
if (!animValue->m_VarFormula.m_Value.empty())
{
@ -424,6 +425,8 @@ void Animation::FillAudio(CRecordExtTimeNodeContainer *pETNC,
{
oAudio.cMediaNode.tgtEl.spTgt = new PPTX::Logic::SpTgt;
oAudio.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef);
// oAudio.isNarration = true;
// oAudio.cMediaNode.showWhenStopped = false;
} else
return;
FillCTn(pETNC, oAudio.cMediaNode.cTn);
@ -634,7 +637,6 @@ void Animation::FillCBhvr(
// accumulate - MUST be 0
// xfrmType - MUST be 0
if (pBhvr->m_haveStringList)
{
if (!pBhvr->m_pStringList->m_arrRgChildRec.empty())
@ -678,6 +680,46 @@ void Animation::FillCBhvr(
oBhvr.tgtEl.spTgt->txEl->end = pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData2;
}
}
if (pBhvr->m_pPropertyList == nullptr)
return;
for (const auto prop : pBhvr->m_pPropertyList->m_arRecords)
{
if (prop == nullptr)
continue;
switch (prop->m_oHeader.RecInstance)
{
case TL_TBPID_RuntimeContext:
break;
case TL_TBPID_MotionPathEditRelative:
break;
case TL_TBPID_ColorColorModel:
break;
case TL_TBPID_ColorDirection:
break;
case TL_TBPID_Override:
{
auto override_ = new PPTX::Limit::TLOverride;
override_->set(L"childStyle");
oBhvr.override_= override_;
break;
}
case TL_TBPID_PathEditRotationAngle:
break;
case TL_TBPID_PathEditRotationX:
break;
case TL_TBPID_PathEditRotationY:
break;
case TL_TBPID_PointsTypes:
break;
case TL_TBPID_UnknownPropertyList:
default:
break;
}
}
}
void Animation::FillCBhvr(
PPTX::Logic::CBhvr &oBhvr, int dur,
@ -780,6 +822,9 @@ void Animation::FillCond(
cond.tgtEl->spTgt = new PPTX::Logic::SpTgt;
cond.tgtEl->spTgt->spid = std::to_wstring(
oldCond->m_oVisualElement.m_oVisualShapeAtom.m_nObjectIdRef);
} else if (oldCond->m_oVisualElement.m_bVisualPageAtom)
{
cond.tgtEl = new PPTX::Logic::TgtEl;
}
}
@ -873,12 +918,15 @@ void Animation::FillCTn(
if (iter->m_fIterateDirectionPropertyUsed)
oCTn.iterate->backwards = (bool)iter->m_nIterateDirection;
if (iter->m_fIterateIntervalTypePropertyUsed)
oCTn.iterate->tmPct = iter->m_nIterateInterval;
if (iter->m_fIterateIntervalPropertyUsed)
oCTn.iterate->tmAbs = std::to_wstring(iter->m_nIterateIntervalType);
int intervalType = iter->m_fIterateIntervalTypePropertyUsed ?
iter->m_nIterateIntervalType : 0;
unsigned int iterateInterval = iter->m_fIterateIntervalPropertyUsed ?
iter->m_nIterateInterval : 0;
if (intervalType)
oCTn.iterate->tmPct = iterateInterval > 1000 ? 10000 : iterateInterval * 10;
else
oCTn.iterate->tmAbs = std::to_wstring(iterateInterval);
}
@ -1437,6 +1485,9 @@ void Animation::SplitAnim(std::list<std::list<SOldAnimation*> >& arrClickPar)
for (auto& oldAnim : m_arrOldAnim)
{
if (isSpidReal(oldAnim.shapeId) == false)
continue;
if (arrClickPar.empty())
{
std::list<SOldAnimation*> clickPar;
@ -1670,6 +1721,7 @@ void Animation::FillCTnAnimation (PPTX::Logic::CTn &oCTN, SOldAnimation *pOldAn
const UINT effect = pOldAnim->anim->m_AnimationAtom.m_AnimEffect;
const UINT direct = pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection;
// Todo 4, 7. 0x11 - 0x1B
switch (effect)
{
case 0x00:
@ -1702,6 +1754,12 @@ void Animation::FillCTnAnimation (PPTX::Logic::CTn &oCTN, SOldAnimation *pOldAn
ConvertDissolveIn(oCTN.childTnLst.get2(), pOldAnim);
break;
}
case 0x06:
{
oCTN.presetID = 10;
ConvertFade(oCTN.childTnLst.get2(), pOldAnim);
break;
}
case 0x08:
{
oCTN.presetID = 14;
@ -1771,6 +1829,11 @@ void Animation::FillCTnAnimation (PPTX::Logic::CTn &oCTN, SOldAnimation *pOldAn
ConvertFlashOnce(oCTN.childTnLst.get2(), pOldAnim, presetSub);
break;
}
default:
oCTN.presetID = 1;
ConvertAppear(oCTN.childTnLst.get2(), pOldAnim);
std::wcout << "Error: Unknown old animation id: " << std::to_wstring(effect) << L"\n";
}
if (presetSub != -1)
@ -1970,6 +2033,12 @@ void Animation::ConvertDissolveIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimatio
PushAnimEffect(oParent, pOldAnim, L"dissolve", L"in");
}
void Animation::ConvertFade(PPTX::Logic::ChildTnLst &oParent, SOldAnimation *pOldAnim)
{
PushSet(oParent, pOldAnim);
PushAnimEffect(oParent, pOldAnim, L"fade", L"in");
}
void Animation::ConvertFlashOnce(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int& presetSub)
{
PushSet(oParent, pOldAnim);
@ -2389,14 +2458,19 @@ void Animation::PushSet(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAni
bool Animation::isSpidReal(const UINT spid)
{
if (m_arrOldAnim.empty())
if (m_realShapesId.find(spid) == m_realShapesId.end())
return false;
else
return true;
for (const auto& oldAnim : m_arrOldAnim)
if (oldAnim.shapeId == spid)
return true;
// if (m_arrOldAnim.empty())
// return true;
return false;
// for (const auto& oldAnim : m_arrOldAnim)
// if (oldAnim.shapeId == spid)
// return true;
// return false;
}

View File

@ -53,6 +53,7 @@
#include "../Records/SlideProgTagsContainer.h"
#include "ImageManager.h"
#include "../Records/Animations/AnimationInfoContainer.h"
#include <unordered_set>
namespace PPT_FORMAT
{
@ -86,14 +87,16 @@ struct SValue
class Animation
{
public:
Animation(CRecordPP10SlideBinaryTagExtension *pPPT10Ext, const std::vector<SOldAnimation> &oldAnim, CExMedia* pExMedia, CRelsGenerator* pRels) :
Animation(CRecordPP10SlideBinaryTagExtension *pPPT10Ext, const std::vector<SOldAnimation> &oldAnim,
CExMedia* pExMedia, CRelsGenerator* pRels, const std::unordered_set<int>& realShapesId) :
m_pPPT10(pPPT10Ext),
m_arrOldAnim(oldAnim),
m_pExMedia(pExMedia),
m_pRels(pRels),
m_cTnId(1),
m_pBldLst(nullptr),
m_currentBldP(nullptr)
m_currentBldP(nullptr),
m_realShapesId(realShapesId)
{
}
@ -216,6 +219,7 @@ private:
void ConvertCheckerboard(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim);
void ConvertCrawlIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub);
void ConvertDissolveIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim);
void ConvertFade(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim);
void ConvertFlashOnce(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub);
void ConvertPeekIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub);
void ConvertRandomBars(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub);
@ -259,9 +263,10 @@ private:
int m_cTnDeep = 0;
PPTX::Logic::BldLst *m_pBldLst; // Do not delete
PPTX::Logic::BldP *m_currentBldP;
const std::unordered_set<int> m_realShapesId;
int m_nextRID; // it needs for audio maybe video for compisation id number;
bool m_isPPT10Broken = false;
bool m_isPPT10Broken = true;
};
}

View File

@ -136,7 +136,7 @@ void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo)
// core
oFile.CreateFileW(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml"));
if (m_xmlCore.empty())
if (m_xmlCore.empty())
m_xmlCore = NSPPTXWriterConst::g_string_core;
oFile.WriteStringUTF8(m_xmlCore);
oFile.CloseFile();
@ -1537,12 +1537,16 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide)
CGroupElement *pGroupElement = !pSlide->m_arElements.empty() ? dynamic_cast<CGroupElement *>(pSlide->m_arElements[0].get()) : NULL;
size_t start_index = 0;
std::unordered_set<int> realShapesId;
if (pGroupElement)
{
for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i)
{
WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]);
auto& element = pGroupElement->m_pChildElements[i];
WriteElement(oWriter, oRels, element);
if (element)
realShapesId.insert(element->m_lID);
}
start_index = 1;
@ -1550,7 +1554,10 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide)
for (size_t i = start_index; i < pSlide->m_arElements.size(); ++i)
{
WriteElement(oWriter, oRels, pSlide->m_arElements[i]);
auto& element = pSlide->m_arElements[i];
WriteElement(oWriter, oRels, element);
if (element)
realShapesId.insert(element->m_lID);
}
oWriter.WriteString(std::wstring(L"</p:spTree></p:cSld>"));
@ -1560,7 +1567,7 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide)
WriteTransition(oWriter, pSlide->m_oSlideShow);
// TODO write new method and class for timing
WriteTiming(oWriter, oRels, nIndexSlide);
WriteTiming(oWriter, oRels, realShapesId, nIndexSlide);
oWriter.WriteString(std::wstring(L"</p:sld>"));
@ -2029,7 +2036,7 @@ void CPPTXWriter::WriteLayoutAfterTheme(CThemePtr pTheme, const int nIndexTheme,
}
void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide)
void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, const std::unordered_set<int>& realShapesId, int nIndexSlide)
{
PPTX::Logic::Timing oTiming;
@ -2056,10 +2063,10 @@ void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator
}
}
if (!pPP10SlideBinaryTag && arrOldAnim.empty())
if (/*!pPP10SlideBinaryTag && */arrOldAnim.empty()) // todo check condition
return;
Animation animation(pPP10SlideBinaryTag, arrOldAnim, &(m_pUserInfo->m_oExMedia), &oRels);
Animation animation(pPP10SlideBinaryTag, arrOldAnim, &(m_pUserInfo->m_oExMedia), &oRels, realShapesId);
animation.Convert(oTiming);
oWriter.WriteString(oTiming.toXML());

View File

@ -89,7 +89,7 @@ namespace PPT_FORMAT
// void WriteRelsMaster (std::wstring path, int type, )
void WriteSlide (int nIndexSlide);
void WriteNotes (int nIndexNotes);
void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide); // TODO write spec class for timing
void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, const std::unordered_set<int> &realShapesId, int nIndexSlide);
void WriteTransition (CStringWriter& oWriter, CSlideShowInfo& oSSInfo);
void WriteColorScheme (CStringWriter& oWriter, const std::wstring & name, const std::vector<CColor> & colors, bool extra = false);

View File

@ -482,7 +482,7 @@ std::wstring PPT_FORMAT::CShapeWriter::ConvertShadow(CShadow & shadow)
}
else
{
// needHiddenEffect = shadow.Visible;
// needHiddenEffect = shadow.Visible;
shadow_writer.WriteString(L"<a:outerShdw");
shadow_writer.WriteString(strDist);
shadow_writer.WriteString(strDir);
@ -499,14 +499,14 @@ std::wstring PPT_FORMAT::CShapeWriter::ConvertShadow(CShadow & shadow)
shadow_writer.WriteString(L"</a:outerShdw>");
}
shadow_writer.WriteString(L"</a:effectLst>");
// if (needHiddenEffect)
// {
// std::wstring STRshadow;
// STRshadow = L"<a:extLst><a:ext uri=\"{AF507438-7753-43E0-B8FC-AC1667EBCBE1}\"><a14:hiddenEffects xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\">";
// STRshadow += shadow_writer.GetData();
// STRshadow += L"</a14:hiddenEffects></a:ext><a:ext uri=\"{53640926-AAD7-44D8-BBD7-CCE9431645EC}\"><a14:shadowObscured xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"1\"/></a:ext></a:extLst>";
// return STRshadow;
// }
// if (needHiddenEffect)
// {
// std::wstring STRshadow;
// STRshadow = L"<a:extLst><a:ext uri=\"{AF507438-7753-43E0-B8FC-AC1667EBCBE1}\"><a14:hiddenEffects xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\">";
// STRshadow += shadow_writer.GetData();
// STRshadow += L"</a14:hiddenEffects></a:ext><a:ext uri=\"{53640926-AAD7-44D8-BBD7-CCE9431645EC}\"><a14:shadowObscured xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"1\"/></a:ext></a:extLst>";
// return STRshadow;
// }
return shadow_writer.GetData();
}
@ -628,11 +628,11 @@ void PPT_FORMAT::CShapeWriter::WriteImageInfo()
bool bExternal = false;
std::wstring strRid = m_pRels->WriteAudio(pAudioElement->m_strAudioFileName, bExternal);
if ((int)pAudioElement->m_strAudioFileName.find(L".WAV") == -1 &&
(int)pAudioElement->m_strAudioFileName.find(L".wav") == -1)
m_oWriter.WriteString(L"<a:audioFile r:link=\"" + strRid + L"\"/>");
else
m_oWriter.WriteString(L"<a:wavAudioFile r:embed=\"" + strRid + L"\"/>");
// if ((int)pAudioElement->m_strAudioFileName.find(L".WAV") == -1 &&
// (int)pAudioElement->m_strAudioFileName.find(L".wav") == -1)
// m_oWriter.WriteString(L"<a:wavAudioFile r:embed=\"" + strRid + L"\"/>");
// else
m_oWriter.WriteString(L"<a:audioFile r:link=\"" + strRid + L"\"/>"); // todo for anim connection
sMediaFile = bExternal ? L"" : pAudioElement->m_strAudioFileName;
}
@ -676,7 +676,7 @@ void PPT_FORMAT::CShapeWriter::WriteGroupInfo()
if (!pGroupElement->m_sDescription.empty())
{
m_oWriter.WriteString(std::wstring(L" descr=\""));
m_oWriter.WriteStringXML(pGroupElement->m_sDescription);
m_oWriter.WriteStringXML(XmlUtils::EncodeXmlStringExtend(pGroupElement->m_sDescription));
m_oWriter.WriteString(std::wstring(L"\""));
}
m_oWriter.WriteString(std::wstring(L">"));
@ -729,7 +729,7 @@ void PPT_FORMAT::CShapeWriter::WriteTableInfo()
if (!pGroupElement->m_sDescription.empty())
{
m_oWriter.WriteString(std::wstring(L" descr=\""));
m_oWriter.WriteStringXML(pGroupElement->m_sDescription);
m_oWriter.WriteStringXML(XmlUtils::EncodeXmlStringExtend(pGroupElement->m_sDescription));
m_oWriter.WriteString(std::wstring(L"\""));
}
m_oWriter.WriteString(std::wstring(L">"));
@ -782,7 +782,7 @@ void PPT_FORMAT::CShapeWriter::WriteShapeInfo()
if (!pShapeElement->m_sDescription.empty())
{
m_oWriter.WriteString(std::wstring(L" descr=\""));
m_oWriter.WriteStringXML(pShapeElement->m_sDescription);
m_oWriter.WriteStringXML(XmlUtils::EncodeXmlStringExtend(pShapeElement->m_sDescription, true));
m_oWriter.WriteString(std::wstring(L"\""));
}
m_oWriter.WriteString(std::wstring(L">"));
@ -1556,7 +1556,7 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vector<CInteractiveInfo
&& actions[i].m_lType == II_NoAction)
continue;
if (actions[i].m_strHyperlink.empty())
if (actions[i].m_strHyperlink.empty() && actions[i].m_lType != LT_CustomShow)
continue;
PPTX::Logic::Hyperlink hlink;

View File

@ -2401,7 +2401,11 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects)
oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide;
m_oExMedia.m_arSlides.push_back(oInfo);
wasSlide = true;
}
} /*else if (oInfo.isHTTPLink(recStr))
{
oInfo.m_type = CExFilesInfo::ExFilesType::eftHyperlink;
m_oExMedia.m_arSlides.push_back(oInfo);
}*/
}
if (pExHyperlink->m_targetAtom.IsInit())
@ -2483,6 +2487,9 @@ void CPPTUserInfo::LoadExAudio(CRecordsContainer* pExObject)
oInfo.m_bLoop = oArrayExMedia[0]->m_bLoop;
oInfo.m_fNarration = oArrayExMedia[0]->m_bNarration;
oInfo.m_fRewind = oArrayExMedia[0]->m_bRewind;
m_oExMedia.m_arAudios.push_back(oInfo);
}

View File

@ -82,32 +82,26 @@ public:
eftAudio = 2,
eftHyperlink = 3,
eftObject = 4,
eftSlide = 5/*,
eftFile = 6*/
eftSlide = 5,
eftFile = 6
};
ExFilesType m_type;
_UINT32 m_dwID;
std::wstring m_strFilePath;
ExFilesType m_type = eftNone;
_UINT32 m_dwID = 0;
std::wstring m_strFilePath = L"";
std::wstring m_name;
// clip
double m_dStartTime;
double m_dEndTime;
double m_dStartTime = 0.0;
double m_dEndTime = 1.0;
// loop
bool m_bLoop;
bool m_bLoop = false;
bool m_fNarration = false; // isNarration pptx
bool m_fRewind = false;
CExFilesInfo()
{
m_type = eftNone;
m_dwID = 0;
m_strFilePath = _T("");
m_dStartTime = 0.0;
m_dEndTime = -1.0;
m_bLoop = false;
}
CExFilesInfo(const CExFilesInfo& oSrc)
{

View File

@ -126,7 +126,7 @@ namespace PPT_FORMAT
if (value <= 0 || value > 255)
return false;
std::set<int> BLCharset = {128, 136};
std::set<int> BLCharset = {128, 136, 129};
return BLCharset.find(value) == BLCharset.end();
}

View File

@ -37,8 +37,8 @@ echo TOOLS_ROOT=${TOOLS_ROOT}
# openssl-1.1.0f has a configure bug
# openssl-1.1.1d has fix configure bug
LIB_VERSION="OpenSSL_1_1_1d"
LIB_NAME="openssl-1.1.1d"
LIB_VERSION="OpenSSL_1_1_1i"
LIB_NAME="openssl-1.1.1i"
echo "https://www.openssl.org/source/${LIB_NAME}.tar.gz"

View File

@ -619,11 +619,12 @@ namespace Aggplus
if (!bIsUseIdentity)
{
agg::trans_affine* full_trans = &m_oFullTransform.m_internal->m_agg_mtx;
double dDet = full_trans->determinant();
if (full_trans->sx < 0.01 && full_trans->sy < 0.01)
if (fabs(dDet) < 0.0001)
{
path_copy.transform_all_paths(m_oFullTransform.m_internal->m_agg_mtx);
dWidth *= sqrt(full_trans->sx * full_trans->sy);
dWidth *= sqrt(dDet);
bIsUseIdentity = true;
}

View File

@ -841,6 +841,12 @@ namespace MetaFile
m_pRenderer->put_BrushTextureMode(c_BrushTextureModeTile);
m_pRenderer->put_BrushTexturePath(pBrush->GetDibPatterPath());
}
else if (BS_PATTERN == unBrushStyle)
{
m_pRenderer->put_BrushType(c_BrushTypePattern);
m_pRenderer->put_BrushTextureMode(c_BrushTextureModeTileCenter);
m_pRenderer->put_BrushTexturePath(pBrush->GetDibPatterPath());
}
else if (BS_HATCHED == unBrushStyle)
{
m_pRenderer->put_BrushType(c_BrushTypeHatch1);

View File

@ -507,7 +507,35 @@ namespace MetaFile
}
case BrushTypeTextureFill:
{
//TODO: реализовать
// TODO: так как на данный момент нельзя регулировать повторение заливки, то будет отрисовывать изображение при самой заливки
pEmfPlusBrush->Style = BS_PATTERN;
unsigned int unBrushDataFlags, unSkip = 16;
m_oStream >> unBrushDataFlags;
m_oStream.Skip(4); // WrapMode
if (unBrushDataFlags & BrushDataTransform)
{
m_oStream.Skip(24); // TransformMatrix
unSkip += 24;
}
if (m_ulRecordSize <= 28)
break;
m_ulRecordSize -= unSkip;
CEmfPlusImage oImage;
ReadImage(oImage);
std::wstring wsImagePath;
if (SaveImage(oImage, wsImagePath))
pEmfPlusBrush->DibPatterPath = wsImagePath;
m_ulRecordSize += unSkip;
break;
}
case BrushTypePathGradient:
@ -1264,6 +1292,36 @@ namespace MetaFile
oMatrix.Dy *= m_dUnitKoef;
}
bool CEmfPlusParser::SaveImage(const CEmfPlusImage &oEmfPlusImage, std::wstring &wsPathToImage)
{
if (ImageDataTypeBitmap != oEmfPlusImage.GetImageDataType())
return false;
BYTE* pBytes;
unsigned int unImageSize;
oEmfPlusImage.GetData(pBytes, unImageSize);
NSFile::CFileBinary oFile;
std::wstring wsTempPath = oFile.GetTempPath() + L"/Temp" + std::to_wstring(unImageSize) + L".tmp";
if (!oFile.CreateFileW(wsTempPath))
return false;
if (!oFile.WriteFile(pBytes, unImageSize))
{
oFile.CloseFile();
return false;
}
oFile.CloseFile();
wsPathToImage = wsTempPath;
return true;
}
BYTE* GetClipedImage(const BYTE* pBuffer, LONG lWidth, LONG lHeight, TRect& oNewRect)
{
if (NULL == pBuffer ||

View File

@ -84,6 +84,8 @@ namespace MetaFile
void UpdateMatrix(TEmfPlusXForm& oMatrix);
bool SaveImage(const CEmfPlusImage& oImage, std::wstring& wsPathToImage);
void Read_EMRPLUS_OFFSETCLIP();
void Read_EMRPLUS_RESETCLIP();
void Read_EMFPLUS_SETCLIPPATH(unsigned short unShFlags);

View File

@ -163,7 +163,12 @@ namespace MetaFile
{
public:
CEmfPlusBrush() : CEmfPlusObject(), Style(BS_SOLID), Hatch(0), Angle(0) {};
virtual ~CEmfPlusBrush() {};
virtual ~CEmfPlusBrush()
{
if (!DibPatterPath.empty() && NSFile::CFileBinary::Exists(DibPatterPath))
NSFile::CFileBinary::Remove(DibPatterPath);
};
virtual EEmfObjectType GetType() override
{
return EMF_OBJECT_BRUSH;
@ -211,7 +216,7 @@ namespace MetaFile
std::wstring GetDibPatterPath()
{
return std::wstring();
return DibPatterPath;
}
void GetBounds(double& left, double& top, double& width, double& height)
@ -228,6 +233,7 @@ namespace MetaFile
unsigned int Hatch;
TEmfPlusRectF RectF;
unsigned int Angle;
std::wstring DibPatterPath;
};
class CEmfPlusPen: public CEmfPlusObject, public IPen

View File

@ -634,6 +634,7 @@ void CSVWriter::Impl::WriteCell(OOX::Spreadsheet::CCell *pCell)
// sCellValue = *pCell->m_oCacheValue;
//}
//else
bool bString = false;
if (pCell->m_oValue.IsInit())
{
sCellValue = pCell->m_oValue->ToString();
@ -648,42 +649,47 @@ void CSVWriter::Impl::WriteCell(OOX::Spreadsheet::CCell *pCell)
if (NULL != pSi)
{
sCellValue = pSi->ToString();
bString = true;
}
}
}
std::wstring format_code;
if (pCell->m_oStyle.IsInit() && m_oXlsx.m_pStyles)
if (!bString)
{
OOX::Spreadsheet::CXfs* xfs = m_oXlsx.m_pStyles->m_oCellXfs->m_arrItems[*pCell->m_oStyle];
if (xfs)
std::wstring format_code;
if (pCell->m_oStyle.IsInit() && m_oXlsx.m_pStyles)
{
if ((xfs->m_oApplyNumberFormat.IsInit()) && (xfs->m_oApplyNumberFormat->ToBool()) || !xfs->m_oApplyNumberFormat.IsInit())
OOX::Spreadsheet::CXfs* xfs = m_oXlsx.m_pStyles->m_oCellXfs->m_arrItems[*pCell->m_oStyle];
if (xfs)
{
if ((xfs->m_oNumFmtId.IsInit()) /*&& (xfs->m_oNumFmtId->GetValue() != 0*/)
if ((xfs->m_oApplyNumberFormat.IsInit()) && (xfs->m_oApplyNumberFormat->ToBool()) || !xfs->m_oApplyNumberFormat.IsInit())
{
int numFmt = xfs->m_oNumFmtId->GetValue();
GetDefaultFormatCode(numFmt, format_code, format_type);
if (m_oXlsx.m_pStyles->m_oNumFmts.IsInit())
if ((xfs->m_oNumFmtId.IsInit()) /*&& (xfs->m_oNumFmtId->GetValue() != 0*/)
{
std::map<unsigned int, size_t>::iterator pFind = m_oXlsx.m_pStyles->m_oNumFmts->m_mapNumFmtIndex.find(numFmt);
if (pFind != m_oXlsx.m_pStyles->m_oNumFmts->m_mapNumFmtIndex.end())
int numFmt = xfs->m_oNumFmtId->GetValue();
GetDefaultFormatCode(numFmt, format_code, format_type);
if (m_oXlsx.m_pStyles->m_oNumFmts.IsInit())
{
OOX::Spreadsheet::CNumFmt *fmt = m_oXlsx.m_pStyles->m_oNumFmts->m_arrItems[pFind->second];
if (fmt)
std::map<unsigned int, size_t>::iterator pFind = m_oXlsx.m_pStyles->m_oNumFmts->m_mapNumFmtIndex.find(numFmt);
if (pFind != m_oXlsx.m_pStyles->m_oNumFmts->m_mapNumFmtIndex.end())
{
if (fmt->m_oFormatCode.IsInit())
format_code = *fmt->m_oFormatCode;
OOX::Spreadsheet::CNumFmt *fmt = m_oXlsx.m_pStyles->m_oNumFmts->m_arrItems[pFind->second];
if (fmt)
{
if (fmt->m_oFormatCode.IsInit())
format_code = *fmt->m_oFormatCode;
}
}
}
}
}
}
}
sCellValue = ConvertValueCellToString(sCellValue, format_type, format_code);
}
sCellValue = ConvertValueCellToString(sCellValue, format_type, format_code);
}
// Escape cell value
@ -837,10 +843,9 @@ std::wstring CSVWriter::Impl::ConvertValueCellToString(const std::wstring &value
try
{
std::wstring format_code_tmp;
double dValue = XmlUtils::GetDouble(value);
int count_d = 0;
bool bFloat = false, bStart = true, bEnd = false;
bool bFloat = false, bStart = true, bEnd = false, bPercent = false;
size_t pos_skip = format_code.rfind(L"#");
if (pos_skip == std::wstring::npos) pos_skip = 0;
@ -886,7 +891,7 @@ std::wstring CSVWriter::Impl::ConvertValueCellToString(const std::wstring &value
{
if (format_code[i] == L'%')
{
dValue *= 100.;
bPercent = true;
format_code_tmp += (std::wstring(L"%") + format_code[i]);
}
else
@ -906,10 +911,26 @@ std::wstring CSVWriter::Impl::ConvertValueCellToString(const std::wstring &value
bStart = false;
}
if (!bStart && !bEnd) format_code_tmp += bFloat ? L"f" : L"d";
else
format_code_tmp += L"%";
if (!bStart && !bEnd) format_code_tmp += bFloat ? L"f" : L"ld";
double dValue = XmlUtils::GetDouble(value);
if (bPercent)
dValue *= 100.;
std::wstringstream stream;
stream << boost::wformat(format_code_tmp) % dValue;
if (bFloat)
{
stream << boost::wformat(format_code_tmp) % dValue;
}
else
{
_INT64 iValue = dValue;
stream << boost::wformat(format_code_tmp) % iValue;
}
return stream.str();
}