Commit d6cd7ad4 authored by Sergey.Kirillov's avatar Sergey.Kirillov Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52209 954022d7-b5bf-4e40-9824-e11837661b57
parent 48f2b625
// AVSEBOOKWriter.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include "EBOOKWriter.h"
#include "MobiFormat/MobiFile.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you
[ module(dll, uuid = "{218DB989-85F3-4512-8A6D-71A7211FBC5A}",
name = "AVSEBOOKWriter",
helpstring = "AVSEBOOKWriter 1.0 Type Library",
resource_name = "IDR_AVSEBOOKWRITER") ];
\ No newline at end of file
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define COMPONENT_NAME "EBOOKWriter"
#include "../../../../Common/FileInfo.h"
#include "version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1251)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
3 TEXTINCLUDE
BEGIN
"\r\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Document
//
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
VALUE "OLESelfRegister", ""
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_AVSEBOOKWRITER REGISTRY "AVSEBOOKWriter.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "AVSEBOOKWriter"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'AVSEBOOKWriter'
'AVSEBOOKWriter.DLL'
{
val AppID = s '%APPID%'
}
}
}
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVSEBOOKWriter", "AVSEBOOKWriter.vcproj", "{BAB70A60-2DA0-4149-B8FC-99D7007E9BDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
ReleaseASC|Win32 = ReleaseASC|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BAB70A60-2DA0-4149-B8FC-99D7007E9BDB}.Debug|Win32.ActiveCfg = Debug|Win32
{BAB70A60-2DA0-4149-B8FC-99D7007E9BDB}.Debug|Win32.Build.0 = Debug|Win32
{BAB70A60-2DA0-4149-B8FC-99D7007E9BDB}.Release|Win32.ActiveCfg = Release|Win32
{BAB70A60-2DA0-4149-B8FC-99D7007E9BDB}.Release|Win32.Build.0 = Release|Win32
{BAB70A60-2DA0-4149-B8FC-99D7007E9BDB}.ReleaseASC|Win32.ActiveCfg = ReleaseASC|Win32
{BAB70A60-2DA0-4149-B8FC-99D7007E9BDB}.ReleaseASC|Win32.Build.0 = ReleaseASC|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
This diff is collapsed.
#pragma once
const long g_clFilePartSize = 20*1024;
class CCalculatorCRC32
{
public:
CCalculatorCRC32()
{
m_dwMagicWord = 0xEDB88320;
m_dwInitCrc = 0xFFFFFFFF;
m_bInitTable = FALSE;
}
public:
DWORD Calc(BYTE const*pStream, int nSize)
{
InitCRCTable();
DWORD dwRes = m_dwInitCrc;
for (int i=0;i<nSize;i++)
{
dwRes = m_arCRCTable[(dwRes ^ pStream[i])& 0xFF] ^ (dwRes >> 8);
}
dwRes = dwRes ^ 0xFFFFFFFF;
return dwRes;
}
DWORD Calc(const CString &sStream)
{
InitCRCTable();
DWORD dwRes = m_dwInitCrc;
int nSize = sStream.GetLength();
for (int i=0;i<nSize;i++)
{
dwRes = m_arCRCTable[(dwRes ^ (BYTE)sStream[i]) & 0xFF] ^ (dwRes >> 8);
}
dwRes = dwRes ^ 0xFFFFFFFF;
return dwRes;
}
DWORD CalcPartFile(const CString &sFilepath)
{
DWORD dwRet = 0xFFFFFFFF;
//LPBYTE pBuffer = new BYTE[g_clFilePartSize];
//if (NULL==pBuffer)
// return dwRet;
//FILE *pFile = fopen(sFilepath, "rb");
//if (NULL==pFile)
//{
// delete [] pBuffer;
// return dwRet;
//}
//size_t nReaded = fread(pBuffer, 1, 1024, pFile);
//fclose(pFile);
//dwRet = CCalculatorCRC32::Calc(pBuffer, nReaded);
//
////ATLTRACE("CRC32: 0x%08X\n", dwRet);
//delete [] pBuffer;
return dwRet;
}
private:
void InitCRCTable()
{
if (m_bInitTable)
return;
DWORD dwTemp;
for (int i=0;i<256;i++)
{
dwTemp = i;
for (int j=0;j<8;j++)
{
if (0x1==(dwTemp & 0x1))
dwTemp = (dwTemp >> 1) ^ m_dwMagicWord;
else
dwTemp = dwTemp >> 1;
}
m_arCRCTable[i] = dwTemp;
}
}
DWORD m_dwMagicWord;
DWORD m_dwInitCrc;
DWORD m_arCRCTable[255];
BOOL m_bInitTable;
};
This diff is collapsed.
This diff is collapsed.
#pragma once
#include "Common.h"
#include "FontManagerBase.h"
namespace NSCommon
{
using namespace NSFontManager;
const double c_dDpiX = 72.0;
const double c_dDpiY = 72.0;
class CFontManager : public CFontManagerBase
{
public:
NSStructures::CFont* m_pFont;
NSCommon::CMatrix* m_pTransform;
double m_dSpaceWidthMM;
public:
CFontManager() : m_pFont(NULL), CFontManagerBase()
{
m_pTransform = NULL;
m_dSpaceWidthMM = 0;
}
virtual ~CFontManager()
{
}
public:
virtual void LoadFont(long lFaceIndex = 0, bool bIsNeedAddToMap = true)
{
if (NULL == m_pManager)
return;
double dSize = m_pFont->Size;
double dSizeFont = dSize * ((m_pTransform->m_agg_mtx.sx + m_pTransform->m_agg_mtx.sy) / 2);
m_pFont->Size = dSizeFont;
if (m_pFont->IsEqual2(&m_oFont.m_oFont))
{
m_pFont->Size = dSize;
return;
}
m_oFont.m_oFont = *m_pFont;
m_pFont->Size = dSize;
bool bIsPath = false;
if (_T("") == m_pFont->Path)
{
CFontManagerBase::LoadFontByName(m_oFont.m_oFont.Name, m_oFont.m_oFont.Size, m_oFont.m_oFont.GetStyle());
}
else
{
CFontManagerBase::LoadFontByFile(m_oFont.m_oFont.Path, m_oFont.m_oFont.Size, lFaceIndex);
m_pFont->SetStyle(m_oFont.m_oProperties.m_lStyle);
m_oFont.m_oFont.SetStyle(m_oFont.m_oProperties.m_lStyle);
bIsPath = true;
}
CalculateSpace();
}
AVSINLINE void CalculateSpace()
{
LONG lGid = 0;
m_pManager->GetStringGID(&lGid);
m_pManager->SetStringGID(FALSE);
m_pManager->LoadString(L" ", 0, 0);
float _x = 0;
float _y = 0;
float _w = 0;
float _h = 0;
m_pManager->MeasureString2(&_x, &_y, &_w, &_h);
m_dSpaceWidthMM = (double)_w * c_dPixToMM;
if (0 >= m_dSpaceWidthMM)
{
m_dSpaceWidthMM = 1.0;
}
m_pManager->SetStringGID(lGid);
}
};
class CFontDstGenerator
{
public:
NSStructures::CFont* m_pFonts;
LONG m_lCurrentIndex;
LONG m_lCountFonts;
LONG m_lSize;
public:
CFontDstGenerator()
{
m_lSize = 50;
m_pFonts = NULL;
m_lCurrentIndex = -1;
m_lCountFonts = 0;
Grow();
}
~CFontDstGenerator()
{
RELEASEARRAYOBJECTS(m_pFonts);
}
public:
LONG AddFont(NSStructures::CFont* pFont, BOOL bIsFontChanged, CFontManagerBase* pBase)
{
if (-1 != m_lCurrentIndex && !bIsFontChanged)
return m_lCurrentIndex;
LONG lIndex = m_lCountFonts - 1;
while (lIndex >= 0)
{
if (m_pFonts[lIndex].IsEqual4(pFont))
break;
--lIndex;
}
if (lIndex >= 0)
{
m_lCurrentIndex = lIndex;
return m_lCurrentIndex;
}
if (m_lCountFonts == m_lSize)
{
//
Grow();
}
m_lCurrentIndex = m_lCountFonts;
++m_lCountFonts;
m_pFonts[m_lCurrentIndex] = *pFont;
// ...
m_pFonts[m_lCurrentIndex].Path = pBase->GetFontPath(&m_pFonts[m_lCurrentIndex]);
return m_lCurrentIndex;
}
LONG AddFont2(NSStructures::CFont* pFont, BOOL bIsFontChanged, CFontManagerBase* pBase)
{
if (-1 != m_lCurrentIndex && !bIsFontChanged)
return m_lCurrentIndex;
CString strName = pFont->Name;
LONG lStyle = pFont->GetStyle();
pFont->Name = pBase->m_strCurrentPickFont;
pFont->SetStyle(pBase->m_lCurrentPictFontStyle);
LONG lIndex = m_lCountFonts - 1;
while (lIndex >= 0)
{
if (m_pFonts[lIndex].IsEqual4(pFont))
break;
--lIndex;
}
if (lIndex >= 0)
{
m_lCurrentIndex = lIndex;
pFont->Name = strName;
pFont->SetStyle(lStyle);
return m_lCurrentIndex;
}
if (m_lCountFonts == m_lSize)
{
//
Grow();
}
m_lCurrentIndex = m_lCountFonts;
++m_lCountFonts;
m_pFonts[m_lCurrentIndex] = *pFont;
// ...
m_pFonts[m_lCurrentIndex].Path = pBase->GetFontPath(&m_pFonts[m_lCurrentIndex]);
pFont->Name = strName;
pFont->SetStyle(lStyle);
return m_lCurrentIndex;
}
public:
void WriteFonts(CString strFolderDst, CString& strCSS, CString& strItems)
{
// , css
strCSS = _T("");
strItems = _T("");
for (LONG nFont = 0; nFont < m_lCountFonts; ++nFont)
{
CString strName = m_pFonts[nFont].Name;
strName.Replace(_T(" "), _T("_avs_space_"));
CString strCssMem = _T("@font-face {font-family:") + strName + _T(";font-weight:");
if (m_pFonts[nFont].Bold)
strCssMem += _T("bold;font-style:");
else
strCssMem += _T("normal;font-style:");
if (m_pFonts[nFont].Italic)
strCssMem += _T("italic;src:url(fonts/");
else
strCssMem += _T("normal;src:url(fonts/");
int nStart1 = m_pFonts[nFont].Path.ReverseFind((TCHAR)'\\');
int nStart2 = m_pFonts[nFont].Path.ReverseFind((TCHAR)'/');
int nStart = max(nStart1, nStart2);
int nEnd = m_pFonts[nFont].Path.GetLength();
CString strDstName = m_pFonts[nFont].Path.Mid(nStart + 1, nEnd - nStart - 1);
strDstName.Replace(_T(" "), _T("_avs_space_"));
CString strFile = strFolderDst + _T("\\fonts\\") + strDstName;
DWORD dwFileAttrib = ::GetFileAttributes(strFile);
if (dwFileAttrib == INVALID_FILE_ATTRIBUTES)
{
//
::CopyFile(m_pFonts[nFont].Path, strFile, TRUE);
}
nEnd = strDstName.Find(TCHAR('.'));
CString strId = strDstName;
if (-1 != nEnd)
strId = strId.Mid(0, nEnd);
strItems += (_T("<item id=\"") + strId + _T("\" href=\"fonts/") + strDstName + _T("\" media-type=\"application/x-font-ttf\"/>"));
strCssMem += strDstName;
strCssMem += _T(");}\n");
strCSS += strCssMem;
}
}
protected:
void Grow()
{
if (NULL == m_pFonts)
{
m_pFonts = new NSStructures::CFont[m_lSize];
return;
}
NSStructures::CFont* pNewBuffer = new NSStructures::CFont[m_lSize * 2];
for (LONG i = 0; i < m_lSize; ++i)
{
pNewBuffer[i] = m_pFonts[i];
}
RELEASEARRAYOBJECTS(m_pFonts);
m_pFonts = pNewBuffer;
m_lSize *= 2;
}
};
}
\ No newline at end of file
#pragma once
#include "ap_AggPlusEnums.h"
#include "ap_AggPlusTypes.h"
#include "agg_trans_affine.h"
namespace NSCommon
{
class CMatrix
{
public:
CMatrix(double m11, double m12, double m21, double m22, double dx, double dy) : m_agg_mtx(m11, m12, m21, m22, dx, dy)
{
}
CMatrix() : m_agg_mtx()
{
}
~CMatrix()
{
}
void Translate(double offsetX, double offsetY, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend)
{
if (order == Aggplus::MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
}
}
void Scale(double scaleX, double scaleY, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend)
{
if (order == Aggplus::MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
}
}
void Shear(double shearX, double shearY, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend)
{
if (order == Aggplus::MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
}
}
void TransformPoint(double& x, double& y)
{
m_agg_mtx.transform(&x, &y);
}
void Rotate(double angle, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend)
{
if (order == Aggplus::MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
}
void RotateAt(double angle, double x, double y, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend)
{
Translate(-x, -y, order);
if (order == Aggplus::MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
Translate(x, y, order);
}
void Multiply(const CMatrix* matrix, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend)
{
if (order == Aggplus::MatrixOrderPrepend)
{
m_agg_mtx.premultiply(matrix->m_agg_mtx);
}
else
{
m_agg_mtx.multiply(matrix->m_agg_mtx);
}
}
double OffsetX() const
{
double M[6]; m_agg_mtx.store_to(M);
return (M[4]);
}
double OffsetY() const
{
double M[6]; m_agg_mtx.store_to(M);
return (M[5]);
}
bool GetElements(float* m) const
{
double M[6]; m_agg_mtx.store_to(M);
m[0]=(float)M[0];
m[1]=(float)M[1];
m[2]=(float)M[2];
m[3]=(float)M[3];
m[4]=(float)M[4];
m[5]=(float)M[5];
return true;
}
bool GetElements(double* m) const
{
m_agg_mtx.store_to(m);
return true;
}
void Reset()
{
m_agg_mtx.reset();
}
const CMatrix& operator=(const CMatrix& Src)
{
m_agg_mtx = Src.m_agg_mtx;
return *this;
}
bool Invert()
{
double d = m_agg_mtx.determinant();
if (0.0001 >= abs(d))
return false;
m_agg_mtx.invert();
return true;
}
//Temp
//Used in X_BrushLinearGradient constructor
double z_Rotation() const
{
return agg::rad2deg(m_agg_mtx.rotation());
}
__forceinline void SetElements(const double& m11, const double& m12, const double& m21, const double& m22, const double& dx, const double& dy)
{
m_agg_mtx.sx = m11;
m_agg_mtx.shy = m12;
m_agg_mtx.shx = m21;
m_agg_mtx.sy = m22;
m_agg_mtx.tx = dx;
m_agg_mtx.ty = dy;
}
public:
agg::trans_affine m_agg_mtx;
};
}
\ No newline at end of file
This diff is collapsed.
//
// Affine transformations
//
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "agg_trans_affine.h"
namespace agg
{
//------------------------------------------------------------------------
const trans_affine& trans_affine::parl_to_parl(const double* src,
const double* dst)
{
sx = src[2] - src[0];
shy = src[3] - src[1];
shx = src[4] - src[0];
sy = src[5] - src[1];
tx = src[0];
ty = src[1];
invert();
multiply(trans_affine(dst[2] - dst[0], dst[3] - dst[1],
dst[4] - dst[0], dst[5] - dst[1],
dst[0], dst[1]));
return *this;
}
//------------------------------------------------------------------------
const trans_affine& trans_affine::rect_to_parl(double x1, double y1,
double x2, double y2,
const double* parl)
{
double src[6];
src[0] = x1; src[1] = y1;
src[2] = x2; src[3] = y1;
src[4] = x2; src[5] = y2;
parl_to_parl(src, parl);
return *this;
}
//------------------------------------------------------------------------
const trans_affine& trans_affine::parl_to_rect(const double* parl,
double x1, double y1,
double x2, double y2)
{
double dst[6];
dst[0] = x1; dst[1] = y1;
dst[2] = x2; dst[3] = y1;
dst[4] = x2; dst[5] = y2;
parl_to_parl(parl, dst);
return *this;
}
//------------------------------------------------------------------------
const trans_affine& trans_affine::multiply(const trans_affine& m)
{
double t0 = sx * m.sx + shy * m.shx;
double t2 = shx * m.sx + sy * m.shx;
double t4 = tx * m.sx + ty * m.shx + m.tx;
shy = sx * m.shy + shy * m.sy;
sy = shx * m.shy + sy * m.sy;
ty = tx * m.shy + ty * m.sy + m.ty;
sx = t0;
shx = t2;
tx = t4;
return *this;
}
//------------------------------------------------------------------------
const trans_affine& trans_affine::invert()
{
double d = determinant_reciprocal();
double t0 = sy * d;
sy = sx * d;
shy = -shy * d;
shx = -shx * d;
double t4 = -tx * t0 - ty * shx;
ty = -tx * shy - ty * sy;
sx = t0;
tx = t4;
return *this;
}
//------------------------------------------------------------------------
const trans_affine& trans_affine::flip_x()
{
sx = -sx;
shy = -shy;
tx = -tx;
return *this;
}
//------------------------------------------------------------------------
const trans_affine& trans_affine::flip_y()
{
shx = -shx;
sy = -sy;
ty = -ty;
return *this;
}
//------------------------------------------------------------------------
const trans_affine& trans_affine::reset()
{
sx = sy = 1.0;
shy = shx = tx = ty = 0.0;
return *this;
}
//------------------------------------------------------------------------
bool trans_affine::is_identity(double epsilon) const
{
return is_equal_eps(sx, 1.0, epsilon) &&
is_equal_eps(shy, 0.0, epsilon) &&
is_equal_eps(shx, 0.0, epsilon) &&
is_equal_eps(sy, 1.0, epsilon) &&
is_equal_eps(tx, 0.0, epsilon) &&
is_equal_eps(ty, 0.0, epsilon);
}
//------------------------------------------------------------------------
bool trans_affine::is_valid(double epsilon) const
{
return fabs(sx) > epsilon && fabs(sy) > epsilon;
}
//------------------------------------------------------------------------
bool trans_affine::is_equal(const trans_affine& m, double epsilon) const
{
return is_equal_eps(sx, m.sx, epsilon) &&
is_equal_eps(shy, m.shy, epsilon) &&
is_equal_eps(shx, m.shx, epsilon) &&
is_equal_eps(sy, m.sy, epsilon) &&
is_equal_eps(tx, m.tx, epsilon) &&
is_equal_eps(ty, m.ty, epsilon);
}
//------------------------------------------------------------------------
double trans_affine::rotation() const
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 0.0;
transform(&x1, &y1);
transform(&x2, &y2);
return atan2(y2-y1, x2-x1);
}
//------------------------------------------------------------------------
void trans_affine::translation(double* dx, double* dy) const
{
*dx = tx;
*dy = ty;
}
//------------------------------------------------------------------------
void trans_affine::scaling(double* x, double* y) const
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 1.0;
trans_affine t(*this);
t *= trans_affine_rotation(-rotation());
t.transform(&x1, &y1);
t.transform(&x2, &y2);
*x = x2 - x1;
*y = y2 - y1;
}
}
This diff is collapsed.
This diff is collapsed.
#ifndef _AGGPLUSTYPES_H
#define _AGGPLUSTYPES_H
#include "windows.h"
namespace Aggplus
{
typedef float REAL;
typedef int INT;
typedef unsigned int *PUINT;
typedef unsigned long ARGB;
typedef INT PixelFormat;
#define REAL_MAX FLT_MAX
#define REAL_MIN FLT_MIN
#define REAL_TOLERANCE (FLT_MIN * 100)
#define REAL_EPSILON 1.192092896e-07F /* FLT_EPSILON */
//--------------------------------------------------------------------------
// Status return values from AGG+ methods
//--------------------------------------------------------------------------
enum Status
{
Ok = 0,
GenericError = 1,
InvalidParameter = 2,
OutOfMemory = 3,
ObjectBusy = 4,
InsufficientBuffer = 5,
NotImplemented = 6,
Win32Error = 7,
WrongState = 8,
Aborted = 9,
FileNotFound = 10,
ValueOverflow = 11,
AccessDenied = 12,
UnknownImageFormat = 13,
FontFamilyNotFound = 14,
FontStyleNotFound = 15,
NotTrueTypeFont = 16,
UnsupportedGdiplusVersion = 17,
AggplusNotInitialized = 18,
PropertyNotFound = 19,
PropertyNotSupported = 20
};
class SizeF
{
public:
SizeF() : Width(0.0f), Height(0.0f) { }
SizeF(const SizeF& size) : Width(size.Width), Height(size.Height) { }
SizeF(REAL width, REAL height) : Width(width), Height(height) { }
SizeF operator+(const SizeF& sz) const { return SizeF(Width+sz.Width, Height+sz.Height); }
SizeF operator-(const SizeF& sz) const { return SizeF(Width-sz.Width, Height-sz.Height); }
BOOL Equals(const SizeF& sz) const { return((Width == sz.Width) && (Height == sz.Height)); }
BOOL Empty() const { return(Width == 0.0f && Height == 0.0f); }
public:
REAL Width, Height;
};
class PointF
{
public:
PointF() : X(0.0f), Y(0.0f) { }
PointF(const PointF &point) : X(point.X), Y(point.Y) { }
PointF(const SizeF &size) : X(size.Width), Y(size.Height) { }
PointF(REAL x, REAL y) : X(x), Y(y) { }
//~PointF() { }
BOOL Equals(const PointF& point) const { return(X==point.X && Y==point.Y); }
PointF operator+(const PointF& point) const { return PointF(X + point.X, Y + point.Y); }
PointF operator-(const PointF& point) const { return PointF(X - point.X, Y - point.Y); }
public:
REAL X, Y;
};
class RectF
{
public:
RectF() : X(0.0f), Y(0.0f), Width(0.0f), Height(0.0f) { }
RectF(REAL x, REAL y, REAL width, REAL height) : X(x), Y(y), Width(width), Height(height) { }
RectF(RECT rct)
{ X = REAL(rct.left); Y = REAL(rct.top); Width = REAL(rct.right-rct.left); Height=REAL(rct.bottom-rct.top);}
RectF(const PointF& location, const SizeF& size) : X(location.X), Y(location.Y), Width(size.Width), Height(size.Height) { }
RectF* Clone() const { return new RectF(X, Y, Width, Height); }
void GetLocation(PointF* point) const { point->X = X; point->Y = Y; }
void GetSize(SizeF* size) const { size->Width = Width; size->Height = Height; }
void GetBounds(RectF* rect) const { rect->X = X; rect->Y = Y; rect->Width = Width; rect->Height = Height; }
REAL GetLeft() const { return X; }
REAL GetTop() const { return Y; }
REAL GetRight() const { return X+Width; }
REAL GetBottom() const { return Y+Height; }
BOOL IsEmptyArea() const { return (Width <= REAL_EPSILON) || (Height <= REAL_EPSILON); }
BOOL Equals(const RectF & rect) const
{
return X == rect.X && Y == rect.Y &&
Width == rect.Width && Height == rect.Height;
}
BOOL Contains(REAL x, REAL y) const
{
return x >= X && x < X+Width &&
y >= Y && y < Y+Height;
}
BOOL Contains(const PointF& pt) const { return Contains(pt.X, pt.Y); }
BOOL Contains(const RectF& rect) const
{
return (X <= rect.X) && (rect.GetRight() <= GetRight()) &&
(Y <= rect.Y) && (rect.GetBottom() <= GetBottom());
}
void Inflate(REAL dx, REAL dy) { X -= dx; Y -= dy; Width += 2*dx; Height += 2*dy; }
void Inflate(const PointF& point) { Inflate(point.X, point.Y); }
BOOL Intersect(const RectF& rect) { return Intersect(*this, *this, rect); }
static BOOL Intersect(RectF& c, const RectF& a, const RectF& b)
{
REAL right = min(a.GetRight(), b.GetRight());
REAL bottom = min(a.GetBottom(), b.GetBottom());
REAL left = max(a.GetLeft(), b.GetLeft());
REAL top = max(a.GetTop(), b.GetTop());
c.X = left;
c.Y = top;
c.Width = right - left;
c.Height = bottom - top;
return !c.IsEmptyArea();
}
BOOL IntersectsWith(const RectF& rect) const
{
return (GetLeft() < rect.GetRight() &&
GetTop() < rect.GetBottom() &&
GetRight() > rect.GetLeft() &&
GetBottom() > rect.GetTop());
}
static BOOL Union(RectF& c, const RectF& a, const RectF& b)
{
REAL right = max(a.GetRight(), b.GetRight());
REAL bottom = max(a.GetBottom(), b.GetBottom());
REAL left = min(a.GetLeft(), b.GetLeft());
REAL top = min(a.GetTop(), b.GetTop());
c.X = left;
c.Y = top;
c.Width = right - left;
c.Height = bottom - top;
return !c.IsEmptyArea();
}
void Offset(const PointF& point) { Offset(point.X, point.Y); }
void Offset(REAL dx, REAL dy) { X += dx; Y += dy; }
public:
REAL X, Y, Width, Height;
};
} //namespace Aggplus
#endif // _AGGPLUSTYPES_H
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#pragma once
#include "LogicPagePDF.h"
#include "LogicPageDOCX.h"
\ No newline at end of file
This diff is collapsed.
Binary files a/AVSEBOOKWriter/Logic/LogicPagePDF.h and /dev/null differ
#pragma once
#include "../Common/FontManager.h"
namespace NSEBook
{
using namespace NSCommon;
class ILogicItem
{
public:
enum ELogicItemType
{
elitTextLine = 0,
elitTable = 1,
elitGraphic = 2,
elitTextParagraph = 3
};
ELogicItemType m_eType;
CDoubleRect m_rcBounds;
bool m_bIsPageBreakAfter;
public:
ILogicItem()
{
m_eType = elitTextLine;
m_bIsPageBreakAfter = false;
}
virtual ~ILogicItem()
{
}
virtual double GetPositionY() = 0;
virtual double GetPositionX() = 0;
};
const long g_lNewNoJustifySpace = 5;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#pragma once
#include "../stdafx.h"
#include <time.h>
namespace NSCommon
{
class CTempManager
{
public:
CString m_strTempDirectory;
CString m_strTempImagesDirectory;
public:
CTempManager()
{
m_strTempDirectory = _T("");
m_strTempImagesDirectory = _T("");
}
~CTempManager()
{
}
public:
void InitTempDirectory()
{
if (_T("") == m_strTempDirectory)
{
CStringW sTempPath;
GetTempPathW(4096, sTempPath.GetBuffer(4096));
sTempPath.ReleaseBuffer();
m_strTempDirectory = sTempPath;
}
srand( (unsigned)time(NULL) );
CString sNewDirName;
do
{
int nRandom = rand() % 100000000;
CString sRandName;
sRandName.Format( _T("AVSEbookTemp%d"), nRandom );
sNewDirName = m_strTempDirectory + _T("\\") + sRandName;
}
while( INVALID_FILE_ATTRIBUTES != ::GetFileAttributes( sNewDirName ) );
m_strTempDirectory = sNewDirName;
m_strTempImagesDirectory = m_strTempDirectory + _T("\\media");
::CreateDirectory(m_strTempDirectory, NULL);
::CreateDirectory(m_strTempImagesDirectory, NULL);
}
void ZipDirectory(CString strDstFile)
{
AVSOfficeUtils::IOfficeUtils* pOfficeUtils = NULL;
if (S_OK != CoCreateInstance(__uuidof(AVSOfficeUtils::COfficeUtils), NULL, CLSCTX_INPROC_SERVER, __uuidof(AVSOfficeUtils::IOfficeUtils),(void**)&pOfficeUtils))
return;
BSTR bstrSrcPath = m_strTempDirectory.AllocSysString();
BSTR bstrDstPath = strDstFile.AllocSysString();
pOfficeUtils->CompressFileOrDirectory( bstrSrcPath, bstrDstPath, -1 );
SysFreeString(bstrSrcPath);
SysFreeString(bstrDstPath);
RELEASEINTERFACE(pOfficeUtils);
}
void RemoveTempDirectory()
{
if ( _T("") == m_strTempDirectory )
return;
SHFILEOPSTRUCTW shfos;
ZeroMemory(&shfos, sizeof(shfos));
shfos.wFunc = FO_DELETE;
CStringW _local = m_strTempDirectory + L"*.*";
_local.AppendChar(0);
_local.AppendChar(0);
shfos.pFrom = _local.GetString();
shfos.fFlags = FOF_SILENT + FOF_NOCONFIRMATION;
SHFileOperationW(&shfos);
RemoveDirectory(m_strTempDirectory);
m_strTempDirectory = _T("");
}
};
}
\ No newline at end of file
This diff is collapsed.
#pragma once
#include "Writer.h"
namespace NSEBook
{
class CWriter_Docx
{
public:
void CreateDocument(CWriter* pWriter)
{
}
void CloseFile(CString strDstFile, CWriter* pWriter)
{
}
};
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AVSEBOOKWriter.rc
//
#define IDS_PROJNAME 100
#define IDR_AVSEBOOKWRITER 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 209
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif
// stdafx.cpp : source file that includes just the standard includes
// AVSEBOOKWriter.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
\ No newline at end of file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
#define DOCX_RENDERER
#define _USE_XMLLITE_READER_
#import "..\..\..\Redist\AVSGraphics.dll" named_guids raw_interfaces_only rename_namespace("AVSGraphics")
#import "..\..\..\Redist\AVSMediaCore3.dll" named_guids raw_interfaces_only rename_namespace("MediaCore"), exclude("tagRECT")
#import "..\..\..\Redist\AVSMediaFormatSettings3.dll" named_guids raw_interfaces_only rename_namespace("MediaFormat"), exclude("tagRECT")
#import "..\..\..\Redist\AVSImageStudio3.dll" named_guids raw_interfaces_only rename_namespace("ImageStudio")
#import "..\..\..\Redist\AVSOfficeStudio\AVSOfficeUtils.dll" named_guids rename_namespace("AVSOfficeUtils"), raw_interfaces_only
#import "..\..\..\Redist\AVSOfficeStudio\AVSOfficeHtmlFile.dll" raw_interfaces_only rename_namespace("OfficeHtmlFile")
#import "..\..\..\Redist\AVSOfficeStudio\AVSOfficeTxtFile.dll" raw_interfaces_only rename_namespace("OfficeTxtFile")
\ No newline at end of file
#pragma once
//1
//0
//0
//19
#define INTVER 1,0,0,19
#define STRVER "1,0,0,19\0"
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