Commit ad823ccf authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52441 954022d7-b5bf-4e40-9824-e11837661b57
parent 3c152121
...@@ -5,25 +5,8 @@ ASCHTMLRenderer/Resources/imgtrackbar/b_bg_on.gif svn_mime_002dtype=application% ...@@ -5,25 +5,8 @@ ASCHTMLRenderer/Resources/imgtrackbar/b_bg_on.gif svn_mime_002dtype=application%
ASCHTMLRenderer/Resources/imgtrackbar/b_l.gif svn_mime_002dtype=application%2Foctet-stream ASCHTMLRenderer/Resources/imgtrackbar/b_l.gif svn_mime_002dtype=application%2Foctet-stream
ASCHTMLRenderer/Resources/imgtrackbar/b_r.gif svn_mime_002dtype=application%2Foctet-stream ASCHTMLRenderer/Resources/imgtrackbar/b_r.gif svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/Expat/lib/libexpat.lib svn_mime_002dtype=application%2Foctet-stream ASCImageStudio3/ASCGraphics/Expat/lib/libexpat.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/Images/Cursors/closehand.cur svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/Images/Cursors/hand.cur svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/Images/Cursors/harrow.cur svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/Objects/Font/FreeType/freetype242_vs2005.lib svn_mime_002dtype=application%2Foctet-stream ASCImageStudio3/ASCGraphics/Objects/Font/FreeType/freetype242_vs2005.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/OfficeSvmFile/zlibstat.lib svn_mime_002dtype=application%2Foctet-stream ASCImageStudio3/ASCGraphics/OfficeSvmFile/zlibstat.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/bin/Release/AxInterop.AVSGraphics.dll svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/bin/Release/Interop.AVSGraphics.dll svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/bin/Release/Interop.AVSOfficeFile.dll svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/bin/Release/Interop.AVSOfficeUniversalConverter.dll svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/bin/Release/WindowsApplication1.exe svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/bin/Release/WindowsApplication1.pdb svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/bin/Release/WindowsApplication1.vshost.exe svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/break_one.bmp svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/break_two.bmp svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/cont_one.bmp svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/cont_two.bmp svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/next.bmp svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/open.bmp svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/TestDocumentViewer/TestDocumentViewer/prev.bmp svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/cximage/CxImage/Debug/cximage.lib svn_mime_002dtype=application%2Foctet-stream ASCImageStudio3/ASCGraphics/cximage/CxImage/Debug/cximage.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/cximage/CxImage/Release/cximage.lib svn_mime_002dtype=application%2Foctet-stream ASCImageStudio3/ASCGraphics/cximage/CxImage/Release/cximage.lib svn_mime_002dtype=application%2Foctet-stream
ASCImageStudio3/ASCGraphics/cximage/jasper/Debug/jasper.lib svn_mime_002dtype=application%2Foctet-stream ASCImageStudio3/ASCGraphics/cximage/jasper/Debug/jasper.lib svn_mime_002dtype=application%2Foctet-stream
......
#include "stdafx.h"
#include "Clip.h"
#include "..\VectorGraphics\MemoryUtils.h"
#include "..\VectorGraphics\SPath.h"
#include "..\VectorGraphics\SXPath.h"
#include "..\VectorGraphics\SXPathScanner.h"
#include "..\VectorGraphics\SBitmap.h"
#include "..\Objects\Structures.h"
#include "Pixels.h"
void CClip::Reset(double dMinX, double dMinY, double dMaxX, double dMaxY, BOOL bAntialias)
{
m_bAntiAlias = bAntialias;
if ( dMinX < dMaxX )
{
m_dMinX = dMinX;
m_dMaxX = dMaxX;
}
else
{
m_dMinX = dMaxX;
m_dMaxX = dMinX;
}
if ( dMinY < dMaxY )
{
m_dMinY = dMinY;
m_dMaxY = dMaxY;
}
else
{
m_dMinY = dMaxY;
m_dMaxY = dMinY;
}
m_nMinX = (int)floor( m_dMinX );
m_nMinY = (int)floor( m_dMinY );
m_nMaxX = (int)floor( m_dMaxX );
m_nMaxY = (int)floor( m_dMaxY );
for ( int nIndex = 0; nIndex < m_nPathsCount; ++nIndex )
{
if ( m_ppPaths[nIndex] )
delete m_ppPaths[nIndex];
if ( m_pScanners[nIndex] )
delete m_pScanners[nIndex];
}
MemUtilsFree( m_ppPaths );
MemUtilsFree( m_pFlags );
MemUtilsFree( m_pScanners );
m_nPathsCount = m_nSize = 0;
m_dLeft = dMinX;
m_dTop = dMinY;
m_dRight = dMaxX;
m_dBottom = dMaxY;
}
void CClip::Reset()
{
for ( int nIndex = 0; nIndex < m_nPathsCount; ++nIndex )
{
if ( m_ppPaths[nIndex] )
delete m_ppPaths[nIndex];
if ( m_pScanners[nIndex] )
delete m_pScanners[nIndex];
}
MemUtilsFree( m_ppPaths );
MemUtilsFree( m_pFlags );
MemUtilsFree( m_pScanners );
m_nPathsCount = m_nSize = 0;
}
void CClip::ClipAALine(CPixels* pAABuffer, int *pnX0, int *pnX1, int nY)
{
int nXX = 0, nYY = 0;
LONG lStride = pAABuffer->m_lStride;
// nX < m_dMinX
int nX0 = *pnX0 * AntiAliasingSize;
int nX1 = (int)floor(m_dMinX * AntiAliasingSize);
if ( nX1 > pAABuffer->m_lWidth )
{
nX1 = pAABuffer->m_lWidth;
}
if ( nX0 < nX1 )
{
nX0 &= ~7;
for ( nYY = 0; nYY < AntiAliasingSize; ++nYY )
{
SColorPointer pColor = pAABuffer->m_pPixels + nYY * lStride + (nX0 >> 3);
for ( nXX = nX0; nXX + 7 < nX1; nXX += 8 )
{
*pColor++ = 0;
}
if ( nXX < nX1 )
{
*pColor &= 0xff >> (nX1 & 7);
}
}
*pnX0 = (int)floor(m_dMinX);
}
// nX > m_dMaxX
nX0 = (int)floor(m_dMaxX * AntiAliasingSize) + 1;
if ( nX0 < 0 )
{
nX0 = 0;
}
nX1 = (*pnX1 + 1) * AntiAliasingSize;
if ( nX0 < nX1 )
{
for ( nYY = 0; nYY < AntiAliasingSize; ++nYY )
{
SColorPointer pColor = pAABuffer->m_pPixels + nYY * lStride + (nX0 >> 3);
nXX = nX0;
if ( nXX & 7 )
{
*pColor &= 0xff00 >> (nXX & 7);
nXX = (nXX & ~7) + 8;
++pColor;
}
for (; nXX < nX1; nXX += 8)
{
*pColor++ = 0;
}
}
*pnX1 = (int)floor(m_dMaxX);
}
for ( int nIndex = 0; nIndex < m_nPathsCount; ++nIndex )
{
m_pScanners[nIndex]->ClipAALine( pAABuffer, pnX0, pnX1, nY );
}
}
\ No newline at end of file
#pragma once
#include "..\stdafx.h"
#include "..\VectorGraphics\SClip.h"
#include "GraphicsPath.h"
class CPixels;
class CClip : public SClip
{
public:
CClip(double dMinX = 0, double dMinY = 0, double dMaxX = 0, double dMaxY = 0, BOOL bAntialias = TRUE) : SClip(dMinX, dMinY, dMaxX, dMaxY, bAntialias)
{
m_dLeft = dMinX;
m_dTop = dMinY;
m_dRight = dMaxX;
m_dBottom = dMaxY;
}
~CClip()
{
}
void Reset(double dMinX, double dMinY, double dMaxX, double dMaxY, BOOL bAntialias);
void Reset();
public:
BOOL Intersect(CGraphicsPath* pPath, double* pMatrix, double dFlatness, BOOL bEO)
{
return (0 == SClip::lipToPath(pPath, pMatrix, dFlatness, bEO));
}
BOOL Exclude(CGraphicsPath* pPath, double* pMatrix, double dFlatness, BOOL bEO)
{
CGraphicsPath oPath;
oPath.AddRectangle(m_dLeft, m_dTop, m_dRight - m_dLeft, m_dBottom - m_dTop);
oPath.AddPath(*pPath);
return Intersect(&oPath, pMatrix, dFlatness, bEO);
}
void ClipAALine(CPixels* pAABuffer, int *pnX0, int *pnX1, int nY);
private:
double m_dLeft;
double m_dTop;
double m_dRight;
double m_dBottom;
};
#include "stdafx.h"
#include <string.h>
#include "MemoryUtils.h"
#include "..\VectorGraphics\SErrorCodes.h"
#include "GraphicsPath.h"
#include "..\VectorGraphics\SMathExt.h"
CGraphicsPath::CGraphicsPath() : SPath()
{
m_bStartSubPath = false;
m_lMode = 0;
}
CGraphicsPath::CGraphicsPath(const CGraphicsPath &oSrc) : SPath((SPath*)&oSrc)
{
m_bStartSubPath = oSrc.m_bStartSubPath;
m_lMode = oSrc.m_lMode;
}
CGraphicsPath& CGraphicsPath::operator=(const CGraphicsPath& oSrc)
{
return *this;
}
CGraphicsPath::~CGraphicsPath()
{
}
// ------------------------------------------------
int CGraphicsPath::EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, BOOL bClockDirection)
{
int nRet = 0;
while ( fAngle1 < 0 )
fAngle1 += 360;
while ( fAngle1 > 360 )
fAngle1 -= 360;
while ( fAngle2 < 0 )
fAngle2 += 360;
while ( fAngle2 >= 360 )
fAngle2 -= 360;
if ( !bClockDirection )
{
if ( fAngle1 <= fAngle2 )
nRet = EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, fAngle2, FALSE );
else
{
nRet += EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, 360, FALSE );
nRet += EllipseArc2( fX, fY, fXRad, fYRad, 0, fAngle2, FALSE );
}
}
else
{
if ( fAngle1 >= fAngle2 )
nRet = EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, fAngle2, TRUE );
else
{
nRet += EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, 0, TRUE );
nRet += EllipseArc2( fX, fY, fXRad, fYRad, 360, fAngle2, TRUE );
}
}
return nRet;
}
double CGraphicsPath::AngToEllPrm(double fAngle, double fXRad, double fYRad)
{
//
// .. x= a cos(t) y = b sin(t) - .
// x = r cos(p), y = r sin(p) => t = atan2( sin(p) / b, cos(p) / a );
return atan2( sin( fAngle ) / fYRad, cos( fAngle ) / fXRad );
}
int CGraphicsPath::EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, BOOL bClockDirection)
{
//
int nRet = 0;
double dAngle1 = fAngle1 * 3.141592 / 180;
double dAngle2 = fAngle2 * 3.141592 / 180;
//
unsigned int nFirstPointQuard = int(fAngle1) / 90 + 1;
unsigned int nSecondPointQuard = int(fAngle2) / 90 + 1;
nSecondPointQuard = min( 4, max( 1, nSecondPointQuard ) );
nFirstPointQuard = min( 4, max( 1, nFirstPointQuard ) );
//
double fStartX = 0.0, fStartY = 0.0, fEndX = 0.0, fEndY = 0.0;
fStartX = fX + fXRad * cos( AngToEllPrm( dAngle1, fXRad, fYRad ) );
fStartY = fY + fYRad * sin( AngToEllPrm( dAngle1, fXRad, fYRad ) );
LineTo(fStartX, fStartY);
//
double fCurX = fStartX, fCurY = fStartY;
double dStartAngle = dAngle1;
double dEndAngle = 0;
if ( !bClockDirection )
{
for( unsigned int nIndex = nFirstPointQuard; nIndex <= nSecondPointQuard; nIndex++ )
{
if ( nIndex == nSecondPointQuard )
dEndAngle = dAngle2;
else
dEndAngle = (90 * (nIndex ) ) * 3.141592f / 180;
if ( !( nIndex == nFirstPointQuard ) )
dStartAngle = (90 * (nIndex - 1 ) ) * 3.141592f / 180;
EllipseArc3(fX, fY, fXRad, fYRad, AngToEllPrm( dStartAngle, fXRad, fYRad ), AngToEllPrm( dEndAngle, fXRad, fYRad ), &fEndX, &fEndY, FALSE);
}
}
else
{
for( unsigned int nIndex = nFirstPointQuard; nIndex >= nSecondPointQuard; nIndex-- )
{
if ( nIndex == nFirstPointQuard )
dStartAngle = dAngle1;
else
dStartAngle = (90 * (nIndex ) ) * 3.141592f / 180;
if ( !( nIndex == nSecondPointQuard ) )
dEndAngle = (90 * (nIndex - 1 ) ) * 3.141592f / 180;
else
dEndAngle = dAngle2;
EllipseArc3(fX, fY, fXRad, fYRad, AngToEllPrm( dStartAngle, fXRad, fYRad ), AngToEllPrm( dEndAngle, fXRad, fYRad ), &fEndX, &fEndY, FALSE);
}
}
return nRet;
}
int CGraphicsPath::EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, BOOL bClockDirection = FALSE)
{
// ,
double fX1 = 0.0, fX2 = 0.0, fY1 = 0.0, fY2 = 0.0;
double fCX1 = 0.0, fCX2 = 0.0, fCY1 = 0.0, fCY2 = 0.0;
double fAlpha = sin( dAngle2 - dAngle1 ) * ( sqrt( 4.0 + 3.0 * tan( (dAngle2 - dAngle1) / 2.0 ) * tan( (dAngle2 - dAngle1) / 2.0 ) ) - 1.0 ) / 3.0;
double fKoef = 1;
fX1 = fX + fXRad * cos( dAngle1 );
fY1 = fY + fYRad * sin( dAngle1 );
fX2 = fX + fXRad * cos( dAngle2 );
fY2 = fY + fYRad * sin( dAngle2 );
fCX1 = fX1 - fAlpha * fXRad * sin ( dAngle1 );
fCY1 = fY1 + fAlpha * fYRad * cos ( dAngle1 );
fCX2 = fX2 + fAlpha * fXRad * sin ( dAngle2 );
fCY2 = fY2 - fAlpha * fYRad * cos ( dAngle2 );
if ( !bClockDirection )
{
CurveTo(fCX1, fCY1, fCX2, fCY2, fX2, fY2);
*pfXCur = fX2;
*pfYCur = fY2;
}
else
{
CurveTo(fCX2, fCY2, fCX1, fCY1, fX1, fY1);
*pfXCur = fX1;
*pfYCur = fY1;
}
return 0;
}
int CGraphicsPath::Ellipse(double fX, double fY, double fXRad, double fYRad)
{
MoveTo(fX - fXRad, fY);
double c_fKappa = 0.552;
CurveTo(fX - fXRad, fY + fYRad * c_fKappa, fX - fXRad * c_fKappa, fY + fYRad, fX, fY + fYRad);
CurveTo(fX + fXRad * c_fKappa, fY + fYRad, fX + fXRad, fY + fYRad * c_fKappa, fX + fXRad, fY);
CurveTo(fX + fXRad, fY - fYRad * c_fKappa, fX + fXRad * c_fKappa, fY - fYRad, fX, fY - fYRad);
CurveTo(fX - fXRad * c_fKappa, fY - fYRad, fX - fXRad, fY - fYRad * c_fKappa, fX - fXRad, fY);
return 0;
}
#pragma once
#include "..\stdafx.h"
#include "math.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
#ifndef M_PI_4
#define M_PI_4 0.785398163397448309616
#endif
#include "..\VectorGraphics\SPath.h"
#include "..\Interfaces\IASCPen.h"
#include "..\Interfaces\IASCBrush.h"
#include "..\Objects\ASCSolidPattern.h"
class CGraphicsPath : public SPath
{
public:
CGraphicsPath();
CGraphicsPath(const CGraphicsPath& oSrc);
CGraphicsPath& operator=(const CGraphicsPath& oSrc);
~CGraphicsPath();
public:
// ,
inline BOOL AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
{
int nRet = 0;
if (m_bStartSubPath)
nRet += MoveTo(x1, y1);
else
nRet += LineTo(x1, y1);
nRet += CurveTo(x2, y2, x3, y3, x4, y4);
return (0 == nRet);
}
inline BOOL AddBeziers(double* pPoints, int nCount)
{
if (6 > nCount)
{
return FALSE;
}
int nRet = 0;
int nIndex = 0;
if (m_bStartSubPath)
{
nRet += PathCommandMoveTo(pPoints[0], pPoints[1]);
nIndex = 2;
}
int n = (nCount - nIndex) / 6;
for (int i = 0; i < n; ++i)
{
double* points = &pPoints[nIndex + i * 6];
nRet += CurveTo(points[0], points[1], points[2], points[3], points[4], points[5]);
}
return (0 == nRet);
}
inline BOOL AddCurve(double* pPoints, int nCount)
{
// . - .
return AddBeziers(pPoints, nCount);
}
inline BOOL AddLine(double x1, double y1, double x2, double y2)
{
if (m_bStartSubPath)
PathCommandMoveTo(x1, y1);
else
PathCommandLineTo(x1, y1);
return PathCommandLineTo(x2, y2);
}
inline BOOL AddLines(double* pPoints, int nCount)
{
if (2 > nCount)
{
return FALSE;
}
int nRet = 0;
int nIndex = 0;
if (m_bStartSubPath)
{
nRet += PathCommandMoveTo(pPoints[0], pPoints[1]);
nIndex = 2;
}
int n = (nCount - nIndex) / 2;
for (int i = 0; i < n; ++i)
{
double* points = &pPoints[nIndex + i * 2];
nRet += LineTo(points[0], points[1]);
}
return (0 == nRet);
}
inline BOOL AddEllipse(double x, double y, double width, double height)
{
double dRadX = width / 2.0;
double dRadY = height / 2.0;
return (0 == Ellipse(x - dRadX, y - dRadY, dRadX, dRadY));
}
inline BOOL AddRectangle(double x, double y, double width, double height)
{
PathCommandMoveTo(x, y);
PathCommandLineTo(x + width, y);
PathCommandLineTo(x + width, y + height);
PathCommandLineTo(x, y + height);
PathCommandLineTo(x, y);
return TRUE;
}
inline BOOL AddPolygon(double* pPoints, int nCount)
{
if (2 > nCount)
{
return FALSE;
}
int nRet = 0;
int nIndex = 0;
if (m_bStartSubPath)
{
nRet += PathCommandMoveTo(pPoints[0], pPoints[1]);
nIndex = 2;
}
int n = (nCount - nIndex) / 2;
if (0 < n)
{
for (int i = 0; i < n; ++i)
{
double* points = &pPoints[nIndex + i * 2];
nRet += LineTo(points[0], points[1]);
}
nRet += LineTo(pPoints[0], pPoints[1]);
}
return (0 == nRet);
}
inline BOOL AddPath(const CGraphicsPath& oPath)
{
SPath::Append((SPath*)&oPath);
return TRUE;
}
inline BOOL AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle)
{
return PathCommandArcTo(x, y, width, height, startAngle, sweepAngle);
}
inline BOOL PathCommandStart()
{
m_bStartSubPath = true;
return TRUE;
}
inline BOOL PathCommandEnd()
{
return TRUE;
}
inline BOOL PathCommandClose()
{
return (0 == SPath::Close());
}
inline BOOL PathCommandMoveTo(double dX, double dY)
{
m_bStartSubPath = FALSE;
return (0 == MoveTo(dX, dY));
}
inline BOOL PathCommandLineTo(double fX, double fY)
{
return (0 == LineTo(fX, fY));
}
inline BOOL PathCommandLinesTo(double* pPoints, int nCount)
{
return AddLines(pPoints, nCount);
}
inline BOOL PathCommandCurvesTo(double* pPoints, int nCount)
{
return AddBeziers(pPoints, nCount);
}
inline BOOL PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle)
{
if ( m_bStartSubPath )
{
double dStartAngle = fStartAngle * M_PI / 180;
double fStartX = fX + fWidth / 2.0 + fWidth / 2 * cos( AngToEllPrm( dStartAngle, fWidth / 2, fHeight / 2 ) );
double fStartY = fY + fHeight / 2.0 + fHeight / 2 * sin( AngToEllPrm ( dStartAngle, fWidth / 2, fHeight / 2 ) );
// , AppendEllipse, MoveTo
if ( fSweepAngle < 360 )
if ( !PathCommandMoveTo( fStartX, fStartY ) )
return FALSE;
}
BOOL bClockDirection = FALSE;
double fEndAngle = 360 - ( fSweepAngle + fStartAngle );
double fSrtAngle = 360 - fStartAngle;
if( fSweepAngle > 0 )
bClockDirection = TRUE;
if( fSweepAngle >= 360 ) //
{
return (0 == Ellipse(fX + fWidth / 2, fY + fHeight / 2, fWidth / 2, fHeight / 2));
}
else //
{
return (0 == EllipseArc(fX + fWidth / 2, fY + fHeight / 2, fWidth / 2, fHeight / 2, fSrtAngle, fEndAngle, bClockDirection));
}
}
inline BOOL GetPoints(double** pPoints)
{
if (NULL == *pPoints || 0 == m_nPointsCount)
return FALSE;
*pPoints = new double[2 * m_nPointsCount];
for (int i = 0; i < m_nPointsCount; ++i)
{
(*pPoints)[2 * i] = m_pPoints[i].dX;
(*pPoints)[2 * i + 1] = m_pPoints[i].dY;
}
return TRUE;
}
inline BOOL GetPoints(double* pPoints)
{
if (NULL == pPoints || 0 == m_nPointsCount)
return FALSE;
for (int i = 0; i < m_nPointsCount; ++i)
{
pPoints[2 * i] = m_pPoints[i].dX;
pPoints[2 * i + 1] = m_pPoints[i].dY;
}
return TRUE;
}
protected:
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, BOOL bClockDirection);
static double AngToEllPrm(double fAngle, double fXRad, double fYRad);
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, BOOL bClockDirection);
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, BOOL bClockDirection);
int Ellipse(double fX, double fY, double fXRad, double fYRad);
public:
STDMETHOD(Pattern)(IAVSGraphicsBase* pObject, IAVSPattern** ppPattern)
{
// .
if (NULL == pObject || NULL == ppPattern)
return S_FALSE;
IAVSPen* pPen = NULL;
pObject->QueryInterface(__uuidof(IAVSPen), (void**)&pPen);
if (NULL != pPen)
{
LONG lColor = 0;
pPen->get_Color(&lColor);
CoCreateInstance(__uuidof(CAVSSolidPattern), NULL, CLSCTX_INPROC, __uuidof(IAVSPattern), (void**)ppPattern);
if (NULL != *ppPattern)
{
((CAVSSolidPattern*)(*ppPattern))->SetColor(lColor);
}
return S_OK;
}
IAVSBrush* pBrush = NULL;
pObject->QueryInterface(__uuidof(IAVSBrush), (void**)&pBrush);
if (NULL != pBrush)
{
LONG lColor = 0;
pBrush->get_Color1(&lColor);
CoCreateInstance(__uuidof(CAVSSolidPattern), NULL, CLSCTX_INPROC, __uuidof(IAVSPattern), (void**)ppPattern);
if (NULL != *ppPattern)
{
((CAVSSolidPattern*)(*ppPattern))->SetColor(lColor);
}
return S_OK;
}
return S_FALSE;
}
private:
bool m_bStartSubPath;
LONG m_lMode;
friend class SXPath;
friend class SImage;
friend class CAVSGraphicsPath;
friend class CAVSGraphics;
};
#pragma once
#include "..\stdafx.h"
#include "..\VectorGraphics\STypes.h"
#include "..\VectorGraphics\MemoryUtils.h"
#include "..\Interfaces\IASCPattern.h"
#include "..\..\..\Common\ASCUtils.h"
class CPixels
{
public:
BYTE* m_pPixels;
SColorMode m_eMode;
LONG m_lStride;
LONG m_lPitch;
LONG m_lLeft;
LONG m_lTop;
LONG m_lWidth;
LONG m_lHeight;
BYTE* m_pAlpha; // ( flip)
// colorspaces,
LONG m_lPitchAlpha;
private:
BOOL m_bIsDestroy;
public:
CPixels()
{
m_bIsDestroy = FALSE;
m_pPixels = NULL;
m_pAlpha = NULL;
}
CPixels(BYTE* pPixels, LONG nWidth, LONG nHeight, LONG nRowPad = 0, SColorMode eMode = colorModeBGRA8, BOOL bAlpha = FALSE, LONG lPitch = 0, BOOL bTopDown = TRUE)
{
//Release();
Create(pPixels, nWidth, nHeight, nRowPad, eMode, bAlpha, lPitch, bTopDown);
}
~CPixels()
{
Release();
}
void Release()
{
if (m_bIsDestroy)
{
RELEASEARRAYOBJECTS(m_pPixels);
}
RELEASEARRAYOBJECTS(m_pAlpha);
}
void Create(BYTE* pPixels, LONG nWidth = 0, LONG nHeight = 0, LONG nRowPad = 0, SColorMode eMode = colorModeBGRA8, BOOL bAlpha = FALSE, LONG lPitch = 0, BOOL bTopDown = TRUE, BOOL bIsPixOffset = FALSE)
{
m_lWidth = nWidth;
m_lHeight = nHeight;
m_eMode = eMode;
m_lPitchAlpha = lPitch;
switch ( m_eMode )
{
case colorModeMono1:
m_lStride = ( m_lWidth + 7 ) >> 3;
m_lPitch = ( m_lPitchAlpha + 7) >> 3;
break;
case colorModeMono8:
m_lStride = m_lWidth;
m_lPitch = m_lPitchAlpha;
break;
case colorModeRGB8:
case colorModeBGR8:
m_lStride = m_lWidth * 3;
m_lPitch = m_lPitchAlpha * 3;
break;
case colorModeBGRA8:
case colorModeRGBA8:
m_lStride = m_lWidth * 4;
m_lPitch = m_lPitchAlpha * 4;
bAlpha = FALSE;
break;
}
m_lStride += nRowPad - 1;
m_lStride -= m_lStride % nRowPad;
if (NULL == pPixels)
{
m_pPixels = (BYTE*)MemUtilsMalloc( m_lStride * m_lHeight );
m_bIsDestroy = TRUE;
}
else
{
m_pPixels = pPixels;
m_bIsDestroy = FALSE;
}
if ( !bTopDown )
{
if (!bIsPixOffset)
{
m_pPixels += ( m_lHeight - 1 ) * m_lStride;
}
m_lStride = -m_lStride;
m_lPitch = -m_lPitch;
}
if ( bAlpha )
{
m_pAlpha = (BYTE*)MemUtilsMalloc( m_lWidth * m_lHeight );
}
else
{
m_pAlpha = NULL;
}
}
public:
void GetPixel(int nX, int nY, SColorPointer pPixel)
{
SColorPointer pColor = NULL;
if ( nY < 0 || nY >= m_lHeight || nX < 0 || nX >= m_lWidth )
{
return;
}
LONG lStride = m_lStride + m_lPitch;
switch (m_eMode)
{
case colorModeMono1:
lStride += (m_lPitch + 7) >> 3;
pColor = &m_pPixels[nY * lStride + (nX >> 3)];
pPixel[0] = (pColor[0] & (0x80 >> (nX & 7))) ? 0xff : 0x00;
break;
case colorModeMono8:
pColor = &m_pPixels[nY * lStride + nX];
pPixel[0] = pColor[0];
break;
case colorModeRGB8:
pColor = &m_pPixels[nY * lStride + 3 * nX];
pPixel[0] = pColor[0];
pPixel[1] = pColor[1];
pPixel[2] = pColor[2];
break;
case colorModeBGR8:
pColor = &m_pPixels[nY * lStride + 3 * nX];
pPixel[0] = pColor[2];
pPixel[1] = pColor[1];
pPixel[2] = pColor[0];
break;
case colorModeRGBA8:
pColor = &m_pPixels[nY * lStride + 4 * nX];
pPixel[0] = pColor[2];
pPixel[1] = pColor[1];
pPixel[2] = pColor[0];
break;
case colorModeBGRA8:
pColor = &m_pPixels[nY * lStride + 4 * nX];
pPixel[0] = pColor[2];
pPixel[1] = pColor[1];
pPixel[2] = pColor[0];
pPixel[3] = pColor[3];
break;
}
}
};
struct SPipe
{
int nX; //
int nY; //
IAVSPattern* pPattern; // Source Pattern
double dAlphaInput; //
BOOL bUsesShape; //
unsigned char unAlphaSrc; // Source Alpha
SColorPointer pColorSrc; // Source Color
SColor arrColorSrcVal; //
unsigned char* pAlpha0; // - Non-isolated
SColorPointer pSMask; // Soft Mask
SColorPointer pColorDst; // Destination Color
int nColorMaskDst; // Destination Color Mask
unsigned char* pAlphaDst; // Destination Alpha
double dShape; // Shape
BOOL bNoTransparency; //
int nNonIsolatedGroup;// Non-isolated group correction
SPipeResultColorCtrl eResultColorCtrl;
};
class CGlyph
{
public:
int nX; // X
int nY; // Y
int nWidth; //
int nHeight; //
BOOL bAA; // Anti-aliased: True , Bitmap 8-(.. ); False - Bitmap 1-
unsigned char *pData; // Bitmap data( )
BOOL bFreeData; // True, pData
};
class CState
{
public:
double m_arrdMatrix[6];
double m_dStrokeAlpha;
double m_dLineWidth;
int m_nLineCap;
int m_nLineJoin;
double m_dMiterLimit;
double m_dFlatness;
double *m_pdLineDash;
int m_nLineDashCount;
double m_dLineDashPhase;
BOOL m_bStrokeAdjust;
};
//-------------------------------------------------------------------------------------------------------------------------------
// Line cap
//-------------------------------------------------------------------------------------------------------------------------------
//#define LineCapButt 0
//#define LineCapRound 1
//#define LineCapProjecting 2
//
////-------------------------------------------------------------------------------------------------------------------------------
//// Line join
////-------------------------------------------------------------------------------------------------------------------------------
//
//#define LineJoinMiter 0
//#define LineJoinRound 1
//#define LineJoinBevel 2
#pragma once
#include "..\stdafx.h"
#include "..\Objects\ASCGraphics.h"
#include "..\..\..\Common\TimeMeasurer.h"
#include "..\agg\Aggplus.h"
class CTester
{
private:
LONG m_lWidthPix;
LONG m_lHeightPix;
LONG m_lStridePix;
LONG m_lPitchPix;
LONG m_lCount;
MediaCore::IAVSUncompressedVideoFrame* m_pImage;
public:
CTester()
{
m_lWidthPix = 1000;
m_lHeightPix = 1000;
m_lStridePix = 4 * m_lWidthPix;
m_lPitchPix = 0;
m_lCount = 100;
m_pImage = NULL;
CoCreateInstance(MediaCore::CLSID_CAVSUncompressedVideoFrame, NULL, CLSCTX_INPROC, MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&m_pImage);
m_pImage->put_ColorSpace(64);
m_pImage->put_Width(m_lWidthPix);
m_pImage->put_Height(m_lHeightPix);
m_pImage->SetDefaultStrides();
m_pImage->AllocateBuffer(-1);
BYTE* pPixels = NULL;
m_pImage->get_Buffer(&pPixels);
memset(pPixels, 255, m_lStridePix * m_lHeightPix);
}
~CTester()
{
RELEASEINTERFACE(m_pImage);
}
float GDI_DRAW()
{
BYTE* pPixels = NULL;
m_pImage->get_Buffer(&pPixels);
Gdiplus::Bitmap oBitmap(m_lWidthPix, m_lHeightPix, m_lStridePix, PixelFormat32bppARGB, pPixels);
Gdiplus::Graphics oGr(&oBitmap);
oGr.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
oGr.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
Gdiplus::SolidBrush oBrush(Gdiplus::Color::Red);
Gdiplus::Pen oPen(Gdiplus::Color::Red, 2);
oGr.SetInterpolationMode(Gdiplus::InterpolationModeBilinear);
Gdiplus::Font oFont(L"Arial", 30);
Gdiplus::PointF point(800, 800);
//Gdiplus::Bitmap oImage(L"C:\\Documents and Settings\\Oleg.Korshul.AVSMEDIA\\Desktop\\Images\\121.jpg");
CTimeMeasurer oTimer;
oTimer.Reset();
/*for (int i = 0; i < m_lCount; ++i)
{
Gdiplus::Bitmap oImage(L"C:\\Documents and Settings\\Oleg.Korshul.AVSMEDIA\\Desktop\\Images\\121.bmp");
Gdiplus::BitmapData oData;
oImage.LockBits(NULL, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &oData);
}*/
oGr.DrawString(L"Hellow", 6, &oFont, point, &oBrush);
//for (int i = 0; i < m_lCount; ++i)
//{
// Gdiplus::GraphicsPath oPath;
// oPath.AddEllipse(500, 500, 200, 200);
// oGr.FillPath(&oBrush, &oPath);
//
// //oGr.DrawLine(&oPen, 500, 500, 700, 700);
//}
/*Gdiplus::Bitmap oImage(L"C:\\Documents and Settings\\Oleg.Korshul.AVSMEDIA\\Desktop\\Images\\1.gif");
oGr.DrawImage(&oImage, 500, 500, 200, 200);*/
float fTime = oTimer.GetTimeInterval();
return fTime;
}
float NEW_DRAW()
{
BYTE* pPixels = NULL;
m_pImage->get_Buffer(&pPixels);
//// agg
/*Aggplus::Bitmap oBitmap((Aggplus::INT)m_lWidthPix, (Aggplus::INT)m_lHeightPix, (Aggplus::INT)m_lStridePix, PixelFormat32bppARGB, pPixels);
Aggplus::Graphics oGr(&oBitmap);
Aggplus::Color oColor(0, 0, 255);
Aggplus::SolidBrush oBrush(oColor);
Aggplus::Pen oPen(oColor, 2);
Aggplus::Font oFont(L"Vivaldi", 30);
Aggplus::PointF point(400, 400);
oGr.DrawString(L"Hellow", 6, &oFont, point, &oBrush);
CTimeMeasurer oTimer;
oTimer.Reset();*/
//for (int i = 0; i < m_lCount; ++i)
//{
// Aggplus::GraphicsPath oPath;
// oPath.AddEllipse(100, 100, 200, 200);
// oGr.FillPath(&oBrush, &oPath);
// //oGr.FillEllipse(&oBrush, 100, 100, 200, 200);
// //oGr.DrawLine(&oPen, 100, 100, 300, 300);
//}
/*for (int i = 0; i < m_lCount; ++i)
{
Aggplus::Image oImage(L"C:\\Documents and Settings\\Oleg.Korshul.AVSMEDIA\\Desktop\\Images\\121.bmp");
}*/
/*Aggplus::Image oImage(L"C:\\Documents and Settings\\Oleg.Korshul.AVSMEDIA\\Desktop\\Images\\1.gif");
oGr.DrawImage(&oImage, 100, 100, 200, 200);*/
/*float fTime = oTimer.GetTimeInterval();
return fTime;*/
IAVSGraphics* pGraphics = NULL;
CoCreateInstance(__uuidof(CAVSGraphics), NULL, CLSCTX_INPROC, __uuidof(IAVSGraphics), (void**)&pGraphics);
pGraphics->Create(pPixels, m_lWidthPix, m_lHeightPix, m_lStridePix, m_lPitchPix, 5);
IAVSBrush* pBrush = NULL;
CoCreateInstance(__uuidof(CAVSBrush), NULL, CLSCTX_INPROC, __uuidof(IAVSBrush), (void**)&pBrush);
pBrush->put_Color1(0xFFFF0000);
IAVSFontManager* pFont = NULL;
CoCreateInstance(__uuidof(CAVSFontManager), NULL, CLSCTX_INPROC, __uuidof(IAVSFontManager), (void**)&pFont);
pFont->Initialize(L"");
pFont->LoadFontByName(L"Vivaldi", 30, 0, 96, 96);
CTimeMeasurer oTimer;
oTimer.Reset();
///*for (int i = 0; i < m_lCount; ++i)
//{
// pGraphics->FillEllipse(pBrush, 600, 600, 200, 200);
//}*/
pGraphics->DrawString(L"Hellow", pFont, pBrush, 0, 500);
float fTime = oTimer.GetTimeInterval();
RELEASEINTERFACE(pBrush);
RELEASEINTERFACE(pGraphics);
RELEASEINTERFACE(pFont);
return fTime;
}
void Test()
{
float t1 = GDI_DRAW();
float t2 = NEW_DRAW();
FILE* f = fopen("c:\\graphics.txt", "a+");
fprintf(f, "count = %d: gdi/new: %lf/%lf\n", m_lCount, (double)t1, (double)t2);
fclose(f);
Save();
}
void Save()
{
ImageStudio::IImageTransforms* pTransform = NULL;
CoCreateInstance( ImageStudio::CLSID_ImageTransforms, NULL, CLSCTX_INPROC, ImageStudio::IID_IImageTransforms, (void**)(&pTransform));
VARIANT var;
var.vt = VT_UNKNOWN;
var.punkVal = (IUnknown*)m_pImage;
VARIANT_BOOL vbRes=VARIANT_TRUE;
pTransform->SetSource(0, var);
pTransform->SetXml(L"<transforms><ImageFile-SaveAsBmp destinationpath='c:\\out.bmp' format='888' quality='100'></ImageFile-SaveAsBmp></transforms>", &vbRes);
pTransform->Transform(&vbRes);
RELEASEINTERFACE(pTransform);
}
};
\ No newline at end of file
#pragma once
#include "stdafx.h"
#include "DIB.h"
#include "..\Interfaces\ASCGraphicsRenderer.h"
void NSDocumentViewer::CPainter::SetDpi(double dDpiX, double dDpiY)
{
m_dKoefPixToMM_X = c_dInch_to_MM / dDpiX;
m_dKoefPixToMM_Y = c_dInch_to_MM / dDpiY;
double dWidthMM = m_lDisplayWidth * m_dKoefPixToMM_X;
double dHeightMM = m_lDisplayHeight * m_dKoefPixToMM_Y;
((CAVSGraphicsRenderer*)m_pRenderer)->SetSizes(dWidthMM, dHeightMM);
}
\ No newline at end of file
This diff is collapsed.
#pragma once
// IAVSDocumentViewer
[object, uuid("239D54EB-8A00-4314-B8B5-C8BCA9DC84FC"), dual, pointer_default(unique)]
__interface IAVSDocumentViewer : public IDispatch
{
[id(100), propget] HRESULT ViewMode([out, retval] LONG* lType);
[id(100), propput] HRESULT ViewMode([in] LONG lType);
[id(101), propget] HRESULT Zoom([out, retval] double* dZoom);
[id(101), propput] HRESULT Zoom([in] double dZoom);
[id(102), propget] HRESULT PositionHor([out, retval] double* dPosition);
[id(102), propput] HRESULT PositionHor([in] double dPosition);
[id(103), propget] HRESULT PositionVer([out, retval] double* dPosition);
[id(103), propput] HRESULT PositionVer([in] double dPosition);
[id(148), propget] HRESULT ControlWidth([out, retval] LONG* lWidth);
[id(149), propget] HRESULT ControlHeight([out, retval] LONG* lHeight);
[id(150), propget] HRESULT DocumentWidth([out, retval] double* dWidth);
[id(151), propget] HRESULT DocumentHeight([out, retval] double* dHeight);
[id(201), propget] HRESULT CountPages([out, retval] LONG* lCountPages);
[id(202), propget] HRESULT CurrentPage([out, retval] LONG* lCurrentPage);
[id(202), propput] HRESULT CurrentPage([in] LONG lCurrentPage);
[id(203), propget] HRESULT PagesInBlock([out, retval] LONG* lCurrentPage);
[id(203), propput] HRESULT PagesInBlock([in] LONG lCurrentPage);
[id(300)] HRESULT CloseFile();
[id(500)] HRESULT Init();
[id(600), propget] HRESULT OfficeSource([out, retval] IUnknown** ppSource);
[id(600), propput] HRESULT OfficeSource([in] IUnknown* pSource);
[id(700), propget] HRESULT ThumbnailsViewer([out, retval] IUnknown** ppThViewer);
[id(700), propput] HRESULT ThumbnailsViewer([in] IUnknown* pThViewer);
[id(800)] HRESULT SetSource([in] IUnknown* punkSource, [in] LONG lViewMode, [in] double dZoom, [in] double dPositionVer, [in] double dPositionHor);
[id(10000), hidden] HRESULT _OnTimer(void);
};
// _IAVSDocumentViewerEvents
[uuid("9F707592-0C5A-4f59-A57A-D11F49FF5FDF"), dispinterface]
__interface _IAVSDocumentViewerEvents
{
[id(10)] HRESULT OnDocumentSizeChanged(double dWidth, double dHeight, double dPositionHor, double dPositionVer);
[id(11)] HRESULT OnDocumentPositionChanged(double dPositionHor, double dPositionVer);
[id(12)] HRESULT OnDocumentPageChanged(LONG lPageNumber);
[id(13)] HRESULT OnDocumentCountPagesChanged(LONG lPageCount);
[id(101)] HRESULT OnMouseDown ( long Button, long Shift, double X, double Y );
[id(102)] HRESULT OnMouseUp ( long Button, long Shift, double X, double Y );
[id(103)] HRESULT OnMouseMove ( long Button, long Shift, double X, double Y );
[id(104)] HRESULT OnMouseDblClick ( long Button, long Shift, double X, double Y );
[id(151)] HRESULT OnKeyDown ( long Button, long Shift, double X, double Y );
[id(152)] HRESULT OnKeyUp ( long Button, long Shift, double X, double Y );
[id(200)] HRESULT OnMessage ( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL* bHandled);
};
// IAVSViewerThumbnails
[object, uuid("4E2474FB-9C42-4691-B064-C01616C5B9FC"), dual, pointer_default(unique)]
__interface IAVSThumbnailsViewer : public IDispatch
{
[id(50), propget] HRESULT FixWidth([out, retval] double* pdFixWidth);
[id(50), propput] HRESULT FixWidth([in] double dFixWidth);
[id(51), propget] HRESULT FixHeight([out, retval] double* pdFixHeight);
[id(51), propput] HRESULT FixHeight([in] double dFixHeight);
[id(101), propget] HRESULT Zoom([out, retval] double* dZoom);
[id(101), propput] HRESULT Zoom([in] double dZoom);
[id(102), propget] HRESULT PositionHor([out, retval] double* dPosition);
[id(102), propput] HRESULT PositionHor([in] double dPosition);
[id(103), propget] HRESULT PositionVer([out, retval] double* dPosition);
[id(103), propput] HRESULT PositionVer([in] double dPosition);
[id(148), propget] HRESULT ControlWidth([out, retval] LONG* lWidth);
[id(149), propget] HRESULT ControlHeight([out, retval] LONG* lHeight);
[id(150), propget] HRESULT DocumentWidth([out, retval] double* dWidth);
[id(151), propget] HRESULT DocumentHeight([out, retval] double* dHeight);
[id(201), propget] HRESULT CountPages([out, retval] LONG* lCountPages);
[id(202), propget] HRESULT CurrentPage([out, retval] LONG* lCurrentPage);
[id(202), propput] HRESULT CurrentPage([in] LONG lCurrentPage);
[id(203), propget] HRESULT VisibleViewerBounds([out, retval] VARIANT_BOOL* vbValue);
[id(203), propput] HRESULT VisibleViewerBounds([in] VARIANT_BOOL vbValue);
[id(300)] HRESULT CloseFile();
[id(500)] HRESULT Init();
[id(600), propget] HRESULT OfficeSource([out, retval] IUnknown** ppSource);
[id(600), propput] HRESULT OfficeSource([in] IUnknown* pSource);
[id(700), propget] HRESULT DocumentViewer([out, retval] IUnknown** ppDocViewer);
[id(700), propput] HRESULT DocumentViewer([in] IUnknown* pDocViewer);
[id(710)] HRESULT SetCurrentPageInfo([in] LONG lCurrentPage, [in] double dLeft, [in] double dTop, [in] double dWidth, [in] double dHeight);
[id(800)] HRESULT GetPagePointInside([in] double dX, [in] double dY, [out] LONG* lPage);
[id(900)] HRESULT SetSource([in] IUnknown* punkSource, [in] double dZoom, [in] double dPositionVer, [in] double dPositionHor);
[id(10000), hidden] HRESULT _OnTimer(void);
};
// _IAVSThumbnailsViewerEvents
[uuid("52FEA94B-26B2-4f2f-A5AF-F05461DB2D29"), dispinterface]
__interface _IAVSThumbnailsViewerEvents
{
[id(10)] HRESULT OnDocumentSizeChanged(double dWidth, double dHeight, double dPositionHor, double dPositionVer);
[id(11)] HRESULT OnDocumentPositionChanged(double dPositionHor, double dPositionVer);
[id(12)] HRESULT OnDocumentPageChanged(LONG lPageNumber);
[id(13)] HRESULT OnDocumentCountPagesChanged(LONG lPageCount);
[id(101)] HRESULT OnMouseDown ( long Button, long Shift, double X, double Y );
[id(102)] HRESULT OnMouseUp ( long Button, long Shift, double X, double Y );
[id(103)] HRESULT OnMouseMove ( long Button, long Shift, double X, double Y );
[id(104)] HRESULT OnMouseDblClick ( long Button, long Shift, double X, double Y );
[id(151)] HRESULT OnKeyDown ( long Button, long Shift, double X, double Y );
[id(152)] HRESULT OnKeyUp ( long Button, long Shift, double X, double Y );
[id(200)] HRESULT OnMessage ( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL* bHandled);
};
\ No newline at end of file
#pragma once
#include "stdafx.h"
#include "ASCMetafile.h"
#include "..\Interfaces\ImageSerializeObjects2.h"
void CMetafile::GenerateMetafile(BSTR bsXML)
{
XmlUtils::CXmlNode oNodeWatermark;
if (oNodeWatermark.FromXmlString((CString)bsXML))
{
ImageStudio::Serialize::Paint::Common::CTextMeasurer oMeasurer;
LONG lMode = 0;
oMeasurer.InternalFromNonFoXml2(oNodeWatermark, lMode, m_fWidth, m_fHeight);
CoCreateInstance(__uuidof(CAVSMetafile), NULL, CLSCTX_ALL, __uuidof(IAVSMetafile), (void**)&m_pAdditionalCommands);
m_pAdditionalCommands->put_Width(m_fWidth);
m_pAdditionalCommands->put_Height(m_fHeight);
IAVSRenderer* pRenderer = NULL;
m_pAdditionalCommands->QueryInterface(IID_IUnknown, (void**)&pRenderer);
if (!oMeasurer.IsFormated())
{
oMeasurer.InitDrawText(pRenderer, 720, 576);
}
oMeasurer.DrawText(pRenderer, 1.0);
RELEASEINTERFACE(pRenderer);
}
}
\ No newline at end of file
This diff is collapsed.
#pragma once
#include "..\stdafx.h"
#include "ViewerCommon.h"
#define AVS_OFFICE_SOURCE_COMPLETEPAGE_EVENT 7
#define AVS_OFFICE_SOURCE_COMPLETE_EVENT 1
#define AVS_OFFICE_SOURCE_WATERMARK_EVENT 9
#define AVS_COUNT_PAGES_UPDATE_SOURCE 10
class CEventsSource
{
public:
virtual void OnCompletePage()
{
}
virtual void OnUpdateWatermark()
{
}
};
class COfficeSource
{
class COfficeSourceEvents : public DocConverter::_IAVSXMLOfficeSourceEvents
{
public:
COfficeSourceEvents(CEventsSource* pSource)
{
m_cnt = 0;
m_dwAdvise = 0;
m_pSource = pSource;
m_nCountPages = 0;
}
virtual ~COfficeSourceEvents(void)
{
}
STDMETHOD(GetTypeInfoCount)(UINT*) { return E_NOTIMPL; }
STDMETHOD(GetTypeInfo)(UINT, LCID, ITypeInfo**) { return E_NOTIMPL; }
STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, UINT, LCID, DISPID*) { return E_NOTIMPL; }
STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
switch(dispIdMember)
{
case AVS_OFFICE_SOURCE_COMPLETEPAGE_EVENT:
{
++m_nCountPages;
if (AVS_COUNT_PAGES_UPDATE_SOURCE <= m_nCountPages)
{
m_nCountPages = 0;
if (NULL != m_pSource)
{
m_pSource->OnCompletePage();
}
}
return S_OK;
}
case AVS_OFFICE_SOURCE_COMPLETE_EVENT:
{
m_nCountPages = 0;
if (NULL != m_pSource)
{
m_pSource->OnCompletePage();
}
return S_OK;
}
case AVS_OFFICE_SOURCE_WATERMARK_EVENT:
{
if (NULL != m_pSource)
{
m_pSource->OnUpdateWatermark();
}
return S_OK;
}
default:
return E_NOTIMPL;
}
}
STDMETHOD(QueryInterface)(REFIID iid, LPVOID* ppv) {
if ((iid == __uuidof(DocConverter::_IAVSXMLOfficeSourceEvents)) ||
(iid == __uuidof(IDispatch)) ||
(iid == __uuidof(IUnknown)))
*ppv = this;
else {
*ppv = 0;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
STDMETHOD_(ULONG,AddRef)() {
return InterlockedIncrement(&m_cnt);
}
STDMETHOD_(ULONG,Release)() {
InterlockedDecrement(&m_cnt);
if (m_cnt!=0) return m_cnt;
delete this;
return 0;
}
BOOL Advise(IUnknown *pFile)
{
m_nCountPages = 0;
if (NULL == pFile)
return FALSE;
IConnectionPointContainer* pContainer;
IConnectionPoint* pCP;
HRESULT hr = pFile->QueryInterface(IID_IConnectionPointContainer, (void**)&pContainer);
if (NULL!=pContainer)
{
pContainer->FindConnectionPoint(__uuidof(DocConverter::_IAVSXMLOfficeSourceEvents), &pCP);
if (NULL!=pCP)
{
pCP->Advise(this, &m_dwAdvise);
pCP->Release();
pCP = NULL;
}
pContainer->Release();
pContainer = NULL;
}
return TRUE;
}
BOOL UnAdvise(IUnknown *pFile)
{
if ((NULL == pFile) || (0 == m_dwAdvise) || (NULL == m_pSource))
return FALSE;
IConnectionPointContainer* pContainer;
IConnectionPoint* pCP;
HRESULT hr = pFile->QueryInterface(IID_IConnectionPointContainer, (void**)&pContainer);
if (NULL!=pContainer)
{
hr = pContainer->FindConnectionPoint(__uuidof(DocConverter::_IAVSXMLOfficeSourceEvents), &pCP);
if (NULL!=pCP)
{
hr = pCP->Unadvise(m_dwAdvise);
pCP->Release();
pCP = NULL;
}
pContainer->Release();
pContainer = NULL;
}
return TRUE;
}
public:
CEventsSource* m_pSource;
protected:
LONG m_cnt;
DWORD m_dwAdvise;
int m_nCountPages; // , , 10
};
public:
DocConverter::IAVSXMLOfficeSource* m_pSource;
COfficeSourceEvents m_oEvents;
public:
IUnknown* GetSource()
{
if (NULL == m_pSource)
return NULL;
IUnknown* punk = NULL;
m_pSource->QueryInterface(IID_IUnknown, (void**)&punk);
return punk;
}
void SetSource(IUnknown* pSource)
{
m_oEvents.UnAdvise(m_pSource);
RELEASEINTERFACE(m_pSource);
if (NULL != pSource)
{
pSource->QueryInterface(DocConverter::IID_IAVSXMLOfficeSource, (void**)&m_pSource);
}
m_oEvents.Advise(m_pSource);
m_oEvents.AddRef();
}
public:
COfficeSource(CEventsSource* pSource) : m_oEvents(pSource)
{
m_pSource = NULL;
}
~COfficeSource()
{
SetSource(NULL);
}
};
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestDocumentViewer", "TestDocumentViewer\TestDocumentViewer.csproj", "{2D235BFE-9E65-4056-8CC1-0A295C29AC44}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2D235BFE-9E65-4056-8CC1-0A295C29AC44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D235BFE-9E65-4056-8CC1-0A295C29AC44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D235BFE-9E65-4056-8CC1-0A295C29AC44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D235BFE-9E65-4056-8CC1-0A295C29AC44}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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