diff --git a/DesktopEditor/raster/Metafile/Emf/EmfClip.cpp b/DesktopEditor/raster/Metafile/Emf/EmfClip.cpp new file mode 100644 index 0000000000..c4bc0aa57e --- /dev/null +++ b/DesktopEditor/raster/Metafile/Emf/EmfClip.cpp @@ -0,0 +1,77 @@ +#include "EmfClip.h" +#include "EmfOutputDevice.h" + +namespace MetaFile +{ + CEmfClip::CEmfClip() + { + + } + CEmfClip::~CEmfClip() + { + Clear(); + } + void CEmfClip::operator=(CEmfClip& oClip) + { + Clear(); + for (unsigned int ulIndex = 0; ulIndex < oClip.m_vCommands.size(); ulIndex++) + { + CEmfClipCommandBase* pCommand = oClip.m_vCommands.at(ulIndex); + CEmfClipCommandBase* pNewCommand = NULL; + switch (pCommand->GetType()) + { + case EMF_CLIPCOMMAND_INTERSECT: + { + pNewCommand = new CEmfClipCommandIntersect(((CEmfClipCommandIntersect*)pCommand)->m_oRect); + break; + } + } + + if (pNewCommand) + m_vCommands.push_back(pNewCommand); + } + } + void CEmfClip::Reset() + { + Clear(); + } + bool CEmfClip::Intersect(TEmfRectL& oRect) + { + CEmfClipCommandBase* pCommand = new CEmfClipCommandIntersect(oRect); + if (!pCommand) + return false; + + m_vCommands.push_back(pCommand); + return true; + } + void CEmfClip::ClipOnRenderer(CEmfOutputDevice* pOutput) + { + if (pOutput) + return; + + pOutput->ResetClip(); + for (unsigned int ulIndex = 0; ulIndex < m_vCommands.size(); ulIndex++) + { + CEmfClipCommandBase* pCommand = m_vCommands.at(ulIndex); + switch (pCommand->GetType()) + { + case EMF_CLIPCOMMAND_INTERSECT: + { + CEmfClipCommandIntersect* pIntersect = (CEmfClipCommandIntersect*)pCommand; + pOutput->IntersectClip(pIntersect->m_oRect.lLeft, pIntersect->m_oRect.lTop, pIntersect->m_oRect.lRight, pIntersect->m_oRect.lBottom); + break; + } + } + } + + } + void CEmfClip::Clear() + { + for (unsigned int ulIndex = 0; ulIndex < m_vCommands.size(); ulIndex++) + { + CEmfClipCommandBase* pCommand = m_vCommands.at(ulIndex); + delete pCommand; + } + m_vCommands.clear(); + } +} \ No newline at end of file diff --git a/DesktopEditor/raster/Metafile/Emf/EmfClip.h b/DesktopEditor/raster/Metafile/Emf/EmfClip.h new file mode 100644 index 0000000000..43cad77e1f --- /dev/null +++ b/DesktopEditor/raster/Metafile/Emf/EmfClip.h @@ -0,0 +1,91 @@ +#ifndef _EMF_CLIP_H +#define _EMF_CLIP_H + +#include +#include "EmfTypes.h" +#include "EmfPath.h" + +namespace MetaFile +{ + class CEmfOutputDevice; + + typedef enum + { + EMF_CLIPCOMMAND_UNKNOWN = 0x00, + EMF_CLIPCOMMAND_INTERSECT = 0x01, + EMF_CLIPCOMMAND_SETPATH = 0x02 + } EEmfClipCommandType; + + class CEmfClipCommandBase + { + public: + CEmfClipCommandBase() + { + } + virtual ~CEmfClipCommandBase() + { + } + virtual EEmfClipCommandType GetType() + { + return EMF_CLIPCOMMAND_UNKNOWN; + } + }; + class CEmfClipCommandIntersect : public CEmfClipCommandBase + { + public: + CEmfClipCommandIntersect(TEmfRectL& oRect) : m_oRect(oRect) + { + } + ~CEmfClipCommandIntersect() + { + } + EEmfClipCommandType GetType() + { + return EMF_CLIPCOMMAND_INTERSECT; + } + + public: + TEmfRectL m_oRect; + }; + class CEmfClipCommandPath : public CEmfClipCommandBase + { + public: + CEmfClipCommandPath(CEmfPath* pPath, unsigned int unMode) : m_oPath(pPath), m_unMode(unMode) + { + } + ~CEmfClipCommandPath() + { + } + EEmfClipCommandType GetType() + { + return EMF_CLIPCOMMAND_SETPATH; + } + + public: + + CEmfPath m_oPath; + unsigned int m_unMode; + }; + + class CEmfClip + { + public: + CEmfClip(); + ~CEmfClip(); + + void operator=(CEmfClip& oClip); + void Reset(); + bool Intersect(TEmfRectL& oRect); + void ClipOnRenderer(CEmfOutputDevice* pOutput); + + private: + + void Clear(); + + private: + + std::vector m_vCommands; + }; +} + +#endif // _EMF_CLIP_H \ No newline at end of file diff --git a/DesktopEditor/raster/Metafile/Emf/EmfPath.cpp b/DesktopEditor/raster/Metafile/Emf/EmfPath.cpp index 40e08ebde2..f2860ee717 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfPath.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfPath.cpp @@ -6,6 +6,13 @@ namespace MetaFile CEmfPath::CEmfPath() { } + CEmfPath::CEmfPath(CEmfPath* pPath) + { + if (pPath) + { + + } + } CEmfPath::~CEmfPath() { Clear(); diff --git a/DesktopEditor/raster/Metafile/Emf/EmfPath.h b/DesktopEditor/raster/Metafile/Emf/EmfPath.h index e5862a452c..fda01320f7 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfPath.h +++ b/DesktopEditor/raster/Metafile/Emf/EmfPath.h @@ -190,6 +190,7 @@ namespace MetaFile public: CEmfPath(); + CEmfPath(CEmfPath* pPath); ~CEmfPath(); bool MoveTo(TEmfPointS& oPoint);