Commit b7bdfb8b authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Добавлены интерфейсные классы, чтобы Renderer для WMF и EMF был общим.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62301 954022d7-b5bf-4e40-9824-e11837661b57
parent 87763997
......@@ -732,4 +732,39 @@ namespace MetaFile
else // BitmapInfoHeader
ReadImageInfoHeader(pHeaderBuffer + 4, ulHeaderBufferLen - 4, pImageBuffer, ulImageBufferLen, ppDstBuffer, pulWidth, pulHeight);
}
double GetEllipseAngle(int nL, int nT, int nR, int nB, int nX, int nY)
{
double dX0 = (nL + nR) / 2.0;
double dY0 = (nT + nB) / 2.0;
//
int nQuarter = -1;
if (nX >= dX0)
{
if (nY <= dY0)
nQuarter = 0;
else
nQuarter = 3;
}
else
{
if (nY <= dY0)
nQuarter = 1;
else
nQuarter = 2;
}
double dDist = sqrt((double)(nX - dX0) * (nX - dX0) + (nY - dY0) * (nY - dY0));
double dRadAngle = asin(abs(nY - dY0) / dDist);
double dAngle = dRadAngle * 180 / 3.1415926;
switch (nQuarter)
{
case 1: dAngle = 180 - dAngle; break;
case 2: dAngle = 180 + dAngle; break;
case 3: dAngle = 360 - dAngle; break;
}
return dAngle;
}
}
......@@ -128,6 +128,16 @@ namespace MetaFile
pBuffer[ulIndex] = ReadUShort();
}
}
void ReadBytes(short* pBuffer, unsigned int ulSize)
{
size_t ulRemainSize = (pEnd - pCur) / 2;
size_t ulFinalSize = (ulRemainSize > ulSize ? ulSize : ulRemainSize);
for (size_t ulIndex = 0; ulIndex < ulFinalSize; ulIndex++)
{
pBuffer[ulIndex] = ReadShort();
}
}
void ReadBytes(unsigned int* pBuffer, unsigned int ulSize)
{
size_t ulRemainSize = (pEnd - pCur) / 4;
......@@ -849,6 +859,7 @@ namespace MetaFile
};
void ReadImage(BYTE* pHeaderBuffer, unsigned int ulHeaderBufferLen, BYTE* pImageBuffer, unsigned int ulImageBufferLen, BYTE** ppDstBuffer, unsigned int* pulWidth, unsigned int* pulHeight);
double GetEllipseAngle(int nL, int nT, int nR, int nB, int nX, int nY);
};
#endif //_METAFILE_WMF_EMF_COMMON_H
#ifndef _INTERFACE_OUTPUT_DEVICE_H
#define _INTERFACE_OUTPUT_DEVICE_H
#include "../Wmf/WmfTypes.h"
namespace MetaFile
{
class IOutputDevice
{
public:
IOutputDevice() {}
virtual ~IOutputDevice() {}
//
virtual void Begin() = 0;
virtual void End() = 0;
// pBuffer - BGRA ulWidth, ulHeight,
virtual void DrawBitmap(int nX, int nY, int nW, int nH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) = 0;
virtual void DrawText(const wchar_t* wsText, unsigned int unCharsCount, int nX, int nY, int nTextW, bool bWithOutLast) = 0;
virtual void StartPath() = 0;
virtual void MoveTo(int nX, int nY) = 0;
virtual void LineTo(int nX, int nY) = 0;
virtual void CurveTo(int nX1, int nY1, int nX2, int nY2, int nXe, int nYe) = 0;
virtual void ArcTo(int nLeft, int nTop, int nRight, int nBottom, double dStartAngle, double dSweepAngle) = 0;
virtual void ClosePath() = 0;
virtual void DrawPath(int nType = 0) = 0;
virtual void EndPath() = 0;
virtual void ResetClip() = 0;
virtual void IntersectClip(int nLeft, int nTop, int nRight, int nBottom) = 0;
virtual void StartClipPath(unsigned int unMode) = 0;
virtual void EndClipPath(unsigned int unMode) = 0;
virtual void UpdateDC() = 0;
};
}
#endif //_INTERFACE_OUTPUT_DEVICE_H
\ No newline at end of file
#ifndef _METAFILE_COMMON_METAFILE_H
#define _METAFILE_COMMON_METAFILE_H
#include "MetaFileTypes.h"
#include "MetaFileObjects.h"
#include "MetaFileClip.h"
#include "../../fontengine/FontManager.h"
namespace MetaFile
{
class CMetaFileBase
{
public:
CMetaFileBase()
CMetaFileBase(){}
virtual ~CMetaFileBase(){}
virtual double TranslateX(int nX) = 0;
virtual double TranslateY(int nY) = 0;
virtual TRect* GetDCBounds() = 0;
virtual double GetPixelHeight() = 0;
virtual double GetPixelWidth() = 0;
virtual int GetTextColor() = 0;
virtual CFont* GetFont() = 0;
virtual CBrush* GetBrush() = 0;
virtual CPen* GetPen() = 0;
virtual unsigned int GetTextAlign() = 0;
virtual unsigned int GetTextBgMode() = 0;
virtual int GetTextBgColor() = 0;
virtual unsigned int GetFillMode() = 0;
virtual TPointL GetCurPos() = 0;
virtual TEmfXForm* GetInverseTransform() = 0;
virtual TEmfXForm* GetTransform() = 0;
virtual unsigned int GetMiterLimit() = 0;
virtual unsigned int GetRop2Mode() = 0;
virtual CClip* GetClip() = 0;
CFontManager* GetFontManager()
{
return m_pFontManager;
}
virtual ~CMetaFileBase()
void SetFontManager(CFontManager* pFontManager)
{
m_pFontManager = pFontManager;
}
virtual void SetError()
void SetError()
{
m_bError = true;
}
bool CheckError()
{
return m_bError;
}
private:
CFontManager* m_pFontManager;
bool m_bError;
};
}
......
#ifndef _METAFILE_COMMON_METAFILECLIP_H
#define _METAFILE_COMMON_METAFILECLIP_H
#include "IOutputDevice.h"
namespace MetaFile
{
class CClip
{
public:
CClip(){}
virtual ~CClip(){}
virtual void ClipOnRenderer(IOutputDevice* pOutput) = 0;
};
}
#endif _METAFILE_COMMON_METAFILECLIP_H
\ No newline at end of file
......@@ -3,24 +3,43 @@
namespace MetaFile
{
typedef enum
class CFont
{
METAFILE_OBJECT_UNKNOWN = 0x00,
METAFILE_OBJECT_BRUSH = 0x01,
METAFILE_OBJECT_FONT = 0x02,
METAFILE_OBJECT_PEN = 0x03,
METAFILE_OBJECT_PALETTE = 0x04
} EMetaFileObjectType;
public:
CFont(){}
virtual ~CFont(){}
virtual int GetHeight() = 0;
virtual std::wstring GetFaceName() = 0;
virtual int GetWeight() = 0;
virtual bool IsItalic() = 0;
virtual bool IsStrikeOut() = 0;
virtual bool IsUnderline() = 0;
virtual int GetEscapement() = 0;
};
class CMetaFileObjectBase
class CBrush
{
public:
CMetaFileObjectBase(){}
virtual ~CMetaFileObjectBase(){}
virtual EMetaFileObjectType GetType()
{
return METAFILE_OBJECT_UNKNOWN;
}
CBrush(){}
virtual ~CBrush(){}
virtual int GetColor() = 0;
virtual unsigned int GetStyle() = 0;
virtual unsigned int GetHatch() = 0;
virtual unsigned int GetAlpha() = 0;
virtual std::wstring GetDibPatterPath() = 0;
};
class CPen
{
public:
CPen(){}
virtual ~CPen(){}
virtual int GetColor() = 0;
virtual unsigned int GetStyle() = 0;
virtual unsigned int GetWidth() = 0;
};
}
......
This diff is collapsed.
#ifndef _METAFILE_COMMON_METAFILETYPES_H
#define _METAFILE_COMMON_METAFILETYPES_H
namespace MetaFile
{
struct TRect
{
long lLeft;
long lTop;
long lRight;
long lBottom;
};
struct TPointL
{
int x;
int y;
};
struct TPointD
{
double x;
double y;
};
struct TColor
{
unsigned char r;
unsigned char g;
unsigned char b;
};
}
#endif //_METAFILE_COMMON_METAFILETYPES_H
\ No newline at end of file
......@@ -17,7 +17,7 @@
namespace MetaFile
{
class CEmfFile : public CMetaFileBase
class CEmfFile
{
public:
......@@ -349,42 +349,7 @@ namespace MetaFile
dDstY = (double)((double)(lSrcY - pWindow->lY) * m_pDC->GetPixelHeight()) + pViewport->lY;
return dDstY;
}
double GetEllipseAngle(int nL, int nT, int nR, int nB, int nX, int nY)
{
double dX0 = (nL + nR) / 2.0;
double dY0 = (nT + nB) / 2.0;
//
int nQuarter = -1;
if (nX >= dX0)
{
if (nY <= dY0)
nQuarter = 0;
else
nQuarter = 3;
}
else
{
if (nY <= dY0)
nQuarter = 1;
else
nQuarter = 2;
}
double dDist = /*std::*/sqrt((double)(nX - dX0) * (nX - dX0) + (nY - dY0) * (nY - dY0));
double dRadAngle = /*std::*/asin(/*std::*/abs(nY - dY0) / dDist);
double dAngle = dRadAngle * 180 / 3.1415926;
switch (nQuarter)
{
case 1: dAngle = 180 - dAngle; break;
case 2: dAngle = 180 + dAngle; break;
case 3: dAngle = 360 - dAngle; break;
}
return dAngle;
}
}
void MoveTo(TEmfPointL& oPoint)
{
......@@ -1717,7 +1682,7 @@ namespace MetaFile
LineTo(oBox.lLeft + lRoundW, oBox.lBottom);
ArcTo(oBox.lLeft, oBox.lBottom - lRoundH, oBox.lLeft + lRoundW, oBox.lBottom, 90, 90);
LineTo(oBox.lLeft, oBox.lTop + lRoundH);
ArcTo(oBox.lLeft, oBox.lTop, oBox.lLeft + lRoundW, oBox.lTop + lRoundW, 180, 90);
ArcTo(oBox.lLeft, oBox.lTop, oBox.lLeft + lRoundW, oBox.lTop + lRoundH, 180, 90);
ClosePath();
DrawPath(true, true);
}
......
......@@ -7,8 +7,6 @@
#include "EmfObjects.h"
#include "EmfClip.h"
#include "../Common/MetaFilePlayer.h"
namespace MetaFile
{
class CEmfFile;
......
......@@ -149,9 +149,12 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Common.h" />
<ClInclude Include="Common\MetaFileClip.h" />
<ClInclude Include="Common\MetaFileRenderer.h" />
<ClInclude Include="Common\IOutputDevice.h" />
<ClInclude Include="Common\MetaFile.h" />
<ClInclude Include="Common\MetaFileObjects.h" />
<ClInclude Include="Common\MetaFilePlayer.h" />
<ClInclude Include="Common\MetaFileTypes.h" />
<ClInclude Include="Emf\EmfClip.h" />
<ClInclude Include="Emf\EmfFile.h" />
<ClInclude Include="Emf\EmfObjects.h" />
......@@ -181,7 +184,6 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="Common.cpp" />
<ClCompile Include="Common\MetaFilePlayer.cpp" />
<ClCompile Include="Emf\EmfClip.cpp" />
<ClCompile Include="Emf\EmfObjects.cpp" />
<ClCompile Include="Emf\EmfPath.cpp" />
......
......@@ -105,15 +105,24 @@
<ClInclude Include="Wmf\WmfObjects.h">
<Filter>Wmf</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFilePlayer.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFileObjects.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFile.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\IOutputDevice.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFileRenderer.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFileTypes.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFileClip.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TestMain.cpp">
......@@ -146,8 +155,5 @@
<ClCompile Include="Wmf\WmfObjects.cpp">
<Filter>Wmf</Filter>
</ClCompile>
<ClCompile Include="Common\MetaFilePlayer.cpp">
<Filter>Common</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
This diff is collapsed.
......@@ -121,7 +121,7 @@ namespace MetaFile
if (ushIndex > m_vAvailableIndexes[nIterator])
{
ushIndex = m_vAvailableIndexes[nIterator];
nAvailableIndex = nIterator;
nAvailableIndex = (int)nIterator;
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment