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 ...@@ -732,4 +732,39 @@ namespace MetaFile
else // BitmapInfoHeader else // BitmapInfoHeader
ReadImageInfoHeader(pHeaderBuffer + 4, ulHeaderBufferLen - 4, pImageBuffer, ulImageBufferLen, ppDstBuffer, pulWidth, pulHeight); 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 ...@@ -128,6 +128,16 @@ namespace MetaFile
pBuffer[ulIndex] = ReadUShort(); 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) void ReadBytes(unsigned int* pBuffer, unsigned int ulSize)
{ {
size_t ulRemainSize = (pEnd - pCur) / 4; size_t ulRemainSize = (pEnd - pCur) / 4;
...@@ -849,6 +859,7 @@ namespace MetaFile ...@@ -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); 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 #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 #ifndef _METAFILE_COMMON_METAFILE_H
#define _METAFILE_COMMON_METAFILE_H #define _METAFILE_COMMON_METAFILE_H
#include "MetaFileTypes.h"
#include "MetaFileObjects.h"
#include "MetaFileClip.h"
#include "../../fontengine/FontManager.h"
namespace MetaFile namespace MetaFile
{ {
class CMetaFileBase class CMetaFileBase
{ {
public: 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;
} }
void SetError()
virtual 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 @@ ...@@ -3,24 +3,43 @@
namespace MetaFile namespace MetaFile
{ {
typedef enum class CFont
{ {
METAFILE_OBJECT_UNKNOWN = 0x00, public:
METAFILE_OBJECT_BRUSH = 0x01, CFont(){}
METAFILE_OBJECT_FONT = 0x02, virtual ~CFont(){}
METAFILE_OBJECT_PEN = 0x03,
METAFILE_OBJECT_PALETTE = 0x04 virtual int GetHeight() = 0;
} EMetaFileObjectType; 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: public:
CMetaFileObjectBase(){} CBrush(){}
virtual ~CMetaFileObjectBase(){} virtual ~CBrush(){}
virtual EMetaFileObjectType GetType()
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
{ {
return METAFILE_OBJECT_UNKNOWN; 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 @@ ...@@ -17,7 +17,7 @@
namespace MetaFile namespace MetaFile
{ {
class CEmfFile : public CMetaFileBase class CEmfFile
{ {
public: public:
...@@ -350,41 +350,6 @@ namespace MetaFile ...@@ -350,41 +350,6 @@ namespace MetaFile
return dDstY; 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) void MoveTo(TEmfPointL& oPoint)
{ {
...@@ -1717,7 +1682,7 @@ namespace MetaFile ...@@ -1717,7 +1682,7 @@ namespace MetaFile
LineTo(oBox.lLeft + lRoundW, oBox.lBottom); LineTo(oBox.lLeft + lRoundW, oBox.lBottom);
ArcTo(oBox.lLeft, oBox.lBottom - lRoundH, oBox.lLeft + lRoundW, oBox.lBottom, 90, 90); ArcTo(oBox.lLeft, oBox.lBottom - lRoundH, oBox.lLeft + lRoundW, oBox.lBottom, 90, 90);
LineTo(oBox.lLeft, oBox.lTop + lRoundH); 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(); ClosePath();
DrawPath(true, true); DrawPath(true, true);
} }
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "EmfObjects.h" #include "EmfObjects.h"
#include "EmfClip.h" #include "EmfClip.h"
#include "../Common/MetaFilePlayer.h"
namespace MetaFile namespace MetaFile
{ {
class CEmfFile; class CEmfFile;
......
...@@ -149,9 +149,12 @@ ...@@ -149,9 +149,12 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Common.h" /> <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\MetaFile.h" />
<ClInclude Include="Common\MetaFileObjects.h" /> <ClInclude Include="Common\MetaFileObjects.h" />
<ClInclude Include="Common\MetaFilePlayer.h" /> <ClInclude Include="Common\MetaFileTypes.h" />
<ClInclude Include="Emf\EmfClip.h" /> <ClInclude Include="Emf\EmfClip.h" />
<ClInclude Include="Emf\EmfFile.h" /> <ClInclude Include="Emf\EmfFile.h" />
<ClInclude Include="Emf\EmfObjects.h" /> <ClInclude Include="Emf\EmfObjects.h" />
...@@ -181,7 +184,6 @@ ...@@ -181,7 +184,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Common.cpp" /> <ClCompile Include="Common.cpp" />
<ClCompile Include="Common\MetaFilePlayer.cpp" />
<ClCompile Include="Emf\EmfClip.cpp" /> <ClCompile Include="Emf\EmfClip.cpp" />
<ClCompile Include="Emf\EmfObjects.cpp" /> <ClCompile Include="Emf\EmfObjects.cpp" />
<ClCompile Include="Emf\EmfPath.cpp" /> <ClCompile Include="Emf\EmfPath.cpp" />
......
...@@ -105,15 +105,24 @@ ...@@ -105,15 +105,24 @@
<ClInclude Include="Wmf\WmfObjects.h"> <ClInclude Include="Wmf\WmfObjects.h">
<Filter>Wmf</Filter> <Filter>Wmf</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Common\MetaFilePlayer.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\MetaFileObjects.h"> <ClInclude Include="Common\MetaFileObjects.h">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Common\MetaFile.h"> <ClInclude Include="Common\MetaFile.h">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClInclude> </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>
<ItemGroup> <ItemGroup>
<ClCompile Include="TestMain.cpp"> <ClCompile Include="TestMain.cpp">
...@@ -146,8 +155,5 @@ ...@@ -146,8 +155,5 @@
<ClCompile Include="Wmf\WmfObjects.cpp"> <ClCompile Include="Wmf\WmfObjects.cpp">
<Filter>Wmf</Filter> <Filter>Wmf</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Common\MetaFilePlayer.cpp">
<Filter>Common</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
This diff is collapsed.
...@@ -121,7 +121,7 @@ namespace MetaFile ...@@ -121,7 +121,7 @@ namespace MetaFile
if (ushIndex > m_vAvailableIndexes[nIterator]) if (ushIndex > m_vAvailableIndexes[nIterator])
{ {
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