Commit 05edf7ae authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62728 954022d7-b5bf-4e40-9824-e11837661b57
parent ad8ea254
......@@ -4,7 +4,6 @@
#include "Jp2/J2kFile.h"
#include "JBig2/source/JBig2File.h"
#include "SvmFile/Source/SvmFile.h"
bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileType)
{
......@@ -13,11 +12,6 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
Jpeg2000::CJ2kFile oJ2;
return oJ2.Open(this, strFileName, std::wstring(L""));
}
// if (22/*CXIMAGE_FORMAT_SVM*/ == nFileType)
// {
// SvmFile::CSvmFile oSvm;
// return oSvm.Open(this, strFileName);
// }
else
{
NSFile::CFileBinary oFile;
......
......@@ -27,13 +27,15 @@ namespace MetaFile
IBrush(){}
virtual ~IBrush(){}
virtual int GetColor() = 0;
virtual unsigned int GetStyle() = 0;
virtual unsigned int GetHatch() = 0;
virtual unsigned int GetAlpha() = 0;
virtual int GetColor() = 0;
virtual int GetColor2() = 0;
virtual unsigned int GetStyle() = 0;
virtual unsigned int GetStyleEx() = 0;
virtual unsigned int GetHatch() = 0;
virtual unsigned int GetAlpha() = 0;
virtual std::wstring GetDibPatterPath() = 0;
virtual void GetBounds(double& left, double& top, double& width, double& height) = 0;
};
class IPen
{
public:
......
......@@ -499,7 +499,6 @@ namespace MetaFile
oPoint.y = m_dScaleY * dY + m_dY;
return oPoint;
}
bool UpdateBrush()
{
IBrush* pBrush = m_pFile->GetBrush();
......@@ -548,6 +547,25 @@ namespace MetaFile
m_pRenderer->put_BrushAlpha1(255);
m_pRenderer->put_BrushColor1(oFgColor.ToInt());
}
else if ( BS_LINEARGRADIENT == unBrushStyle ||
BS_RADIALGRADIENT == unBrushStyle ||
BS_AXIALGRADIENT == unBrushStyle ||
BS_RECTGRADIENT == unBrushStyle ||
BS_PATHGRADIENT == unBrushStyle
)
{
m_pRenderer->put_BrushType(c_BrushTypeCenter);
m_pRenderer->put_BrushColor1(pBrush->GetColor());
m_pRenderer->put_BrushColor2(pBrush->GetColor2());
m_pRenderer->put_BrushAlpha1(pBrush->GetAlpha());
m_pRenderer->put_BrushLinearAngle(pBrush->GetStyleEx());
double l=0, t=0, w=0, h=0;
pBrush->GetBounds(l,t,w,h);
m_pRenderer->BrushBounds(l,t,w,h);
}
else //if (BS_SOLID == unBrushStyle)
{
m_pRenderer->put_BrushType(c_BrushTypeSolid);
......
......@@ -86,6 +86,12 @@ typedef unsigned char BYTE;
#define BS_PATTERN8X8 7
#define BS_DIBPATTERN8X8 8
#define BS_MONOPATTERN 9
#define BS_LINEARGRADIENT 10
#define BS_RADIALGRADIENT 11
#define BS_AXIALGRADIENT 12
#define BS_RECTGRADIENT 13
#define BS_PATHGRADIENT 14
//square? ellips ??
/* Hatch Styles */
#define HS_HORIZONTAL 0 /* ----- */
......
......@@ -797,14 +797,18 @@ namespace MetaFile
if (DIB_RGB_COLORS == unColorUsage)
{
int lCalcLen = (((nWidth * ushPlanes * ushBitCount + 31) & ~31) / 8) * abs(nHeight);
int nAvailableLen = (unBufferLen - unHeaderSize) - lCalcLen - unColorUsed * 4;
if (nAvailableLen < 0)
return;
if (0 == unColorUsed && BI_BITCOUNT_1 == ushBitCount && nAvailableLen >= 8)
unColorUsed = 2;
else if (0 == unColorUsed && BI_BITCOUNT_3 == ushBitCount && nAvailableLen >= 1024)
unColorUsed = 256;
if (unCompression == 0)
{
int nAvailableLen = (unBufferLen - unHeaderSize) - lCalcLen - unColorUsed * 4;
if (nAvailableLen < 0)
return;
if (0 == unColorUsed && BI_BITCOUNT_1 == ushBitCount && nAvailableLen >= 8)
unColorUsed = 2;
else if (0 == unColorUsed && BI_BITCOUNT_3 == ushBitCount && nAvailableLen >= 1024)
unColorUsed = 256;
}
unHeaderSize += 4 * unColorUsed; // RGBQuad
ReadImageInfoHeader(pImageBuffer + 4, unHeaderSize - 4, pImageBuffer + unHeaderSize, unBufferLen - unHeaderSize, ppDstBuffer, punWidth, punHeight);
......
......@@ -42,10 +42,18 @@ namespace MetaFile
// IBrush
int GetColor();
int GetColor2()
{
return 0;
}
unsigned int GetStyle()
{
return BrushStyle;
}
unsigned int GetStyleEx()
{
return 0;
}
unsigned int GetHatch()
{
return BrushHatch;
......@@ -58,6 +66,7 @@ namespace MetaFile
{
return DibPatternPath;
}
void GetBounds(double& left, double& top, double& width, double& height) {}
public:
unsigned int BrushStyle;
......
......@@ -12,6 +12,7 @@ namespace MetaFile
return;
}
m_pEmfFile = pFile;
m_pDC = pDC;
m_vDCStack.push_back(pDC);
......
......@@ -121,6 +121,7 @@ namespace MetaFile
{
m_oWmfFile.Close();
m_oEmfFile.Close();
m_oSvmFile.Close();
m_lType = 0;
};
......
#include "SvmClip.h"
namespace MetaFile
{
CSvmClip::CSvmClip()
{
}
CSvmClip::~CSvmClip()
{
Clear();
}
void CSvmClip::operator=(CSvmClip& oClip)
{
Clear();
for (unsigned int ulIndex = 0; ulIndex < oClip.m_vCommands.size(); ulIndex++)
{
CSvmClipCommandBase* pCommand = oClip.m_vCommands.at(ulIndex);
CSvmClipCommandBase* pNewCommand = NULL;
switch (pCommand->GetType())
{
case SVM_CLIPCOMMAND_INTERSECT:
{
CSvmClipCommandIntersect* pI = (CSvmClipCommandIntersect*)pCommand;
pNewCommand = new CSvmClipCommandIntersect(pI->m_dL, pI->m_dT, pI->m_dR, pI->m_dB);
break;
}
case SVM_CLIPCOMMAND_EXCLUDE:
{
CSvmClipCommandExclude* pE = (CSvmClipCommandExclude*)pCommand;
pNewCommand = new CSvmClipCommandExclude(pE->m_dL, pE->m_dT, pE->m_dR, pE->m_dB, pE->m_dWindowL, pE->m_dWindowT, pE->m_dWindowR, pE->m_dWindowB);
break;
}
}
if (pNewCommand)
m_vCommands.push_back(pNewCommand);
}
}
void CSvmClip::Reset()
{
Clear();
}
bool CSvmClip::Intersect(double dL, double dT, double dR, double dB)
{
CSvmClipCommandBase* pCommand = new CSvmClipCommandIntersect(dL, dT, dR, dB);
if (!pCommand)
return false;
m_vCommands.push_back(pCommand);
return true;
}
bool CSvmClip::Exclude(double dL, double dT, double dR, double dB, double dWindowL, double dWindowT, double dWindowR, double dWindowB)
{
CSvmClipCommandBase* pCommand = new CSvmClipCommandExclude(dL, dT, dR, dB, dWindowL, dWindowT, dWindowR, dWindowB);
if (!pCommand)
return false;
m_vCommands.push_back(pCommand);
return true;
}
void CSvmClip::Clear()
{
for (unsigned int ulIndex = 0; ulIndex < m_vCommands.size(); ulIndex++)
{
CSvmClipCommandBase* pCommand = m_vCommands.at(ulIndex);
delete pCommand;
}
m_vCommands.clear();
}
void CSvmClip::ClipOnRenderer(IOutputDevice* pOutput)
{
if (pOutput)
{
pOutput->ResetClip();
for (unsigned int ulIndex = 0; ulIndex < m_vCommands.size(); ulIndex++)
{
CSvmClipCommandBase* pCommand = m_vCommands.at(ulIndex);
switch (pCommand->GetType())
{
case SVM_CLIPCOMMAND_INTERSECT:
{
CSvmClipCommandIntersect* pIntersect = (CSvmClipCommandIntersect*)pCommand;
pOutput->StartClipPath(RGN_AND, ALTERNATE);
pOutput->MoveTo(pIntersect->m_dL, pIntersect->m_dT);
pOutput->LineTo(pIntersect->m_dR, pIntersect->m_dT);
pOutput->LineTo(pIntersect->m_dR, pIntersect->m_dB);
pOutput->LineTo(pIntersect->m_dL, pIntersect->m_dB);
pOutput->ClosePath();
pOutput->EndClipPath(RGN_AND);
break;
}
case SVM_CLIPCOMMAND_EXCLUDE:
{
CSvmClipCommandExclude* pExclude = (CSvmClipCommandExclude*)pCommand;
pOutput->StartClipPath(RGN_AND, ALTERNATE);
pOutput->MoveTo(pExclude->m_dL, pExclude->m_dT);
pOutput->LineTo(pExclude->m_dR, pExclude->m_dT);
pOutput->LineTo(pExclude->m_dR, pExclude->m_dB);
pOutput->LineTo(pExclude->m_dL, pExclude->m_dB);
pOutput->ClosePath();
pOutput->MoveTo(pExclude->m_dWindowL, pExclude->m_dWindowT);
pOutput->LineTo(pExclude->m_dWindowR, pExclude->m_dWindowT);
pOutput->LineTo(pExclude->m_dWindowR, pExclude->m_dWindowB);
pOutput->LineTo(pExclude->m_dWindowL, pExclude->m_dWindowB);
pOutput->ClosePath();
pOutput->EndClipPath(RGN_AND);
break;
}
}
}
}
}
}
\ No newline at end of file
#ifndef _METAFILE_SVM_SVMCLIP_H
#define _METAFILE_SVM_SVMCLIP_H
#include "../Common/MetaFileClip.h"
#include "../Common/IOutputDevice.h"
#include "../Common/MetaFileTypes.h"
#include <vector>
namespace MetaFile
{
typedef enum
{
SVM_CLIPCOMMAND_UNKNOWN = 0x00,
SVM_CLIPCOMMAND_INTERSECT = 0x01,
SVM_CLIPCOMMAND_EXCLUDE = 0x02
} ESvmClipCommandType;
class CSvmClipCommandBase
{
public:
CSvmClipCommandBase()
{
}
virtual ~CSvmClipCommandBase()
{
}
virtual ESvmClipCommandType GetType()
{
return SVM_CLIPCOMMAND_UNKNOWN;
}
};
class CSvmClipCommandIntersect : public CSvmClipCommandBase
{
public:
CSvmClipCommandIntersect(double dL, double dT, double dR, double dB)
{
m_dL = dL;
m_dT = dT;
m_dR = dR;
m_dB = dB;
}
~CSvmClipCommandIntersect()
{
}
ESvmClipCommandType GetType()
{
return SVM_CLIPCOMMAND_INTERSECT;
}
public:
double m_dL;
double m_dT;
double m_dR;
double m_dB;
};
class CSvmClipCommandExclude : public CSvmClipCommandBase
{
public:
CSvmClipCommandExclude(double dL, double dT, double dR, double dB, double dWindowL, double dWindowT, double dWindowR, double dWindowB)
{
m_dL = dL;
m_dT = dT;
m_dR = dR;
m_dB = dB;
m_dWindowL = dWindowL;
m_dWindowT = dWindowT;
m_dWindowR = dWindowR;
m_dWindowB = dWindowB;
}
~CSvmClipCommandExclude()
{
}
ESvmClipCommandType GetType()
{
return SVM_CLIPCOMMAND_EXCLUDE;
}
public:
double m_dL;
double m_dT;
double m_dR;
double m_dB;
double m_dWindowL;
double m_dWindowT;
double m_dWindowR;
double m_dWindowB;
};
class CSvmClip : public IClip
{
public:
CSvmClip();
~CSvmClip();
void operator=(CSvmClip& oClip);
void Reset();
bool Intersect(double dL, double dT, double dR, double dB);
bool Exclude(double dL, double dT, double dR, double dB, double dLbb, double dTbb, double dRbb, double dBbb);
// IClip
void ClipOnRenderer(IOutputDevice* pOutput);
private:
void Clear();
private:
std::vector<CSvmClipCommandBase*> m_vCommands;
};
}
#endif // _METAFILE_SVM_SVMCLIP_H
\ No newline at end of file
#include "SvmObjects.h"
#include "../../../common/String.h"
namespace MetaFile
{
void soakBytes(CDataStream &stream, int numBytes)
void parseString(CDataStream &stream, std::wstring &string, unsigned short version, unsigned short charset)
{
unsigned char scratch;
for (int i = 0; i < numBytes; ++i)
if (charset == 0xffff)//RTL_UNICODE
{
stream >> scratch;
unsigned int length;
stream >> length;
string = NSString::CConverter::GetUnicodeFromUTF16((unsigned short*)stream.GetCurPtr(), length);
stream.Skip(length*2);
}
}
void parseString(CDataStream &stream, std::wstring &string)
{
unsigned short length;
stream >> length;
for (unsigned int i = 0; i < length; ++i)
else
{
unsigned char ch;
stream >> ch;
string += char(ch);
unsigned short length;
stream >> length;
if (charset < 1)
{
std::string ansiString = std::string((char*)stream.GetCurPtr(),length);
string = std::wstring(ansiString.begin(), ansiString.end());
}else
string = NSString::CConverter::GetUnicodeFromSingleByteString((unsigned char*)stream.GetCurPtr(), length,
(NSString::CConverter::ESingleByteEncoding)charset);
stream.Skip(length);
}
}
......@@ -119,7 +127,7 @@ CDataStream& operator>>(CDataStream &stream, SvmHeader &header)
stream >> header.actionCount;
if (header.versionCompat.version > 1)
soakBytes(stream, 1);
stream.Skip(1);
return stream;
}
......@@ -133,6 +141,13 @@ TSvmRect::TSvmRect()
{
l = t = r = b = 0;
}
CDataStream& operator>>(CDataStream &stream, TSvmBitmapSize &s)
{
stream >> s.cx;
stream >> s.cy;
return stream;
}
CDataStream& operator>>(CDataStream &stream, TSvmPoint &p)
{
stream >> p.x;
......@@ -140,6 +155,13 @@ CDataStream& operator>>(CDataStream &stream, TSvmPoint &p)
return stream;
}
CDataStream& operator>>(CDataStream &stream, TSvmBitmapPoint &p)
{
stream >> p.x;
stream >> p.y;
return stream;
}
CSvmBrush::CSvmBrush() : Color(255, 255, 255)
{
BrushStyle = BS_SOLID;
......@@ -154,7 +176,15 @@ CSvmBrush::CSvmBrush(CSvmBrush& oBrush)
int CSvmBrush::GetColor()
{
return METAFILE_RGBA(Color.r, Color.g, Color.b);
return Color.color;//METAFILE_RGBA(Color.r, Color.g, Color.b);
}
int CSvmBrush::GetColor2()
{
return Color2.color;//METAFILE_RGBA(Color2.r, Color2.g, Color2.b);
}
unsigned int CSvmBrush::GetStyleEx()
{
return BrushStyleEx;
}
unsigned int CSvmBrush::GetStyle()
{
......@@ -166,11 +196,18 @@ unsigned int CSvmBrush::GetHatch()
}
unsigned int CSvmBrush::GetAlpha()
{
return 255;
return 0xff-Color.a;
}
void CSvmBrush::GetBounds(double& left, double& top, double& width, double& height)
{
left = BrushBounds.l;
top = BrushBounds.t;
width = BrushBounds.r - BrushBounds.l;
height = BrushBounds.b - BrushBounds.t;
}
int CSvmPen::GetColor()
{
return METAFILE_RGBA(Color.r, Color.g, Color.b);
return Color.color;//METAFILE_RGBA(Color.r, Color.g, Color.b);
}
TSvmRect::TSvmRect(CDataStream &stream)
{
......@@ -179,8 +216,8 @@ TSvmRect::TSvmRect(CDataStream &stream)
CDataStream& operator>>(CDataStream &stream, TSvmRect &p)
{
stream >> p.l;
stream >> p.r;
stream >> p.t;
stream >> p.r;
stream >> p.b;
return stream;
......@@ -201,76 +238,88 @@ CDataStream& operator>>(CDataStream &stream, TSvmPolygon &p)
}
return stream;
}
#define METAFILE_RGBA(r, g, b, a) ((unsigned int)( ( (unsigned char)(r) )| ( ( (unsigned char)(g) ) << 8 ) | ( ( (unsigned char)(b) ) << 16 ) | ( (unsigned char)(a) << 24 ) ) )
CDataStream& operator>>(CDataStream &stream, TSvmColor &c)
{
stream >> c.b;
stream >> c.g;
stream >> c.r;
stream >> c.a;
char s;
unsigned short a, r, g, b, p;
//stream >> s;
// stream >> a;
// stream >> r;
// stream >> g;
// stream >> b;
// stream >> p;
stream >> c.b;
stream >> c.g;
stream >> c.r;
stream >> c.a;
//c.a = a;
//c.r = r;
//c.b = b;
//c.g = g;
c.color = METAFILE_RGBA(c.r, c.g, c.b, c.a);
return stream;
}
CDataStream& operator>>(CDataStream &stream, CSvmBrush *b)
CDataStream& operator>>(CDataStream &stream, TSvmLineInfo &i)
{
VersionCompat version;
stream >> version;
unsigned short style;
stream >> style;
i.style = (ESvmLineStyle) style;
stream >> i.width;
if (version.version >=2)
{
//counts dot & dashes, size, distance
stream.Skip(2 + 4 + 2 + 4 + 4);
}
return stream;
}
CDataStream& operator>>(CDataStream &stream, CSvmFont *font)
{
unsigned short version;
unsigned int totalSize;
unsigned int totalSize;
// the VersionCompat struct
stream >> version;
stream >> totalSize;
// Name and style
std::wstring family;
std::wstring style;
parseString(stream, family);
parseString(stream, style);
parseString(stream, font->sFamilyName, version);
parseString(stream, font->sStyle, version);
font->sFacename = family;
// Font size
unsigned int width;
unsigned int height;
stream >> width;
stream >> height;
stream >> font->SizeWidth;
stream >> font->SizeHeight;
font->Width = width;
font->Height = height;
stream >> font->CharSet;
stream >> font->Family;
stream >> font->Pitch;
stream >> font->Weight;
stream >> font->Underline;
stream >> font->StrikeOut;
stream >> font->Italic;
stream >> font->Language;
stream >> font->Width;
stream >> font->Orientation;
stream >> font->bWordline;
stream >> font->bOutline;
stream >> font->bShadow;
stream >> font->Kerning;
char temp8;
bool tempbool;
unsigned short tempu16;
stream >> tempu16; // charset
stream >> tempu16; // family
stream >> tempu16; // pitch
stream >> tempu16; // weight
if (tempu16 > 0)
font->Weight = tempu16;
stream >> tempu16; // underline
if (tempu16 > 0)
font->Underline= 1;
stream >> tempu16; // strikeout
if (tempu16 > 0)
font->StrikeOut = 1;
stream >> tempu16; // italic
if (tempu16 > 0)
font->Italic = 1;
stream >> tempu16; // language
stream >> tempu16; // width
if (tempu16 > 0)
font->Width = tempu16; //??? todo
stream >> tempu16; // orientation
stream >> tempbool; // wordline
stream >> tempbool; // outline
stream >> tempbool; // shadow
stream >> temp8; // kerning
if (version > 1)
{
......@@ -286,9 +335,106 @@ CDataStream& operator>>(CDataStream &stream, CSvmFont *font)
{
stream >> tempu16; // overline
}
// FIXME: Read away the rest of font here to allow for higher versions than 3.
return stream;
}
#define DIBCOREHEADERSIZE 12
CDataStream& operator>>(CDataStream &stream, TSvmBitmap &b)
{
// BITMAPINFOHEADER or BITMAPCOREHEADER
stream >> b.nSize;
// BITMAPCOREHEADER
if ( b.nSize == DIBCOREHEADERSIZE )
{
short nTmp16;
stream >> nTmp16; b.nWidth = nTmp16;
stream >> nTmp16; b.nHeight = nTmp16;
stream >> b.nPlanes;
stream >> b.nBitCount;
}
else
{
// unknown Header
if( b.nSize < sizeof( TSvmBitmap ) )
{
unsigned int nUnknownSize = sizeof( b.nSize );
stream >> b.nWidth; nUnknownSize += sizeof( b.nWidth );
stream >> b.nHeight; nUnknownSize += sizeof( b.nHeight );
stream >> b.nPlanes; nUnknownSize += sizeof( b.nPlanes );
stream >> b.nBitCount; nUnknownSize += sizeof( b.nBitCount );
if( nUnknownSize < b.nSize )
{
stream >> b.nCompression;
nUnknownSize += sizeof( b.nCompression );
if( nUnknownSize < b.nSize )
{
stream >> b.nSizeImage;
nUnknownSize += sizeof( b.nSizeImage );
if( nUnknownSize < b.nSize )
{
stream >> b.nXPelsPerMeter;
nUnknownSize += sizeof( b.nXPelsPerMeter );
if( nUnknownSize < b.nSize )
{
stream >> b.nYPelsPerMeter;
nUnknownSize += sizeof( b.nYPelsPerMeter );
}
if( nUnknownSize < b.nSize )
{
stream >> b.nColsUsed;
nUnknownSize += sizeof( b.nColsUsed );
if( nUnknownSize < b.nSize )
{
stream >> b.nColsImportant;
nUnknownSize += sizeof( b.nColsImportant );
}
}
}
}
}
}
else
{
stream >> b.nWidth;
stream >> b.nHeight;
stream >> b.nPlanes;
stream >> b.nBitCount;
stream >> b.nCompression;
stream >> b.nSizeImage;
stream >> b.nXPelsPerMeter;
stream >> b.nYPelsPerMeter;
stream >> b.nColsUsed;
stream >> b.nColsImportant;
}
// Eventuell bis zur Palette ueberlesen
if ( b.nSize > sizeof( TSvmBitmap ) ) // ???
stream.Skip( b.nSize - sizeof( TSvmBitmap ) );
}
bool bTopDown;
if ( b.nHeight < 0 )
{
bTopDown = true;
b.nHeight *= -1;
}
else
bTopDown = false;
// #144105# protect a little against damaged files
if( b.nSizeImage > ( 16 * static_cast< unsigned int >( b.nWidth * b.nHeight ) ) )
b.nSizeImage = 0;
return stream;
}
}
#pragma once
//#include <qglobal.h>
#include "../Common/MetaFileTypes.h"
#include "../Common/MetaFileObjects.h"
......@@ -12,11 +11,10 @@ namespace MetaFile
{
typedef enum
{
SVM_OBJECT_UNKNOWN = 0x00,
SVM_OBJECT_BRUSH = 0x01,
SVM_OBJECT_FONT = 0x02,
SVM_OBJECT_PEN = 0x03//,
//EMF_OBJECT_PALETTE = 0x04
SVM_OBJECT_UNKNOWN = 0x00,
SVM_OBJECT_BRUSH = 0x01,
SVM_OBJECT_FONT = 0x02,
SVM_OBJECT_PEN = 0x03
} ESvmObjectType;
class CSvmObjectBase
......@@ -36,7 +34,7 @@ struct VersionCompat
VersionCompat(CDataStream &stream);
unsigned short version;
unsigned int length;//32
unsigned int length;
};
struct Fraction
......@@ -68,7 +66,16 @@ struct TSvmSize
unsigned int cx;
unsigned int cy;
};
struct TSvmBitmapSize
{
unsigned short cx;
unsigned short cy;
};
struct TSvmBitmapPoint
{
unsigned short x;
unsigned short y;
};
enum ESvmMapUnit
{
MAP_100TH_MM, MAP_10TH_MM, MAP_MM, MAP_CM,
......@@ -77,6 +84,25 @@ MAP_100TH_MM, MAP_10TH_MM, MAP_MM, MAP_CM,
MAP_RELATIVE, /*MAP_REALAPPFONT,*/ MAP_LASTENUMDUMMY
};
enum ESvnRasterOp
{
ROP_OVERPAINT, ROP_XOR, ROP_0, ROP_1, ROP_INVERT
};
enum ESvmGradientStyle
{
GRADIENT_LINEAR = 0,
GRADIENT_AXIAL = 1,
GRADIENT_RADIAL = 2,
GRADIENT_ELLIPTICAL = 3,
GRADIENT_SQUARE = 4,
GRADIENT_RECT = 5
};
enum ESvmLineStyle
{
LINE_NONE = 0,
LINE_SOLID = 1,
LINE_DASH = 2
};
struct MapMode
{
MapMode();
......@@ -121,12 +147,15 @@ struct TSvmPolygon
std::vector<TSvmPoint> points;
unsigned short count;
};
struct TSvmColor
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a; //Reserved Must be 0x00
unsigned char a;
unsigned int color;
TSvmColor()
{
......@@ -146,14 +175,21 @@ struct TSvmColor
}
void Copy(const TSvmColor& oOther)
{
r = oOther.r; g = oOther.g; b = oOther.b; a = oOther.a;
r = oOther.r; g = oOther.g; b = oOther.b; a = oOther.a; color = oOther.color;
}
TSvmColor& operator=(const TSvmColor& oColor)
{
r = oColor.r; g = oColor.g; b = oColor.b; a = oColor.a;
r = oColor.r; g = oColor.g; b = oColor.b; a = oColor.a; color = oColor.color;
return *this;
}
};
struct TSvmLineInfo
{
ESvmLineStyle style;
int width;
};
struct TSvmWindow
{
int lX;
......@@ -190,18 +226,38 @@ public:
}
// IBrush
int GetColor();
int GetColor2();
unsigned int GetStyleEx();
unsigned int GetStyle();
unsigned int GetHatch();
unsigned int GetAlpha();
std::wstring GetDibPatterPath(){ return L""; }
void GetBounds(double& left, double& top, double& width, double& height);
public:
unsigned short BrushStyleEx; //angle, or ....
unsigned short BrushStyle;
TSvmColor Color;
TSvmColor Color2;
unsigned short BrushHatch;
unsigned short BrushStyle;
TSvmColor Color;
unsigned short BrushHatch;
TSvmRect BrushBounds;
};
struct TSvmBitmap
{
unsigned int nSize;
unsigned int nWidth;
unsigned int nHeight;
unsigned short nPlanes;
unsigned short nBitCount;
unsigned int nCompression;
unsigned int nSizeImage;
int nXPelsPerMeter;
int nYPelsPerMeter;
unsigned int nColsUsed;
unsigned int nColsImportant;
};
class CSvmFont : public CSvmObjectBase, public IFont
{
public:
......@@ -221,11 +277,11 @@ public:
// IFont
int GetHeight()
{
return (int)Height;
return (int)SizeHeight;
}
std::wstring GetFaceName()
{
return sFacename;
return sFamilyName;
}
int GetWeight()
{
......@@ -245,7 +301,7 @@ public:
}
int GetEscapement()
{
return (int)Escapement;
return 0;//(int)Escapement;
}
int GetCharSet()
{
......@@ -254,20 +310,27 @@ public:
public:
short Height;
short Width;
short Escapement;
short Orientation;
short Weight;
unsigned char Italic;
unsigned char Underline;
unsigned char StrikeOut;
unsigned char CharSet;
unsigned char OutPrecision;
unsigned char ClipPrecision;
unsigned char Quality;
unsigned char PitchAndFamily;
std::wstring sFacename;
unsigned int SizeHeight;
unsigned int SizeWidth;
unsigned short Width;
unsigned short Orientation;
unsigned short Weight;
unsigned short Italic;
unsigned short Underline;
unsigned short StrikeOut;
unsigned short CharSet;
unsigned short Language;
unsigned short Pitch;
unsigned short Family;
bool bWordline;
bool bOutline;
bool bShadow;
char Kerning;
std::wstring sFamilyName;
std::wstring sStyle;
// 32
};
......@@ -276,7 +339,6 @@ class CSvmPen : public CSvmObjectBase, public IPen
public:
CSvmPen()
{
Width.x = 1;
}
~CSvmPen()
{
......@@ -295,28 +357,30 @@ public:
}
unsigned int GetWidth()
{
return (unsigned int)Width.x;
return (unsigned int)Width;
}
public:
unsigned short PenStyle;
TSvmPoint Width;
TSvmColor Color;
unsigned short PenStyle;
int Width;
TSvmColor Color;
};
void soakBytes(CDataStream &stream, int numBytes);
void parseString(CDataStream &stream, std::wstring &string);
void parseString(CDataStream &stream, std::wstring &string, unsigned short version = 0, unsigned short charset = 0);
CDataStream& operator>>(CDataStream &stream, VersionCompat &compat);
CDataStream& operator>>(CDataStream &stream, Fraction &fract);
CDataStream& operator>>(CDataStream &stream, MapMode &mm);
CDataStream& operator>>(CDataStream &stream, SvmHeader &header);
CDataStream& operator>>(CDataStream &stream, TSvmBitmapSize &s);
CDataStream& operator>>(CDataStream &stream, TSvmBitmapPoint &s);
CDataStream& operator>>(CDataStream &stream, TSvmPoint &p);
CDataStream& operator>>(CDataStream &stream, TSvmRect &p);
CDataStream& operator>>(CDataStream &stream, TSvmPolygon &p);
CDataStream& operator>>(CDataStream &stream, TSvmColor &c);
CDataStream& operator>>(CDataStream &stream, CSvmBrush *b);
CDataStream& operator>>(CDataStream &stream, TSvmBitmap &b);
CDataStream& operator>>(CDataStream &stream, CSvmFont *f);
CDataStream& operator>>(CDataStream &stream, TSvmLineInfo &l);
}
......
......@@ -2,35 +2,53 @@
#include "SvmPlayer.h"
#include "SvmFile.h"
// MetaFile
#include "SvmEnums.h"
#include "SvmObjects.h"
#define DEBUG_SVMPAINT 0
// Flags for Push
#define PUSH_LINECOLOR ((USHORT)0x0001)
#define PUSH_FILLCOLOR ((USHORT)0x0002)
#define PUSH_FONT ((USHORT)0x0004)
#define PUSH_TEXTCOLOR ((USHORT)0x0008)
#define PUSH_MAPMODE ((USHORT)0x0010)
#define PUSH_CLIPREGION ((USHORT)0x0020)
#define PUSH_RASTEROP ((USHORT)0x0040)
#define PUSH_TEXTFILLCOLOR ((USHORT)0x0080)
#define PUSH_TEXTALIGN ((USHORT)0x0100)
#define PUSH_REFPOINT ((USHORT)0x0200)
#define PUSH_TEXTLINECOLOR ((USHORT)0x0400)
#define PUSH_TEXTLAYOUTMODE ((USHORT)0x0800)
#define PUSH_TEXTLANGUAGE ((USHORT)0x1000)
#define PUSH_OVERLINECOLOR ((USHORT)0x2000)
#define PUSH_ALLTEXT (PUSH_TEXTCOLOR | PUSH_TEXTFILLCOLOR | PUSH_TEXTLINECOLOR | PUSH_OVERLINECOLOR | PUSH_TEXTALIGN | PUSH_TEXTLAYOUTMODE | PUSH_TEXTLANGUAGE)
#define PUSH_ALLFONT (PUSH_ALLTEXT | PUSH_FONT)
#define PUSH_ALL ((USHORT)0xFFFF)
/**
Namespace for StarView Metafile (SVM) classes
*/
namespace MetaFile
{
CSvmPlayer::CSvmPlayer(CSvmFile* pFile)
{
CSvmDC* pDC = new CSvmDC();
if (!pDC)
{
pFile->SetError();
return;
}
CSvmPlayer::CSvmPlayer(CSvmFile* pFile)
{
CSvmDC* pDC = new CSvmDC();
if (!pDC)
{
pFile->SetError();
return;
}
m_pDC = pDC;
m_vDCStack.push_back(pDC);
m_ushIndex = 0;
m_pFile = pFile;
m_pDC = pDC;
m_vDCStack.push_back(pDC);
InitStockObjects();
}
m_nFlags = 0;
m_eRasterOp = ROP_OVERPAINT;
m_ushIndex = 0;
InitStockObjects();
}
CSvmPlayer::~CSvmPlayer()
{
......@@ -68,13 +86,15 @@ void CSvmPlayer::Clear()
CSvmDC* pDC = new CSvmDC();
if (!pDC)
{
m_pSvmFile->SetError();
m_pFile->SetError();
return;
}
m_nFlags = 0;
m_eRasterOp = ROP_OVERPAINT;
m_ushIndex = 0;
m_pDC = pDC;
m_vDCStack.push_back(pDC);
m_ushIndex = 0;
m_vAvailableIndexes.clear();
InitStockObjects();
......@@ -89,24 +109,37 @@ void CSvmPlayer::SelectObject(unsigned short ushIndex)
switch (pObject->GetType())
{
case SVM_OBJECT_BRUSH: m_pDC->SetBrush((CSvmBrush*)pObject); break;
case SVM_OBJECT_FONT: m_pDC->SetFont((CSvmFont*)pObject); break;
case SVM_OBJECT_PEN: m_pDC->SetPen((CSvmPen*)pObject); break;
case SVM_OBJECT_BRUSH: m_pDC->SetBrush((CSvmBrush*)pObject); break;
case SVM_OBJECT_FONT: m_pDC->SetFont((CSvmFont*)pObject); break;
case SVM_OBJECT_PEN: m_pDC->SetPen((CSvmPen*)pObject); break;
}
}
}
CSvmObjectBase *CSvmPlayer::GetLastObject (ESvmObjectType type)
{
CSvmObjectMap::iterator oIterator = m_mObjects.end();
oIterator--;
for (; oIterator != m_mObjects.begin(); oIterator--)
{
if (oIterator->second->GetType() == type)
{
return oIterator->second;
}
}
return NULL;
}
CSvmDC* CSvmPlayer::SaveDC()
{
if (!m_pDC)
{
m_pSvmFile->SetError();
m_pFile->SetError();
return NULL;
}
CSvmDC* pNewDC = m_pDC->Copy();
if (!pNewDC)
{
m_pSvmFile->SetError();
m_pFile->SetError();
return NULL;
}
......@@ -118,7 +151,7 @@ CSvmDC* CSvmPlayer::RestoreDC()
{
if (m_vDCStack.size() <= 1)
{
m_pSvmFile->SetError();
m_pFile->SetError();
return m_pDC;
}
......@@ -170,11 +203,157 @@ void CSvmPlayer::RegisterObject(CSvmObjectBase* pObject)
SelectObject(m_ushIndex-1);
}
void CSvmPlayer::SetRasterOp(int op)
{
m_eRasterOp = (ESvnRasterOp)op;
}
void CSvmPlayer::InitStockObjects()
{
InitStockBrush(false, 79, 129, 189); //default OnlyOffice
InitStockPen(false, 0x00, 0x00, 0x00);
}
void CSvmPlayer::Pop()
{
//if ( m_nFlags & PUSH_LINECOLOR )
//{
// if ( m_nFlags->mpLineColor )
// SetLineColor( *m_nFlags->mpLineColor );
// else
// SetLineColor();
//}
//if ( m_nFlags & PUSH_FILLCOLOR )
//{
// if ( m_nFlags->mpFillColor )
// SetFillColor( *m_nFlags->mpFillColor );
// else
// SetFillColor();
//}
//if ( m_nFlags & PUSH_FONT )
// SetFont( *pData->mpFont );
//if ( m_nFlags & PUSH_TEXTCOLOR )
// SetTextColor( *pData->mpTextColor );
//if ( m_nFlags & PUSH_TEXTFILLCOLOR )
//{
// if ( pData->mpTextFillColor )
// SetTextFillColor( *pData->mpTextFillColor );
// else
// SetTextFillColor();
//}
//if ( m_nFlags & PUSH_TEXTLINECOLOR )
//{
// if ( pData->mpTextLineColor )
// SetTextLineColor( *pData->mpTextLineColor );
// else
// SetTextLineColor();
//}
//if ( m_nFlags & PUSH_OVERLINECOLOR )
//{
// if ( pData->mpOverlineColor )
// SetOverlineColor( *pData->mpOverlineColor );
// else
// SetOverlineColor();
//}
//if ( m_nFlags & PUSH_TEXTALIGN )
// SetTextAlign( pData->meTextAlign );
//if( m_nFlags & PUSH_TEXTLAYOUTMODE )
// SetLayoutMode( pData->mnTextLayoutMode );
//if( m_nFlags & PUSH_TEXTLANGUAGE )
// SetDigitLanguage( pData->meTextLanguage );
//if ( m_nFlags & PUSH_RASTEROP )
// SetRasterOp( m_eRasterOp );
//if ( m_nFlags & PUSH_MAPMODE )
//{
// if ( pData->mpMapMode )
// SetMapMode( *pData->mpMapMode );
// else
// SetMapMode();
//}
if ( m_nFlags & PUSH_CLIPREGION )
{
GetDC()->GetClip()->ClipOnRenderer(m_pFile->m_pOutput);
GetDC()->GetClip()->Reset();
}
m_nFlags = 0;
//if ( m_nFlags & PUSH_REFPOINT )
//{
// if ( pData->mpRefPoint )
// SetRefPoint( *pData->mpRefPoint );
// else
// SetRefPoint();
//}
}
void CSvmPlayer::Push(int nFlags) //
{
m_nFlags = nFlags;
//if ( nFlags & PUSH_LINECOLOR )
//{
// if ( mbLineColor )
// pData->mpLineColor = new Color( maLineColor );
// else
// pData->mpLineColor = NULL;
//}
//if ( nFlags & PUSH_FILLCOLOR )
//{
// if ( mbFillColor )
// pData->mpFillColor = new Color( maFillColor );
// else
// pData->mpFillColor = NULL;
//}
//if ( nFlags & PUSH_FONT )
// pData->mpFont = new Font( maFont );
//if ( nFlags & PUSH_TEXTCOLOR )
// pData->mpTextColor = new Color( GetTextColor() );
//if ( nFlags & PUSH_TEXTFILLCOLOR )
//{
// if ( IsTextFillColor() )
// pData->mpTextFillColor = new Color( GetTextFillColor() );
// else
// pData->mpTextFillColor = NULL;
//}
//if ( nFlags & PUSH_TEXTLINECOLOR )
//{
// if ( IsTextLineColor() )
// pData->mpTextLineColor = new Color( GetTextLineColor() );
// else
// pData->mpTextLineColor = NULL;
//}
//if ( nFlags & PUSH_OVERLINECOLOR )
//{
// if ( IsOverlineColor() )
// pData->mpOverlineColor = new Color( GetOverlineColor() );
// else
// pData->mpOverlineColor = NULL;
//}
//if ( nFlags & PUSH_TEXTALIGN )
// pData->meTextAlign = GetTextAlign();
//if( nFlags & PUSH_TEXTLAYOUTMODE )
// pData->mnTextLayoutMode = GetLayoutMode();
//if( nFlags & PUSH_TEXTLANGUAGE )
// pData->meTextLanguage = GetDigitLanguage();
//if ( nFlags & PUSH_RASTEROP )
// pData->meRasterOp = GetRasterOp();
//if ( nFlags & PUSH_MAPMODE )
//{
// if ( mbMap )
// pData->mpMapMode = new MapMode( maMapMode );
// else
// pData->mpMapMode = NULL;
//}
if ( nFlags & PUSH_CLIPREGION )
{
GetDC()->GetClip()->Reset();
//new region
}
//if ( nFlags & PUSH_REFPOINT )
//{
// if ( mbRefPoint )
// pData->mpRefPoint = new Point( maRefPoint );
// else
// pData->mpRefPoint = NULL;
//}
}
void CSvmPlayer::InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b)
{
CSvmBrush* pBrush = new CSvmBrush();
......@@ -261,7 +440,7 @@ CSvmDC* CSvmDC::Copy()
pNewDC->m_oWindow.Copy(&m_oWindow);
pNewDC->m_oViewport.Copy(&m_oViewport);
pNewDC->m_oCurPos = m_oCurPos;
//pNewDC->m_oClip = m_oClip;
pNewDC->m_oClip = m_oClip;
pNewDC->m_unArcDirection = m_unArcDirection;
return pNewDC;
......@@ -426,6 +605,10 @@ CSvmPen* CSvmDC::GetPen()
{
return m_pPen;
}
CSvmClip* CSvmDC::GetClip()
{
return &m_oClip;
}
void CSvmDC::SetStretchMode(unsigned int& oMode)
{
m_ulStretchMode = oMode;
......@@ -543,10 +726,6 @@ TSvmPoint & CSvmDC::GetCurPos()
{
return m_oCurPos;
}
//CSvmClip* CSvmDC::GetClip()
//{
// return &m_oClip;
//}
//void CSvmDC::ClipToPath(CSvmPath* pPath, unsigned int unMode)
//{
// m_oClip.SetPath(pPath, unMode);
......
......@@ -2,6 +2,7 @@
#include "SvmEnums.h"
#include "SvmObjects.h"
#include "SvmClip.h"
#include <map>
#include <vector>
......@@ -17,30 +18,41 @@ public:
CSvmPlayer(CSvmFile *file);
virtual ~CSvmPlayer();
void Clear();
CSvmDC* SaveDC();
CSvmDC* RestoreDC();
CSvmDC* GetDC();
void RegisterObject(CSvmObjectBase* pObject);
void SelectObject(unsigned short ushIndex);
void SelectPalette(unsigned short ushIndex);
void DeleteObject(unsigned short ushIndex);
void RegisterObject (CSvmObjectBase* pObject);
void SelectObject (unsigned short ushIndex);
void DeleteObject (unsigned short ushIndex);
CSvmObjectBase *GetLastObject (ESvmObjectType type);
void Pop();
void Push(int Flags);
void SetRasterOp(int op);
private:
void InitStockObjects();
void InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b);
void InitStockPen(bool bNull, unsigned char r, unsigned char g, unsigned char b);
void InitStockBrush (bool bNull, unsigned char r, unsigned char g, unsigned char b);
void InitStockPen (bool bNull, unsigned char r, unsigned char g, unsigned char b);
typedef std::map < unsigned int, CSvmObjectBase* > CSvmObjectMap;
CSvmDC* m_pDC;
std::vector<CSvmDC*> m_vDCStack;
CSvmFile* m_pSvmFile;
CSvmObjectMap m_mObjects;
CSvmDC* m_pDC;
std::vector<CSvmDC*> m_vDCStack;
CSvmFile* m_pFile;
CSvmObjectMap m_mObjects;
int m_nFlags;
ESvnRasterOp m_eRasterOp;
typedef std::map <unsigned int, CWmfObjectBase*> CWmfObjectMap;
unsigned short m_ushIndex;
std::vector<unsigned short> m_vAvailableIndexes;
};
class CSvmDC
......@@ -95,7 +107,7 @@ public:
void SetCurPos(TSvmPoint& oPoint);
void SetCurPos(int lX, int lY);
TSvmPoint& GetCurPos();
//CSvmClip* GetClip();
CSvmClip* GetClip();
//void ClipToPath(CSvmPath* pPath, unsigned int unMode);
void SetArcDirection(unsigned int unDirection);
unsigned int GetArcDirection();
......@@ -127,8 +139,8 @@ private:
double m_dPixelHeight;
TSvmWindow m_oWindow;
TSvmWindow m_oViewport;
TSvmPoint m_oCurPos;
// CSvmClip m_oClip;
TSvmPoint m_oCurPos;
CSvmClip m_oClip;
unsigned int m_unArcDirection;
};
......
......@@ -44,10 +44,19 @@ namespace MetaFile
// IBrush
int GetColor();
int GetColor2()
{
return 0;
}
unsigned int GetStyle();
unsigned int GetStyleEx()
{
return 0;
}
unsigned int GetHatch();
unsigned int GetAlpha();
std::wstring GetDibPatterPath();
void GetBounds(double& left, double& top, double& width, double& height) {}
public:
......
......@@ -785,6 +785,38 @@
>
</File>
</Filter>
<Filter
Name="StarView"
>
<File
RelativePath=".\Metafile\StarView\SvmEnums.h"
>
</File>
<File
RelativePath=".\Metafile\StarView\SvmFile.cpp"
>
</File>
<File
RelativePath=".\Metafile\StarView\SvmFile.h"
>
</File>
<File
RelativePath=".\Metafile\StarView\SvmObjects.cpp"
>
</File>
<File
RelativePath=".\Metafile\StarView\SvmObjects.h"
>
</File>
<File
RelativePath=".\Metafile\StarView\SvmPlayer.cpp"
>
</File>
<File
RelativePath=".\Metafile\StarView\SvmPlayer.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Jp2"
......
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