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

(2.0.0.10) ASC version full

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52639 954022d7-b5bf-4e40-9824-e11837661b57
parent 18312d0a
//
// 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;
}
}
#pragma once
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <math.h>
namespace agg
{
const double affine_epsilon = 1e-14;
//------------------------------------------------------------is_equal_eps
template<class T> inline bool is_equal_eps(T v1, T v2, T epsilon)
{
return fabs(v1 - v2) <= double(epsilon);
}
//------------------------------------------------------------------deg2rad
inline double deg2rad(double deg)
{
return deg * M_PI / 180.0;
}
//------------------------------------------------------------------rad2deg
inline double rad2deg(double rad)
{
return rad * 180.0 / M_PI;
}
//============================================================trans_affine
//
// See Implementation agg_trans_affine.cpp
//
// Affine transformation are linear transformations in Cartesian coordinates
// (strictly speaking not only in Cartesian, but for the beginning we will
// think so). They are rotation, scaling, translation and skewing.
// After any affine transformation a line segment remains a line segment
// and it will never become a curve.
//
// There will be no math about matrix calculations, since it has been
// described many times. Ask yourself a very simple question:
// "why do we need to understand and use some matrix stuff instead of just
// rotating, scaling and so on". The answers are:
//
// 1. Any combination of transformations can be done by only 4 multiplications
// and 4 additions in floating point.
// 2. One matrix transformation is equivalent to the number of consecutive
// discrete transformations, i.e. the matrix "accumulates" all transformations
// in the order of their settings. Suppose we have 4 transformations:
// * rotate by 30 degrees,
// * scale X to 2.0,
// * scale Y to 1.5,
// * move to (100, 100).
// The result will depend on the order of these transformations,
// and the advantage of matrix is that the sequence of discret calls:
// rotate(30), scaleX(2.0), scaleY(1.5), move(100,100)
// will have exactly the same result as the following matrix transformations:
//
// affine_matrix m;
// m *= rotate_matrix(30);
// m *= scaleX_matrix(2.0);
// m *= scaleY_matrix(1.5);
// m *= move_matrix(100,100);
//
// m.transform_my_point_at_last(x, y);
//
// What is the good of it? In real life we will set-up the matrix only once
// and then transform many points, let alone the convenience to set any
// combination of transformations.
//
// So, how to use it? Very easy - literally as it's shown above. Not quite,
// let us write a correct example:
//
// agg::trans_affine m;
// m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0);
// m *= agg::trans_affine_scaling(2.0, 1.5);
// m *= agg::trans_affine_translation(100.0, 100.0);
// m.transform(&x, &y);
//
// The affine matrix is all you need to perform any linear transformation,
// but all transformations have origin point (0,0). It means that we need to
// use 2 translations if we want to rotate someting around (100,100):
//
// m *= agg::trans_affine_translation(-100.0, -100.0); // move to (0,0)
// m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0); // rotate
// m *= agg::trans_affine_translation(100.0, 100.0); // move back to (100,100)
//----------------------------------------------------------------------
struct trans_affine
{
double sx, shy, shx, sy, tx, ty;
//------------------------------------------ Construction
// Identity matrix
trans_affine() :
sx(1.0), shy(0.0), shx(0.0), sy(1.0), tx(0.0), ty(0.0)
{}
// Custom matrix. Usually used in derived classes
trans_affine(double v0, double v1, double v2,
double v3, double v4, double v5) :
sx(v0), shy(v1), shx(v2), sy(v3), tx(v4), ty(v5)
{}
// Custom matrix from m[6]
explicit trans_affine(const double* m) :
sx(m[0]), shy(m[1]), shx(m[2]), sy(m[3]), tx(m[4]), ty(m[5])
{}
// Rectangle to a parallelogram.
trans_affine(double x1, double y1, double x2, double y2,
const double* parl)
{
rect_to_parl(x1, y1, x2, y2, parl);
}
// Parallelogram to a rectangle.
trans_affine(const double* parl,
double x1, double y1, double x2, double y2)
{
parl_to_rect(parl, x1, y1, x2, y2);
}
// Arbitrary parallelogram transformation.
trans_affine(const double* src, const double* dst)
{
parl_to_parl(src, dst);
}
//---------------------------------- Parellelogram transformations
// transform a parallelogram to another one. Src and dst are
// pointers to arrays of three points (double[6], x1,y1,...) that
// identify three corners of the parallelograms assuming implicit
// fourth point. The arguments are arrays of double[6] mapped
// to x1,y1, x2,y2, x3,y3 where the coordinates are:
// *-----------------*
// / (x3,y3)/
// / /
// /(x1,y1) (x2,y2)/
// *-----------------*
const trans_affine& parl_to_parl(const double* src,
const double* dst);
const trans_affine& rect_to_parl(double x1, double y1,
double x2, double y2,
const double* parl);
const trans_affine& parl_to_rect(const double* parl,
double x1, double y1,
double x2, double y2);
//------------------------------------------ Operations
// Reset - load an identity matrix
const trans_affine& reset();
// Direct transformations operations
const trans_affine& translate(double x, double y);
const trans_affine& rotate(double a);
const trans_affine& scale(double s);
const trans_affine& scale(double x, double y);
// Multiply matrix to another one
const trans_affine& multiply(const trans_affine& m);
// Multiply "m" to "this" and assign the result to "this"
const trans_affine& premultiply(const trans_affine& m);
// Multiply matrix to inverse of another one
const trans_affine& multiply_inv(const trans_affine& m);
// Multiply inverse of "m" to "this" and assign the result to "this"
const trans_affine& premultiply_inv(const trans_affine& m);
// Invert matrix. Do not try to invert degenerate matrices,
// there's no check for validity. If you set scale to 0 and
// then try to invert matrix, expect unpredictable result.
const trans_affine& invert();
// Mirroring around X
const trans_affine& flip_x();
// Mirroring around Y
const trans_affine& flip_y();
//------------------------------------------- Load/Store
// Store matrix to an array [6] of double
void store_to(double* m) const
{
*m++ = sx; *m++ = shy; *m++ = shx; *m++ = sy; *m++ = tx; *m++ = ty;
}
// Load matrix from an array [6] of double
const trans_affine& load_from(const double* m)
{
sx = *m++; shy = *m++; shx = *m++; sy = *m++; tx = *m++; ty = *m++;
return *this;
}
//------------------------------------------- Operators
// Multiply the matrix by another one
const trans_affine& operator *= (const trans_affine& m)
{
return multiply(m);
}
// Multiply the matrix by inverse of another one
const trans_affine& operator /= (const trans_affine& m)
{
return multiply_inv(m);
}
// Multiply the matrix by another one and return
// the result in a separete matrix.
trans_affine operator * (const trans_affine& m)
{
return trans_affine(*this).multiply(m);
}
// Multiply the matrix by inverse of another one
// and return the result in a separete matrix.
trans_affine operator / (const trans_affine& m)
{
return trans_affine(*this).multiply_inv(m);
}
// Calculate and return the inverse matrix
trans_affine operator ~ () const
{
trans_affine ret = *this;
return ret.invert();
}
// Equal operator with default epsilon
bool operator == (const trans_affine& m) const
{
return is_equal(m, affine_epsilon);
}
// Not Equal operator with default epsilon
bool operator != (const trans_affine& m) const
{
return !is_equal(m, affine_epsilon);
}
//-------------------------------------------- Transformations
// Direct transformation of x and y
void transform(double* x, double* y) const;
// Direct transformation of x and y, 2x2 matrix only, no translation
void transform_2x2(double* x, double* y) const;
// Inverse transformation of x and y. It works slower than the
// direct transformation. For massive operations it's better to
// invert() the matrix and then use direct transformations.
void inverse_transform(double* x, double* y) const;
//-------------------------------------------- Auxiliary
// Calculate the determinant of matrix
double determinant() const
{
return sx * sy - shy * shx;
}
// Calculate the reciprocal of the determinant
double determinant_reciprocal() const
{
return 1.0 / (sx * sy - shy * shx);
}
// Get the average scale (by X and Y).
// Basically used to calculate the approximation_scale when
// decomposinting curves into line segments.
double scale() const;
// Check to see if the matrix is not degenerate
bool is_valid(double epsilon = affine_epsilon) const;
// Check to see if it's an identity matrix
bool is_identity(double epsilon = affine_epsilon) const;
// Check to see if two matrices are equal
bool is_equal(const trans_affine& m, double epsilon = affine_epsilon) const;
// Determine the major parameters. Use with caution considering
// possible degenerate cases.
double rotation() const;
void translation(double* dx, double* dy) const;
void scaling(double* x, double* y) const;
void scaling_abs(double* x, double* y) const;
};
//------------------------------------------------------------------------
inline void trans_affine::transform(double* x, double* y) const
{
register double tmp = *x;
*x = tmp * sx + *y * shx + tx;
*y = tmp * shy + *y * sy + ty;
}
//------------------------------------------------------------------------
inline void trans_affine::transform_2x2(double* x, double* y) const
{
register double tmp = *x;
*x = tmp * sx + *y * shx;
*y = tmp * shy + *y * sy;
}
//------------------------------------------------------------------------
inline void trans_affine::inverse_transform(double* x, double* y) const
{
register double d = determinant_reciprocal();
register double a = (*x - tx) * d;
register double b = (*y - ty) * d;
*x = a * sy - b * shx;
*y = b * sx - a * shy;
}
//------------------------------------------------------------------------
inline double trans_affine::scale() const
{
double x = 0.707106781 * sx + 0.707106781 * shx;
double y = 0.707106781 * shy + 0.707106781 * sy;
return sqrt(x*x + y*y);
}
//------------------------------------------------------------------------
inline const trans_affine& trans_affine::translate(double x, double y)
{
tx += x;
ty += y;
return *this;
}
//------------------------------------------------------------------------
inline const trans_affine& trans_affine::rotate(double a)
{
double ca = cos(a);
double sa = sin(a);
double t0 = sx * ca - shy * sa;
double t2 = shx * ca - sy * sa;
double t4 = tx * ca - ty * sa;
shy = sx * sa + shy * ca;
sy = shx * sa + sy * ca;
ty = tx * sa + ty * ca;
sx = t0;
shx = t2;
tx = t4;
return *this;
}
//------------------------------------------------------------------------
inline const trans_affine& trans_affine::scale(double x, double y)
{
double mm0 = x; // Possible hint for the optimizer
double mm3 = y;
sx *= mm0;
shx *= mm0;
tx *= mm0;
shy *= mm3;
sy *= mm3;
ty *= mm3;
return *this;
}
//------------------------------------------------------------------------
inline const trans_affine& trans_affine::scale(double s)
{
double m = s; // Possible hint for the optimizer
sx *= m;
shx *= m;
tx *= m;
shy *= m;
sy *= m;
ty *= m;
return *this;
}
//------------------------------------------------------------------------
inline const trans_affine& trans_affine::premultiply(const trans_affine& m)
{
trans_affine t = m;
return *this = t.multiply(*this);
}
//------------------------------------------------------------------------
inline const trans_affine& trans_affine::multiply_inv(const trans_affine& m)
{
trans_affine t = m;
t.invert();
return multiply(t);
}
//------------------------------------------------------------------------
inline const trans_affine& trans_affine::premultiply_inv(const trans_affine& m)
{
trans_affine t = m;
t.invert();
return *this = t.multiply(*this);
}
//------------------------------------------------------------------------
inline void trans_affine::scaling_abs(double* x, double* y) const
{
// Used to calculate scaling coefficients in image resampling.
// When there is considerable shear this method gives us much
// better estimation than just sx, sy.
*x = sqrt(sx * sx + shx * shx);
*y = sqrt(shy * shy + sy * sy);
}
//====================================================trans_affine_rotation
// Rotation matrix. sin() and cos() are calculated twice for the same angle.
// There's no harm because the performance of sin()/cos() is very good on all
// modern processors. Besides, this operation is not going to be invoked too
// often.
class trans_affine_rotation : public trans_affine
{
public:
trans_affine_rotation(double a) :
trans_affine(cos(a), sin(a), -sin(a), cos(a), 0.0, 0.0)
{}
};
//====================================================trans_affine_scaling
// Scaling matrix. x, y - scale coefficients by X and Y respectively
class trans_affine_scaling : public trans_affine
{
public:
trans_affine_scaling(double x, double y) :
trans_affine(x, 0.0, 0.0, y, 0.0, 0.0)
{}
trans_affine_scaling(double s) :
trans_affine(s, 0.0, 0.0, s, 0.0, 0.0)
{}
};
//================================================trans_affine_translation
// Translation matrix
class trans_affine_translation : public trans_affine
{
public:
trans_affine_translation(double x, double y) :
trans_affine(1.0, 0.0, 0.0, 1.0, x, y)
{}
};
//====================================================trans_affine_skewing
// Sckewing (shear) matrix
class trans_affine_skewing : public trans_affine
{
public:
trans_affine_skewing(double x, double y) :
trans_affine(1.0, tan(y), tan(x), 1.0, 0.0, 0.0)
{}
};
//===============================================trans_affine_line_segment
// Rotate, Scale and Translate, associating 0...dist with line segment
// x1,y1,x2,y2
class trans_affine_line_segment : public trans_affine
{
public:
trans_affine_line_segment(double x1, double y1, double x2, double y2,
double dist)
{
double dx = x2 - x1;
double dy = y2 - y1;
if(dist > 0.0)
{
multiply(trans_affine_scaling(sqrt(dx * dx + dy * dy) / dist));
}
multiply(trans_affine_rotation(atan2(dy, dx)));
multiply(trans_affine_translation(x1, y1));
}
};
//============================================trans_affine_reflection_unit
// Reflection matrix. Reflect coordinates across the line through
// the origin containing the unit vector (ux, uy).
// Contributed by John Horigan
class trans_affine_reflection_unit : public trans_affine
{
public:
trans_affine_reflection_unit(double ux, double uy) :
trans_affine(2.0 * ux * ux - 1.0,
2.0 * ux * uy,
2.0 * ux * uy,
2.0 * uy * uy - 1.0,
0.0, 0.0)
{}
};
//=================================================trans_affine_reflection
// Reflection matrix. Reflect coordinates across the line through
// the origin at the angle a or containing the non-unit vector (x, y).
// Contributed by John Horigan
class trans_affine_reflection : public trans_affine_reflection_unit
{
public:
trans_affine_reflection(double a) :
trans_affine_reflection_unit(cos(a), sin(a))
{}
trans_affine_reflection(double x, double y) :
trans_affine_reflection_unit(x / sqrt(x * x + y * y), y / sqrt(x * x + y * y))
{}
};
}
\ No newline at end of file
//
//
//////////////////////////////////////////////////////////////////////
#ifndef _AGGPLUSENUMS_H
#define _AGGPLUSENUMS_H
#include "ap_AggPlusTypes.h"
//#define __cplusplus
namespace Aggplus
{
#define PixelFormatIndexed 0x00010000 // Indexes into a palette
#define PixelFormatGDI 0x00020000 // Is a GDI-supported format
#define PixelFormatAlpha 0x00040000 // Has an alpha component
#define PixelFormatPAlpha 0x00080000 // Pre-multiplied alpha
#define PixelFormatExtended 0x00100000 // Extended color 16 bits/channel
#define PixelFormatCanonical 0x00200000
#define PixelFormatUndefined 0
#define PixelFormatDontCare 0
#define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended)
#define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI)
#define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI)
#define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
#define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI)
#define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI)
#define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
#define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
#define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended)
#define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
#define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
#define PixelFormatMax 15
//--------------------------------------------------------------------------
// Matrix Order
//--------------------------------------------------------------------------
enum MatrixOrder
{
MatrixOrderPrepend = 0,
MatrixOrderAppend = 1
};
//--------------------------------------------------------------------------
// Dash style constants
//--------------------------------------------------------------------------
enum DashStyle
{
DashStyleSolid, // 0
DashStyleDash, // 1
DashStyleDot, // 2
DashStyleDashDot, // 3
DashStyleDashDotDot, // 4
DashStyleCustom // 5
};
//--------------------------------------------------------------------------
// Line join constants
//--------------------------------------------------------------------------
enum LineJoin
{
LineJoinMiter = 0,
LineJoinBevel = 1,
LineJoinRound = 2,
LineJoinMiterClipped = 3
};
//--------------------------------------------------------------------------
// Line cap constants
//--------------------------------------------------------------------------
enum LineCap
{
LineCapFlat = 0,
LineCapSquare = 1,
LineCapRound = 2,
LineCapTriangle = 3,
LineCapNoAnchor = 0x10, // corresponds to flat cap
LineCapSquareAnchor = 0x11, // corresponds to square cap
LineCapRoundAnchor = 0x12, // corresponds to round cap
LineCapDiamondAnchor = 0x13, // corresponds to triangle cap
LineCapArrowAnchor = 0x14, // no correspondence
LineCapCustom = 0xff, // custom cap
LineCapAnchorMask = 0xf0 // mask to check for anchor or not.
};
//--------------------------------------------------------------------------
// Brush types
//--------------------------------------------------------------------------
enum BrushType
{
BrushTypeSolidColor = 0,
BrushTypeHatchFill = 1,
BrushTypeTextureFill = 2,
BrushTypePathGradient = 3,
BrushTypeLinearGradient = 4
};
//--------------------------------------------------------------------------
// Various wrap modes for brushes
//--------------------------------------------------------------------------
enum WrapMode
{
WrapModeTile, // 0
WrapModeTileFlipX, // 1
WrapModeTileFlipY, // 2
WrapModeTileFlipXY, // 3
WrapModeClamp // 4
};
//--------------------------------------------------------------------------
// FontStyle: face types and common styles
//--------------------------------------------------------------------------
enum FontStyle
{
FontStyleRegular = 0,
FontStyleBold = 1,
FontStyleItalic = 2,
FontStyleBoldItalic = 3,
FontStyleUnderline = 4,
FontStyleStrikeout = 8
};
//---------------------------------------------------------------------------
// String alignment flags
//---------------------------------------------------------------------------
enum StringAlignment
{
// Left edge for left-to-right text,
// right for right-to-left text,
// and top for vertical
StringAlignmentNear = 0,
StringAlignmentCenter = 1,
StringAlignmentFar = 2
};
//############## Not implemented-Used
//--------------------------------------------------------------------------
// Unit constants
//--------------------------------------------------------------------------
enum Unit
{
UnitWorld, // 0 -- World coordinate (non-physical unit)
UnitDisplay, // 1 -- Variable -- for PageTransform only
UnitPixel, // 2 -- Each unit is one device pixel.
UnitPoint, // 3 -- Each unit is a printer's point, or 1/72 inch.
UnitInch, // 4 -- Each unit is 1 inch.
UnitDocument, // 5 -- Each unit is 1/300 inch.
UnitMillimeter // 6 -- Each unit is 1 millimeter.
};
//---------------------------------------------------------------------------
// Text Rendering Hint
//---------------------------------------------------------------------------
enum TextRenderingHint
{
TextRenderingHintSystemDefault = 0, // Glyph with system default rendering hint
TextRenderingHintSingleBitPerPixelGridFit, // Glyph bitmap with hinting
TextRenderingHintSingleBitPerPixel, // Glyph bitmap without hinting
TextRenderingHintAntiAliasGridFit, // Glyph anti-alias bitmap with hinting
TextRenderingHintAntiAlias, // Glyph anti-alias bitmap without hinting
TextRenderingHintClearTypeGridFit // Glyph CT bitmap with hinting
};
//--------------------------------------------------------------------------
// Quality mode constants
//--------------------------------------------------------------------------
enum QualityMode
{
QualityModeInvalid = -1,
QualityModeDefault = 0,
QualityModeLow = 1, // Best performance
QualityModeHigh = 2 // Best rendering quality
};
//--------------------------------------------------------------------------
// Alpha Compositing mode constants
//--------------------------------------------------------------------------
enum CompositingMode
{
CompositingModeSourceOver, // 0
CompositingModeSourceCopy // 1
};
//--------------------------------------------------------------------------
// Alpha Compositing quality constants
//--------------------------------------------------------------------------
enum CompositingQuality
{
CompositingQualityInvalid = QualityModeInvalid,
CompositingQualityDefault = QualityModeDefault,
CompositingQualityHighSpeed = QualityModeLow,
CompositingQualityHighQuality = QualityModeHigh,
CompositingQualityGammaCorrected,
CompositingQualityAssumeLinear
};
//---------------------------------------------------------------------------
// Smoothing Mode
//---------------------------------------------------------------------------
enum SmoothingMode
{
SmoothingModeInvalid = QualityModeInvalid,
SmoothingModeDefault = QualityModeDefault,
SmoothingModeHighSpeed = QualityModeLow,
SmoothingModeHighQuality = QualityModeHigh,
SmoothingModeNone,
SmoothingModeAntiAlias
};
//--------------------------------------------------------------------------
// Interpolation modes
//--------------------------------------------------------------------------
enum InterpolationMode
{
InterpolationModeInvalid = QualityModeInvalid,
InterpolationModeDefault = QualityModeDefault,
InterpolationModeLowQuality = QualityModeLow,
InterpolationModeHighQuality = QualityModeHigh,
InterpolationModeBilinear,
InterpolationModeBicubic,
InterpolationModeNearestNeighbor,
InterpolationModeHighQualityBilinear,
InterpolationModeHighQualityBicubic
};
enum StringFormatFlags
{
//not supp StringFormatFlagsDirectionRightToLeft = 0x00000001,
//not supp StringFormatFlagsDirectionVertical = 0x00000002,
//not supp StringFormatFlagsNoFitBlackBox = 0x00000004,
//not supp StringFormatFlagsDisplayFormatControl = 0x00000020,
//not supp StringFormatFlagsNoFontFallback = 0x00000400,
//not supp StringFormatFlagsMeasureTrailingSpaces = 0x00000800,
//not supp StringFormatFlagsNoWrap = 0x00001000,
StringFormatFlagsLineLimit = 0x00002000
//not supp StringFormatFlagsNoClip = 0x00004000
};
} //namespace Aggplus
#endif // !defined(_AGGPLUSENUMS_H)
#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
#pragma once
#include "ap_AggPlusEnums.h"
#include "ap_AggPlusTypes.h"
#include "agg_trans_affine.h"
namespace NSDocxRenderer
{
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
#pragma once
#include "../stdafx.h"
#include "../../Common/DocxFormat/Source/XML/XmlUtils.h"
#include "../../Common/ASCUtils.h"
#include "../../ASCImageStudio3\ASCGraphics\Interfaces\ASCRenderer.h"
#include "ap_aggplusenums.h"
#include <gdiplus.h>
// pen -----------------------------------------------------------
const long c_ag_LineCapFlat = 0;
const long c_ag_LineCapSquare = 1;
const long c_ag_LineCapTriangle = 3;
const long c_ag_LineCapNoAnchor = 16;
const long c_ag_LineCapSquareAnchor = 17;
const long c_ag_LineCapRoundAnchor = 18;
const long c_ag_LineCapDiamondAnchor = 19;
const long c_ag_LineCapArrowAnchor = 20;
const long c_ag_LineCapAnchorMask = 240;
const long c_ag_LineCapCustom = 255;
const long c_ag_DashCapFlat = 0;
const long c_ag_DashCapRound = 2;
const long c_ag_DashCapTriangle = 3;
const long c_ag_LineJoinMiter = 0;
const long c_ag_LineJoinBevel = 1;
const long c_ag_LineJoinRound = 2;
const long c_ag_LineJoinMiterClipped = 3;
const long c_ag_PenAlignmentCenter = 0;
const long c_ag_PenAlignmentInset = 1;
const long c_ag_PenAlignmentOutset = 2;
const long c_ag_PenAlignmentLeft = 3;
const long c_ag_PenAlignmentRight = 4;
// --------------------------------------------------------------
// brush --------------------------------------------------------
// old constants for brush type
const long c_BrushTypeSolid_ = 0;
const long c_BrushTypeHorizontal_ = 1;
const long c_BrushTypeVertical_ = 2;
const long c_BrushTypeDiagonal1_ = 3;
const long c_BrushTypeDiagonal2_ = 4;
const long c_BrushTypeCenter_ = 5;
const long c_BrushTypePathGradient1_ = 6;
const long c_BrushTypePathGradient2_ = 7;
const long c_BrushTypeTexture_ = 8;
const long c_BrushTypeHatch1_ = 9;
const long c_BrushTypeHatch53_ = 61;
const long c_BrushTypeGradient1_ = 62;
const long c_BrushTypeGradient6_ = 70;
const long c_BrushTypeSolid = 1000;
const long c_BrushTypeHorizontal = 2001;
const long c_BrushTypeVertical = 2002;
const long c_BrushTypeDiagonal1 = 2003;
const long c_BrushTypeDiagonal2 = 2004;
const long c_BrushTypeCenter = 2005;
const long c_BrushTypePathGradient1 = 2006;
const long c_BrushTypePathGradient2 = 2007;
const long c_BrushTypeCylinderHor = 2008;
const long c_BrushTypeCylinderVer = 2009;
const long c_BrushTypeTexture = 3008;
const long c_BrushTypeHatch1 = 4009;
const long c_BrushTypeHatch53 = 4061;
const long c_BrushTextureModeStretch = 0;
const long c_BrushTextureModeTile = 1;
const long c_BrushTextureModeTileCenter = 2;
// --------------------------------------------------------------
//using namespace Gdiplus;
namespace NSStructures
{
class CPen
{
public:
long Color;
long Alpha;
double Size;
byte DashStyle;
byte LineStartCap;
byte LineEndCap;
byte LineJoin;
double* DashPattern;
long Count;
double DashOffset;
LONG Align;
double MiterLimit;
public:
CString ToXmlString(CString strRootNodeName = _T("pen"), BOOL bAttributed = FALSE)
{
XmlUtils::CXmlWriter oXmlWriter;
if (!bAttributed)
{
oXmlWriter.WriteNodeBegin(strRootNodeName);
oXmlWriter.WriteNode(_T("color"), Color);
oXmlWriter.WriteNode(_T("alpha"), Alpha);
oXmlWriter.WriteNode(_T("size"), Size);
oXmlWriter.WriteNode(_T("style"), DashStyle);
oXmlWriter.WriteNode(_T("line-start-cap"), LineStartCap);
oXmlWriter.WriteNode(_T("line-end-cap"), LineEndCap);
oXmlWriter.WriteNode(_T("line-join"), LineJoin);
oXmlWriter.WriteNode(_T("dash-pattern-count"), Count);
oXmlWriter.WriteNodeBegin(_T("dash-pattern"));
if (DashPattern != NULL)
{
for (int i = 0; i < Count; ++i)
{
oXmlWriter.WriteNode(_T("dash"), DashPattern[i]);
}
}
oXmlWriter.WriteNodeEnd(_T("dash-pattern"));
oXmlWriter.WriteNode(_T("dash-offset"), DashOffset);
oXmlWriter.WriteNode(_T("alignment"), Align);
oXmlWriter.WriteNodeEnd(strRootNodeName);
}
else
{
oXmlWriter.WriteNodeBegin(strRootNodeName, TRUE);
ToXmlAttributes(oXmlWriter);
oXmlWriter.WriteNodeEnd(strRootNodeName, TRUE);
}
return oXmlWriter.GetXmlString();
}
void FromXmlString(CString& strXml)
{
XmlUtils::CXmlReader oXmlReader;
oXmlReader.SetXmlString(strXml);
oXmlReader.ReadRootNode();
FromXmlAttributes(oXmlReader);
}
void ToXmlAttributes(XmlUtils::CXmlWriter& oXmlWriter)
{
oXmlWriter.WriteAttribute(_T("color"), Color);
oXmlWriter.WriteAttribute(_T("alpha"), Alpha);
oXmlWriter.WriteAttribute(_T("size"), Size);
oXmlWriter.WriteAttribute(_T("style"), DashStyle);
oXmlWriter.WriteAttribute(_T("line-start-cap"), LineStartCap);
oXmlWriter.WriteAttribute(_T("line-end-cap"), LineEndCap);
oXmlWriter.WriteAttribute(_T("line-join"), LineJoin);
oXmlWriter.WriteAttribute(_T("dash-offset"), DashOffset);
oXmlWriter.WriteAttribute(_T("alignment"), Align);
}
void FromXmlAttributes(XmlUtils::CXmlReader& oXmlReader)
{
Color = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("alpha"), _T("0")));
Size = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("size"), _T("0")));
DashStyle = (byte)XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("style"), _T("0")));
LineStartCap = (byte)XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("line-start-cap"), _T("0")));
LineEndCap = (byte)XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("line-end-cap"), _T("0")));
LineJoin = (byte)XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("line-join"), _T("0")));
RELEASEARRAYOBJECTS(DashPattern);
Count = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("dash-pattern-count"), _T("0")));
if (Count != 0)
{
XmlUtils::CXmlNode oPatternNode;
oXmlReader.ReadNodeList(_T("dash-pattern"));
if (oPatternNode.FromXmlString(oXmlReader.ReadNodeXml(0)))
{
XmlUtils::CXmlNodes oDashNodes;
if (oPatternNode.GetNodes(_T("dash"), oDashNodes))
{
Count = oDashNodes.GetCount();
if (Count != 0)
{
DashPattern = new double[Count];
XmlUtils::CXmlNode oDashNode;
for (int i = 0; i < Count; ++i)
{
oDashNodes.GetAt(i, oDashNode);
DashPattern[i] = XmlUtils::GetDouble(oDashNode.GetText());
}
}
}
}
}
DashOffset = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("dash-offset"), _T("0")));
Align = XmlUtils::GetInteger(oXmlReader.ReadNodeAttribute(_T("alignment"), _T("0")));
}
void FromXmlNode(XmlUtils::CXmlNode& oXmlNode)
{
Color = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("alpha"), _T("0")));
Size = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("size"), _T("0")));
DashStyle = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("style"), _T("0")));
LineStartCap = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("line-start-cap"), _T("0")));
LineEndCap = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("line-end-cap"), _T("0")));
LineJoin = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("line-join"), _T("0")));
RELEASEARRAYOBJECTS(DashPattern);
Count = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("dash-pattern-count"), _T("0")));
if (Count != 0)
{
XmlUtils::CXmlNode oPatternNode;
if (oXmlNode.GetNode(_T("dash-pattern"), oPatternNode))
{
XmlUtils::CXmlNodes oDashNodes;
if (oPatternNode.GetNodes(_T("dash"), oDashNodes))
{
Count = oDashNodes.GetCount();
if (Count != 0)
{
DashPattern = new double[Count];
XmlUtils::CXmlNode oDashNode;
for (int i = 0; i < Count; ++i)
{
oDashNodes.GetAt(i, oDashNode);
DashPattern[i] = XmlUtils::GetDouble(oDashNode.GetText());
}
}
}
}
}
DashOffset = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("dash-offset"), _T("0")));
Align = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("alignment"), _T("0")));
}
void FromXmlNode2(XmlUtils::CXmlNode& oXmlNode)
{
Color = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-alpha"), _T("0")));
Size = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("pen-size"), _T("0")));
DashStyle = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-style"), _T("0")));
LineStartCap = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-line-start-cap"), _T("0")));
LineEndCap = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-line-end-cap"), _T("0")));
LineJoin = (byte)XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-line-join"), _T("0")));
RELEASEARRAYOBJECTS(DashPattern);
Count = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-dash-pattern-count"), _T("0")));
if (Count != 0)
{
XmlUtils::CXmlNode oPatternNode;
if (oXmlNode.GetNode(_T("dash-pattern"), oPatternNode))
{
XmlUtils::CXmlNodes oDashNodes;
if (oPatternNode.GetNodes(_T("dash"), oDashNodes))
{
Count = oDashNodes.GetCount();
if (Count != 0)
{
DashPattern = new double[Count];
XmlUtils::CXmlNode oDashNode;
for (int i = 0; i < Count; ++i)
{
oDashNodes.GetAt(i, oDashNode);
DashPattern[i] = XmlUtils::GetDouble(oDashNode.GetText());
}
}
}
}
}
DashOffset = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("pen-dash-offset"), _T("0")));
Align = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("pen-alignment"), _T("0")));
}
void GetDashPattern(double* arrDashPattern, long& nCount) const
{
if (nCount == Count)
{
for (int i = 0; i < Count; ++i)
{
arrDashPattern[i] = DashPattern[i];
}
}
}
void SetDashPattern(double* arrDashPattern, long nCount)
{
if ((arrDashPattern == NULL) || (nCount == 0))
{
Count = 0;
RELEASEARRAYOBJECTS(DashPattern);
}
else
{
if (Count != nCount)
{
Count = nCount;
RELEASEARRAYOBJECTS(DashPattern);
DashPattern = new double[Count];
}
for (int i = 0; i < Count; ++i)
{
DashPattern[i] = arrDashPattern[i];
}
}
}
void ScaleAlpha( double dScale )
{
long dNewAlpha = long(Alpha * dScale + 0.5);
if( dNewAlpha > 255 ) dNewAlpha = 255;
else if( dNewAlpha < 0 ) dNewAlpha = 0;
Alpha = dNewAlpha;
}
BOOL IsEqual(CPen* pPen)
{
if (NULL == pPen)
return FALSE;
return ((Color == pPen->Color) && (Alpha == pPen->Alpha) && (Size == pPen->Size) &&
(DashStyle == pPen->DashStyle) && (LineStartCap == pPen->LineStartCap) &&
(LineEndCap == pPen->LineEndCap) && (LineJoin == pPen->LineJoin));
}
void SetToRenderer(IASCRenderer *pRenderer)
{
pRenderer->put_PenColor(Color);
pRenderer->put_PenAlpha(Alpha);
pRenderer->put_PenSize(Size);
pRenderer->put_PenDashStyle(DashStyle);
pRenderer->put_PenLineStartCap(LineStartCap);
pRenderer->put_PenLineEndCap(LineEndCap);
pRenderer->put_PenLineJoin(LineJoin);
pRenderer->put_PenAlign(Align);
if (DashStyle != Aggplus::DashStyleSolid)
{
SAFEARRAYBOUND rgsab;
rgsab.lLbound = 0;
rgsab.cElements = Count;
SAFEARRAY* pArray = SafeArrayCreate(VT_R8, 1, &rgsab);
memcpy(pArray->pvData, DashPattern, Count * sizeof(double));
pRenderer->PenDashPattern(pArray);
RELEASEARRAY(pArray);
pRenderer->put_PenDashOffset(DashOffset);
}
}
void SetDefaultParams()
{
Color = 0;
Alpha = 255;
Size = 1;
DashStyle = 0;
LineStartCap = 0;
LineEndCap = 0;
LineJoin = 0;
DashPattern = NULL;
Count = 0;
DashOffset = 0;
Align = Gdiplus::PenAlignmentCenter;
MiterLimit = 0.5;
}
public:
CPen()
{
SetDefaultParams();
}
CPen( const CPen& other )
{
*this = other;
}
CPen& operator=(const CPen& other)
{
Color = other.Color;
Alpha = other.Alpha;
Size = other.Size;
DashStyle = other.DashStyle;
LineStartCap = other.LineStartCap;
LineEndCap = other.LineEndCap;
LineJoin = other.LineJoin;
RELEASEARRAYOBJECTS(DashPattern);
Count = other.Count;
if (Count != 0)
{
DashPattern = new double[Count];
for (int i = 0; i < Count; ++i)
{
DashPattern[i] = other.DashPattern[i];
}
}
DashOffset = other.DashOffset;
Align = other.Align;
MiterLimit = other.MiterLimit;
return *this;
}
virtual ~CPen()
{
RELEASEARRAYOBJECTS(DashPattern);
}
};
class CBrush
{
public:
long Type;
long Color1;
long Color2;
long Alpha1;
long Alpha2;
CString TexturePath;
long TextureAlpha;
long TextureMode;
BOOL Rectable;
Gdiplus::RectF Rect;
double LinearAngle;
public:
CString ToXmlString(CString strRootNodeName = _T("brush"), BOOL bAttributed = FALSE)
{
XmlUtils::CXmlWriter oXmlWriter;
if (!bAttributed)
{
oXmlWriter.WriteNodeBegin(strRootNodeName);
oXmlWriter.WriteNode(_T("type"), Type);
oXmlWriter.WriteNode(_T("color1"), Color1);
oXmlWriter.WriteNode(_T("color2"), Color2);
oXmlWriter.WriteNode(_T("alpha1"), Alpha1);
oXmlWriter.WriteNode(_T("alpha2"), Alpha2);
oXmlWriter.WriteNode(_T("texturepath"), TexturePath);
oXmlWriter.WriteNode(_T("texturealpha"), TextureAlpha);
oXmlWriter.WriteNode(_T("texturemode"), TextureMode);
oXmlWriter.WriteNode(_T("rectable"), Rectable);
oXmlWriter.WriteNode(_T("linearangle"), LinearAngle);
oXmlWriter.WriteNodeBegin(_T("rectangle"), TRUE);
oXmlWriter.WriteAttribute(_T("left"), Rect.X);
oXmlWriter.WriteAttribute(_T("top"), Rect.Y);
oXmlWriter.WriteAttribute(_T("width"), Rect.Width);
oXmlWriter.WriteAttribute(_T("height"), Rect.Height);
oXmlWriter.WriteNodeEnd(_T("rectangle"), TRUE);
oXmlWriter.WriteNodeEnd(strRootNodeName);
}
else
{
oXmlWriter.WriteNodeBegin(strRootNodeName, TRUE);
ToXmlAttributes(oXmlWriter);
oXmlWriter.WriteNodeEnd(strRootNodeName, TRUE);
}
return oXmlWriter.GetXmlString();
}
void FromXmlString(CString& strXml)
{
XmlUtils::CXmlReader oXmlReader;
oXmlReader.SetXmlString(strXml);
oXmlReader.ReadRootNode();
FromXmlAttributes(oXmlReader);
}
void ToXmlAttributes(XmlUtils::CXmlWriter& oXmlWriter)
{
oXmlWriter.WriteAttribute(_T("type"), Type);
oXmlWriter.WriteAttribute(_T("color1"), Color1);
oXmlWriter.WriteAttribute(_T("color2"), Color2);
oXmlWriter.WriteAttribute(_T("alpha1"), Alpha1);
oXmlWriter.WriteAttribute(_T("alpha2"), Alpha2);
oXmlWriter.WriteAttribute(_T("texturepath"), TexturePath);
oXmlWriter.WriteAttribute(_T("texturealpha"), TextureAlpha);
oXmlWriter.WriteAttribute(_T("texturemode"), TextureMode);
oXmlWriter.WriteAttribute(_T("rectable"), Rectable);
oXmlWriter.WriteAttribute(_T("linearangle"), LinearAngle);
oXmlWriter.WriteAttribute(_T("rect-left"), Rect.X);
oXmlWriter.WriteAttribute(_T("rect-top"), Rect.Y);
oXmlWriter.WriteAttribute(_T("rect-width"), Rect.Width);
oXmlWriter.WriteAttribute(_T("rect-height"), Rect.Height);
}
void FromXmlAttributes(XmlUtils::CXmlReader& oXmlReader)
{
Type = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("type"), _T("0")));
Type = ConstantCompatible(Type);
Color1 = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("color1"), _T("0")));
Color2 = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("color2"), _T("0")));
Alpha1 = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("alpha1"), _T("0")));
Alpha2 = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("alpha2"), _T("0")));
TexturePath = oXmlReader.ReadNodeAttributeOrValue(_T("texturepath"), _T(""));
TextureAlpha = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("texturealpha"), _T("0")));
TextureMode = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("texturemode"), _T("0")));
Rectable = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("rectable"), _T("0")));
LinearAngle = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("linearangle"), _T("0")));
Rect.X = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("rect-left")));
Rect.Y = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("rect-top")));
Rect.Width = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("rect-width")));
Rect.Height = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("rect-height")));
if (oXmlReader.ReadNode(_T("rectangle")))
{
Rect.X = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttribute(_T("left")));
Rect.Y = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttribute(_T("top")));
Rect.Width = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttribute(_T("width")));
Rect.Height = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlReader.ReadNodeAttribute(_T("height")));
}
}
void FromXmlNode(XmlUtils::CXmlNode& oXmlNode)
{
Type = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("type"), _T("0")));
Type = ConstantCompatible(Type);
Color1 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("color1"), _T("0")));
Color2 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("color2"), _T("0")));
Alpha1 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("alpha1"), _T("0")));
Alpha2 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("alpha2"), _T("0")));
TexturePath = oXmlNode.GetAttributeOrValue(_T("texturepath"), _T(""));
TextureAlpha = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("texturealpha"), _T("0")));
TextureMode = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("texturemode"), _T("0")));
Rectable = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("rectable"), _T("0")));
LinearAngle = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("linearangle"), _T("0")));
Rect.X = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("rect-left")));
Rect.Y = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("rect-top")));
Rect.Width = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("rect-width")));
Rect.Height = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("rect-height")));
XmlUtils::CXmlNode oNodeRect;
if (oXmlNode.GetNode(_T("rectangle"), oNodeRect))
{
Rect.X = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("left")));
Rect.Y = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("top")));
Rect.Width = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("width")));
Rect.Height = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("height")));
}
}
void FromXmlNode2(XmlUtils::CXmlNode& oXmlNode)
{
Type = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-type"), _T("0")));
Type = ConstantCompatible(Type);
Color1 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-color1"), _T("0")));
Color2 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-color2"), _T("0")));
Alpha1 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-alpha1"), _T("0")));
Alpha2 = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-alpha2"), _T("0")));
TexturePath = oXmlNode.GetAttributeOrValue(_T("brush-texturepath"), _T(""));
TextureAlpha = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-texturealpha"), _T("0")));
TextureMode = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-texturemode"), _T("0")));
Rectable = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("brush-rectable"), _T("0")));
LinearAngle = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("brush-linearangle"), _T("0")));
Rect.X = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("brush-rect-left")));
Rect.Y = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("brush-rect-top")));
Rect.Width = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("brush-rect-width")));
Rect.Height = (Gdiplus::REAL)XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("brush-rect-height")));
XmlUtils::CXmlNode oNodeRect;
if (oXmlNode.GetNode(_T("brush-rectangle"), oNodeRect))
{
Rect.X = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("left")));
Rect.Y = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("top")));
Rect.Width = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("width")));
Rect.Height = (Gdiplus::REAL)XmlUtils::GetDouble(oNodeRect.GetAttributeOrValue(_T("height")));
}
}
inline LONG ConstantCompatible(LONG nConstant)
{
if( c_BrushTypeDiagonal1_ == nConstant )
nConstant = c_BrushTypeDiagonal2_;
else if( c_BrushTypeDiagonal2_ == nConstant )
nConstant = c_BrushTypeDiagonal1_;
if (1000 <= nConstant)
return nConstant;
if (c_BrushTypeSolid_ == nConstant)
return nConstant + 1000;
if (c_BrushTypeHorizontal_ <= nConstant && c_BrushTypePathGradient2_ >= nConstant)
return nConstant + 2000;
if (c_BrushTypeTexture_ == nConstant)
return nConstant + 3000;
if (c_BrushTypeHatch1_ <= nConstant && c_BrushTypeHatch53_ >= nConstant)
return nConstant + 4000;
if (c_BrushTypeGradient1_ <= nConstant && c_BrushTypeGradient6_ >= nConstant)
return nConstant + 2000 - 61;
return 1000;
}
void ScaleAlpha1( double dScale )
{
long dNewAlpha = long(Alpha1 * dScale + 0.5);
if( dNewAlpha > 255 ) dNewAlpha = 255;
else if( dNewAlpha < 0 ) dNewAlpha = 0;
Alpha1 = dNewAlpha;
}
void ScaleAlpha2( double dScale )
{
long dNewAlpha = long(Alpha2 * dScale + 0.5);
if( dNewAlpha > 255 ) dNewAlpha = 255;
else if( dNewAlpha < 0 ) dNewAlpha = 0;
Alpha2 = dNewAlpha;
}
void ScaleTextureAlpha( double dScale )
{
long dNewAlpha = long(TextureAlpha * dScale + 0.5);
if( dNewAlpha > 255 ) dNewAlpha = 255;
else if( dNewAlpha < 0 ) dNewAlpha = 0;
TextureAlpha = dNewAlpha;
}
BOOL IsEqual(CBrush* pBrush)
{
if (NULL == pBrush)
return FALSE;
/*return ((Type == pBrush->Type) &&
(Color1 == pBrush->Color1) && (Color2 == pBrush->Color2) &&
(Alpha1 == pBrush->Alpha1) && (Alpha2 == pBrush->Alpha2));*/
return ((Type == pBrush->Type) &&
(Color1 == pBrush->Color1) && (Color2 == pBrush->Color2) &&
(Alpha1 == pBrush->Alpha1) && (Alpha2 == pBrush->Alpha2) && (LinearAngle == pBrush->LinearAngle) &&
(TexturePath == pBrush->TexturePath) && (TextureAlpha == pBrush->TextureAlpha) && (TextureMode == pBrush->TextureMode) &&
(Rectable == pBrush->Rectable) && (Rect.Equals(pBrush->Rect)));
}
void SetDefaultParams()
{
Type = c_BrushTypeSolid;
Color1 = 0;
Alpha1 = 255;
Color2 = 0;
Alpha2 = 255;
TextureAlpha = 255;
TextureMode = c_BrushTextureModeStretch;
LinearAngle = 0;
TexturePath = _T("");
Rectable = FALSE;
Rect.X = 0.0F;
Rect.Y = 0.0F;
Rect.Width = 0.0F;
Rect.Height = 0.0F;
}
public:
CBrush()
{
SetDefaultParams();
}
CBrush( const CBrush& other )
{
Type = other.Type;
Color1 = other.Color1;
Alpha1 = other.Alpha1;
Color2 = other.Color2;
Alpha2 = other.Alpha2;
TexturePath = other.TexturePath;
TextureAlpha = other.TextureAlpha;
TextureMode = other.TextureMode;
Rectable = other.Rectable;
Rect = other.Rect;
LinearAngle = other.LinearAngle;
}
CBrush& operator=(const CBrush& other)
{
Type = other.Type;
Color1 = other.Color1;
Alpha1 = other.Alpha1;
Color2 = other.Color2;
Alpha2 = other.Alpha2;
TexturePath = other.TexturePath;
TextureAlpha = other.TextureAlpha;
TextureMode = other.TextureMode;
Rectable = other.Rectable;
Rect = other.Rect;
LinearAngle = other.LinearAngle;
return *this;
}
virtual ~CBrush()
{
}
BOOL IsTexture()
{
return (c_BrushTypeTexture == Type);
}
BOOL IsOneColor()
{
return (c_BrushTypeSolid == Type);
}
BOOL IsTwoColor()
{
return ((c_BrushTypeHorizontal <= Type && c_BrushTypeCylinderVer >= Type) ||
(c_BrushTypeHatch1 <= Type && c_BrushTypeHatch53 >= Type));
}
void SetToRenderer(IASCRenderer *pRenderer)
{
Type = ConstantCompatible(Type);
pRenderer->put_BrushType(Type);
if (IsOneColor())
{
pRenderer->put_BrushColor1(Color1);
pRenderer->put_BrushAlpha1(Alpha1);
}
else if (IsTexture())
{
BSTR bstrTexturePath = TexturePath.AllocSysString();
pRenderer->put_BrushTexturePath(bstrTexturePath);
SysFreeString(bstrTexturePath);
pRenderer->put_BrushTextureMode(TextureMode);
pRenderer->put_BrushTextureAlpha(TextureAlpha);
pRenderer->BrushRect(Rectable, Rect.X, Rect.Y, Rect.Width, Rect.Height);
}
else if (IsTwoColor())
{
pRenderer->put_BrushColor1(Color1);
pRenderer->put_BrushAlpha1(Alpha1);
pRenderer->put_BrushColor2(Color2);
pRenderer->put_BrushAlpha2(Alpha2);
}
}
};
class CFont
{
public:
CString Path;
CString Name;
double Size;
BOOL Bold;
BOOL Italic;
byte Underline;
byte Strikeout;
BOOL StringGID;
double CharSpace;
public:
CString ToXmlString(CString strRootNodeName = _T("font"), BOOL bAttributed = FALSE)
{
XmlUtils::CXmlWriter oXmlWriter;
if (!bAttributed)
{
oXmlWriter.WriteNodeBegin(strRootNodeName);
oXmlWriter.WriteNode(_T("name"), Name);
oXmlWriter.WriteNode(_T("size"), Size);
oXmlWriter.WriteNode(_T("bold"), Bold);
oXmlWriter.WriteNode(_T("italic"), Italic);
oXmlWriter.WriteNode(_T("underline"), Underline);
oXmlWriter.WriteNode(_T("strikeout"), Strikeout);
oXmlWriter.WriteNode(_T("path"), Path);
oXmlWriter.WriteNode(_T("gid"), StringGID);
oXmlWriter.WriteNodeEnd(strRootNodeName);
}
else
{
oXmlWriter.WriteNodeBegin(strRootNodeName, TRUE);
ToXmlAttributes(oXmlWriter);
oXmlWriter.WriteNodeEnd(strRootNodeName, TRUE);
}
return oXmlWriter.GetXmlString();
}
void FromXmlString(CString& strXml)
{
XmlUtils::CXmlReader oXmlReader;
oXmlReader.SetXmlString(strXml);
oXmlReader.ReadRootNode();
FromXmlAttributes(oXmlReader);
}
void ToXmlAttributes(XmlUtils::CXmlWriter& oXmlWriter)
{
oXmlWriter.WriteAttribute(_T("name"), Name);
oXmlWriter.WriteAttribute(_T("size"), Size);
oXmlWriter.WriteAttribute(_T("bold"), Bold);
oXmlWriter.WriteAttribute(_T("italic"), Italic);
oXmlWriter.WriteAttribute(_T("underline"), Underline);
oXmlWriter.WriteAttribute(_T("strikeout"), Strikeout);
oXmlWriter.WriteAttribute(_T("path"), Path);
oXmlWriter.WriteAttribute(_T("gid"), StringGID);
}
void FromXmlAttributes(XmlUtils::CXmlReader& oXmlReader)
{
Name = oXmlReader.ReadNodeAttributeOrValue(_T("name"), _T("Arial"));
Size = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("size"), _T("0")));
Bold = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("bold"), _T("0")));
Italic = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("italic"), _T("0")));
Underline = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("underline"), _T("0")));
Strikeout = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("strikeout"), _T("0")));
Path = oXmlReader.ReadNodeAttributeOrValue(_T("path"), _T(""));
StringGID = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("gid"), _T("0")));
}
void FromXmlNode(XmlUtils::CXmlNode& oXmlNode)
{
Name = oXmlNode.GetAttributeOrValue(_T("name"), _T("Arial"));
Size = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("size"), _T("0")));
Bold = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("bold"), _T("0")));
Italic = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("italic"), _T("0")));
Underline = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("underline"), _T("0")));
Strikeout = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("strikeout"), _T("0")));
Path = oXmlNode.GetAttributeOrValue(_T("path"), _T(""));
StringGID = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("gid"), _T("0")));
}
void FromXmlNode2(XmlUtils::CXmlNode& oXmlNode)
{
Name = oXmlNode.GetAttributeOrValue(_T("font-name"), _T("Arial"));
Size = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("font-size"), _T("0")));
Bold = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("font-bold"), _T("0")));
Italic = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("font-italic"), _T("0")));
Underline = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("font-underline"), _T("0")));
Strikeout = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("font-strikeout"), _T("0")));
Path = oXmlNode.GetAttributeOrValue(_T("font-path"), _T(""));
StringGID = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("font-gid"), _T("0")));
}
BOOL IsEqual(CFont* pFont)
{
if (NULL == pFont)
return FALSE;
if (!Path.IsEmpty() && !pFont->Path.IsEmpty())
return ((Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size) && (Bold == pFont->Bold) && (Italic == pFont->Italic));
return ((Name == pFont->Name) && (Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size) &&
(Bold == pFont->Bold) && (Italic == pFont->Italic) &&
(Underline == pFont->Underline) && (Strikeout == pFont->Strikeout));
}
BOOL IsEqual2(CFont* pFont)
{
if (NULL == pFont)
return FALSE;
return ((Name == pFont->Name) && (Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size) &&
(Bold == pFont->Bold) && (Italic == pFont->Italic));
}
BOOL IsEqual3(CFont* pFont)
{
if (NULL == pFont)
return FALSE;
return ((Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size));
}
LONG GetStyle() const
{
LONG lStyle = 0;
if (Bold)
lStyle |= 0x01;
if (Italic)
lStyle |= 0x02;
lStyle |= Underline << 2;
lStyle |= Strikeout << 7;
return lStyle;
}
void SetStyle(LONG const& lStyle)
{
Bold = (0x01 == (0x01 & lStyle));
Italic = (0x02 == (0x02 & lStyle));
Underline = (byte)(0x7C & lStyle) >> 2;
Strikeout = (byte)(0x0180 & lStyle) >> 7;
}
void SetToRenderer(IASCRenderer *pRenderer)
{
BSTR bstrName = Name.AllocSysString();
pRenderer->put_FontName(bstrName);
SysFreeString(bstrName);
BSTR bstrPath = Path.AllocSysString();
pRenderer->put_FontPath(bstrPath);
SysFreeString(bstrPath);
pRenderer->put_FontSize(Size);
pRenderer->put_FontStyle(GetStyle());
pRenderer->put_FontStringGID(StringGID);
pRenderer->put_FontCharSpace(CharSpace);
}
void SetDefaultParams()
{
Name = _T("Arial");
Path = _T("");
Size = 0;
Bold = FALSE;
Italic = FALSE;
Underline = 0;
Strikeout = 0;
StringGID = FALSE;
CharSpace = 0.0;
}
public:
CFont()
{
SetDefaultParams();
}
CFont( const CFont& other )
{
*this = other;
}
CFont& operator=(const CFont& other)
{
Name = other.Name;
Path = other.Path;
Size = other.Size;
Bold = other.Bold;
Italic = other.Italic;
Underline = other.Underline;
Strikeout = other.Strikeout;
StringGID = other.StringGID;
CharSpace = other.CharSpace;
return *this;
}
virtual ~CFont()
{
}
};
class CFormat
{
public:
BOOL AntiAliasPen;
BOOL AntiAliasBrush;
BOOL AntiAliasText;
long StringAlignmentVertical;
long StringAlignmentHorizontal;
BOOL WordWrapBySymbol;
long ImageAlphMode;
public:
CString ToXmlString(CString strRootNodeName = _T("format"), BOOL bAttributed = FALSE)
{
XmlUtils::CXmlWriter oXmlWriter;
if (!bAttributed)
{
oXmlWriter.WriteNodeBegin(strRootNodeName);
oXmlWriter.WriteNode(_T("antialiaspen"), AntiAliasPen);
oXmlWriter.WriteNode(_T("antialiasbrush"), AntiAliasBrush);
oXmlWriter.WriteNode(_T("antialiastext"), AntiAliasText);
oXmlWriter.WriteNode(_T("stringalignmentvertical"), StringAlignmentVertical);
oXmlWriter.WriteNode(_T("stringalignmenthorizontal"), StringAlignmentHorizontal);
oXmlWriter.WriteNode(_T("wordwrapbysymbol"), WordWrapBySymbol);
oXmlWriter.WriteNode(_T("imagealphmode"), ImageAlphMode);
oXmlWriter.WriteNodeEnd(strRootNodeName);
}
else
{
oXmlWriter.WriteNodeBegin(strRootNodeName, TRUE);
ToXmlAttributes(oXmlWriter);
oXmlWriter.WriteNodeEnd(strRootNodeName, TRUE);
}
return oXmlWriter.GetXmlString();
}
void FromXmlString(CString strXml)
{
XmlUtils::CXmlReader oXmlReader;
oXmlReader.SetXmlString(strXml);
oXmlReader.ReadRootNode();
FromXmlAttributes(oXmlReader);
}
void ToXmlAttributes(XmlUtils::CXmlWriter& oXmlWriter)
{
oXmlWriter.WriteAttribute(_T("antialiaspen"), AntiAliasPen);
oXmlWriter.WriteAttribute(_T("antialiasbrush"), AntiAliasBrush);
oXmlWriter.WriteAttribute(_T("antialiastext"), AntiAliasText);
oXmlWriter.WriteAttribute(_T("stringalignmentvertical"), StringAlignmentVertical);
oXmlWriter.WriteAttribute(_T("stringalignmenthorizontal"), StringAlignmentHorizontal);
oXmlWriter.WriteAttribute(_T("wordwrapbysymbol"), WordWrapBySymbol);
oXmlWriter.WriteAttribute(_T("imagealphmode"), ImageAlphMode);
}
void FromXmlAttributes(XmlUtils::CXmlReader& oXmlReader)
{
AntiAliasPen = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("antialiaspen"), _T("1")));
AntiAliasBrush = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("antialiasbrush"), _T("1")));
AntiAliasText = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("antialiastext"), _T("0")));
StringAlignmentVertical = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("stringalignmentvertical"), _T("0")));
StringAlignmentHorizontal = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("stringalignmenthorizontal"), _T("0")));
WordWrapBySymbol = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("wordwrapbysymbol"), _T("0")));
ImageAlphMode = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("imagealphmode"), _T("0")));
}
void FromXmlNode(XmlUtils::CXmlNode& oXmlNode)
{
AntiAliasPen = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("antialiaspen"), _T("1")));
AntiAliasBrush = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("antialiasbrush"), _T("1")));
AntiAliasText = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("antialiastext"), _T("0")));
StringAlignmentVertical = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("font-stringalignmentvertical"), _T("1")));
StringAlignmentHorizontal = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("font-stringalignmenthorizontal"), _T("1")));
WordWrapBySymbol = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("wordwrapbysymbol"), _T("0")));
ImageAlphMode = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("imagealphmode"), _T("0")));
}
public:
CFormat()
{
AntiAliasPen = TRUE;
AntiAliasBrush = TRUE;
AntiAliasText = TRUE;
StringAlignmentVertical = 0;
StringAlignmentHorizontal = 0;
WordWrapBySymbol = FALSE;
ImageAlphMode = 0;
}
CFormat( const CFormat& other )
{
AntiAliasPen = other.AntiAliasPen;
AntiAliasBrush = other.AntiAliasBrush;
AntiAliasText = other.AntiAliasText;
StringAlignmentVertical = other.StringAlignmentVertical;
StringAlignmentHorizontal = other.StringAlignmentHorizontal;
WordWrapBySymbol = other.WordWrapBySymbol;
ImageAlphMode = other.ImageAlphMode;
}
CFormat& operator=(const CFormat& other)
{
AntiAliasPen = other.AntiAliasPen;
AntiAliasBrush = other.AntiAliasBrush;
AntiAliasText = other.AntiAliasText;
StringAlignmentVertical = other.StringAlignmentVertical;
StringAlignmentHorizontal = other.StringAlignmentHorizontal;
WordWrapBySymbol = other.WordWrapBySymbol;
ImageAlphMode = other.ImageAlphMode;
return *this;
}
~CFormat()
{
}
};
class CShadow
{
public:
BOOL Visible;
double DistanceX;
double DistanceY;
double BlurSize;
long Color;
long Alpha;
public:
CString ToXmlString(CString strRootNodeName = _T("shadow"), BOOL bAttributed = FALSE)
{
XmlUtils::CXmlWriter oXmlWriter;
if (!bAttributed)
{
oXmlWriter.WriteNodeBegin(strRootNodeName);
oXmlWriter.WriteNode(_T("visible"), Visible);
oXmlWriter.WriteNode(_T("distancex"), DistanceX);
oXmlWriter.WriteNode(_T("distancey"), DistanceY);
oXmlWriter.WriteNode(_T("blursize"), BlurSize);
oXmlWriter.WriteNode(_T("color"), Color);
oXmlWriter.WriteNode(_T("alpha"), Alpha);
oXmlWriter.WriteNodeEnd(strRootNodeName);
}
else
{
oXmlWriter.WriteNodeBegin(strRootNodeName, TRUE);
ToXmlAttributes(oXmlWriter);
oXmlWriter.WriteNodeEnd(strRootNodeName, TRUE);
}
return oXmlWriter.GetXmlString();
}
void FromXmlString(CString& strXml)
{
XmlUtils::CXmlReader oXmlReader;
oXmlReader.SetXmlString(strXml);
oXmlReader.ReadRootNode();
FromXmlAttributes(oXmlReader);
}
void ToXmlAttributes(XmlUtils::CXmlWriter& oXmlWriter)
{
oXmlWriter.WriteAttribute(_T("visible"), Visible);
oXmlWriter.WriteAttribute(_T("distancex"), DistanceX);
oXmlWriter.WriteAttribute(_T("distancey"), DistanceY);
oXmlWriter.WriteAttribute(_T("blursize"), BlurSize);
oXmlWriter.WriteAttribute(_T("color"), Color);
oXmlWriter.WriteAttribute(_T("alpha"), Alpha);
}
void FromXmlAttributes(XmlUtils::CXmlReader& oXmlReader)
{
Visible = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("visible"), _T("0")));
DistanceX = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("distancex"), _T("0")));
DistanceY = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("distancey"), _T("0")));
BlurSize = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("blursize"), _T("0")));
Color = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("alpha"), _T("0")));
}
void FromXmlNode(XmlUtils::CXmlNode& oXmlNode)
{
Visible = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("visible"), _T("0")));
DistanceX = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("distancex"), _T("0")));
DistanceY = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("distancey"), _T("0")));
BlurSize = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("blursize"), _T("0")));
Color = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("alpha"), _T("0")));
}
void SetDefaultParams()
{
Visible = FALSE;
DistanceX = 15;
DistanceY = 15;
BlurSize = 0;
Color = 0;
Alpha = 120;
}
public:
CShadow()
{
SetDefaultParams();
}
CShadow( const CShadow& other )
{
Visible = other.Visible;
DistanceX = other.DistanceX;
DistanceY = other.DistanceY;
BlurSize = other.BlurSize;
Color = other.Color;
Alpha = other.Alpha;
}
CShadow& operator=(const CShadow& other)
{
Visible = other.Visible;
DistanceX = other.DistanceX;
DistanceY = other.DistanceY;
BlurSize = other.BlurSize;
Color = other.Color;
Alpha = other.Alpha;
return *this;
}
virtual ~CShadow()
{
}
};
class CBackground
{
public:
long Color;
long Alpha;
public:
CString ToXmlString(CString strRootNodeName = _T("background"), BOOL bAttributed = FALSE)
{
XmlUtils::CXmlWriter oXmlWriter;
if (!bAttributed)
{
oXmlWriter.WriteNodeBegin(strRootNodeName);
oXmlWriter.WriteNode(_T("color"), Color);
oXmlWriter.WriteNode(_T("alpha"), Alpha);
oXmlWriter.WriteNodeEnd(strRootNodeName);
}
else
{
oXmlWriter.WriteNodeBegin(strRootNodeName, TRUE);
ToXmlAttributes(oXmlWriter);
oXmlWriter.WriteNodeEnd(strRootNodeName, TRUE);
}
return oXmlWriter.GetXmlString();
}
void FromXmlString(CString& strXml)
{
XmlUtils::CXmlReader oXmlReader;
oXmlReader.SetXmlString(strXml);
oXmlReader.ReadRootNode();
FromXmlAttributes(oXmlReader);
}
void ToXmlAttributes(XmlUtils::CXmlWriter& oXmlWriter)
{
oXmlWriter.WriteAttribute(_T("color"), Color);
oXmlWriter.WriteAttribute(_T("alpha"), Alpha);
}
void FromXmlAttributes(XmlUtils::CXmlReader& oXmlReader)
{
Color = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("alpha"), _T("0")));
}
void FromXmlNode(XmlUtils::CXmlNode& oXmlNode)
{
Color = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("alpha"), _T("0")));
}
public:
CBackground()
{
Color = 0;
Alpha = 0;
}
CBackground( const CBackground& other )
{
Color = other.Color;
Alpha = other.Alpha;
}
CBackground& operator=(const CBackground& other)
{
Color = other.Color;
Alpha = other.Alpha;
return *this;
}
virtual ~CBackground()
{
}
};
class CEdgeText
{
public:
long Visible;
double Dist;
long Color;
long Alpha;
public:
CString ToXmlString(CString strRootNodeName = _T("edgetext"), BOOL bAttributed = FALSE)
{
XmlUtils::CXmlWriter oXmlWriter;
if (!bAttributed)
{
oXmlWriter.WriteNodeBegin(strRootNodeName);
oXmlWriter.WriteNode(_T("visible"), Visible);
oXmlWriter.WriteNode(_T("dist"), Dist);
oXmlWriter.WriteNode(_T("color"), Color);
oXmlWriter.WriteNode(_T("alpha"), Alpha);
oXmlWriter.WriteNodeEnd(strRootNodeName);
}
else
{
oXmlWriter.WriteNodeBegin(strRootNodeName, TRUE);
ToXmlAttributes(oXmlWriter);
oXmlWriter.WriteNodeEnd(strRootNodeName, TRUE);
}
return oXmlWriter.GetXmlString();
}
void FromXmlString(CString& strXml)
{
XmlUtils::CXmlReader oXmlReader;
oXmlReader.SetXmlString(strXml);
oXmlReader.ReadRootNode();
FromXmlAttributes(oXmlReader);
}
void ToXmlAttributes(XmlUtils::CXmlWriter& oXmlWriter)
{
oXmlWriter.WriteAttribute(_T("visible"), Visible);
oXmlWriter.WriteAttribute(_T("dist"), Dist);
oXmlWriter.WriteAttribute(_T("color"), Color);
oXmlWriter.WriteAttribute(_T("alpha"), Alpha);
}
void FromXmlAttributes(XmlUtils::CXmlReader& oXmlReader)
{
Visible = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("edge-visible"), _T("0")));
Dist = XmlUtils::GetDouble(oXmlReader.ReadNodeAttributeOrValue(_T("edge-dist"), _T("0")));
Color = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("edge-color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlReader.ReadNodeAttributeOrValue(_T("edge-alpha"), _T("0")));
}
void FromXmlNode(XmlUtils::CXmlNode& oXmlNode)
{
Visible = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("edge-visible"), _T("0")));
Dist = XmlUtils::GetDouble(oXmlNode.GetAttributeOrValue(_T("edge-dist"), _T("0")));
Color = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("edge-color"), _T("0")));
Alpha = XmlUtils::GetInteger(oXmlNode.GetAttributeOrValue(_T("edge-alpha"), _T("0")));
}
void SetDefaultParams()
{
Visible = 0;
Dist = 5;
Color = 0;
Alpha = 255;
}
public:
CEdgeText()
{
SetDefaultParams();
}
CEdgeText( const CEdgeText& other )
{
Visible = other.Visible;
Dist = other.Dist;
Color = other.Color;
Alpha = other.Alpha;
}
CEdgeText& operator=(const CEdgeText& other)
{
Visible = other.Visible;
Dist = other.Dist;
Color = other.Color;
Alpha = other.Alpha;
return *this;
}
virtual ~CEdgeText()
{
}
};
static void SetMatrix(Gdiplus::Matrix& oDst, const Gdiplus::Matrix& oSrc)
{
Gdiplus::REAL mass[6];
oSrc.GetElements(mass);
oDst.SetElements(mass[0], mass[1], mass[2], mass[3], mass[4], mass[5]);
}
}
\ No newline at end of file
#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;
};
#pragma once
#ifndef AVSINLINE
#if defined(_MSC_VER)
#define AVSINLINE __forceinline
#else
#define AVSINLINE inline
#endif
#endif
#include "../../Common/TemporaryCS.h"
#include "../Graphics/Matrix.h"
#include "../Graphics/Structures.h"
#include "StringWriter.h"
#include "CalculatorCRC32.h"
namespace NSDocxRenderer
{
AVSINLINE LONG ConvertColor(LONG lBGR)
{
return (0x00FFFFFF & (((lBGR & 0xFF) << 16) | (lBGR & 0x0000FF00) | ((lBGR >> 16) & 0xFF)));
}
AVSINLINE void CorrectString(CString& strValue)
{
strValue.Replace(_T("&"), _T("&amp;"));
strValue.Replace(_T("'"), _T("&apos;"));
strValue.Replace(_T("<"), _T("&lt;"));
strValue.Replace(_T(">"), _T("&gt;"));
strValue.Replace(_T("\""), _T("&quot;"));
}
class CBaseItem
{
public:
enum ElemType
{
etParagraph = 0,
etImage = 1,
etShape = 2
};
ElemType m_eType;
CBaseItem()
{
m_eType = etShape;
}
virtual void ToXml(NSDocxRenderer::CStringWriter& oWriter) = 0;
};
class CImageManager
{
public:
CAtlMap<CString, CImageInfo> m_mapImagesFile;
CAtlMap<DWORD, CImageInfo> m_mapImageData;
CString m_strDstMedia;
LONG m_lMaxSizeImage;
LONG m_lNextIDImage;
CCalculatorCRC32 m_oCRC;
public:
CImageManager()
{
m_strDstMedia = _T("");
m_lMaxSizeImage = 800;
m_lNextIDImage = 0;
}
AVSINLINE void NewDocument()
{
m_strDstMedia = _T("");
m_lMaxSizeImage = 800;
m_lNextIDImage = 0;
m_mapImageData.RemoveAll();
m_mapImagesFile.RemoveAll();
}
public:
CImageInfo WriteImage(IUnknown* punkImage, double& x, double& y, double& width, double& height)
{
if (height < 0)
{
FlipY(punkImage);
height = -height;
y -= height;
}
return GenerateImageID(punkImage);
}
CImageInfo WriteImage(CString& strFile, double& x, double& y, double& width, double& height)
{
return GenerateImageID(strFile);
}
protected:
inline void CopyFile(CString& strFileSrc, CString& strFileDst)
{
CDirectory::CopyFile(strFileSrc, strFileDst, NULL, NULL);
}
void SaveImage(CString& strFileSrc, CImageInfo& oInfo)
{
CString strLoadXml = _T("<transforms><ImageFile-LoadImage sourcepath=\"") + strFileSrc + _T("\"/></transforms>");
ImageStudio::IImageTransforms* pTransform = NULL;
CoCreateInstance(ImageStudio::CLSID_ImageTransforms, NULL, CLSCTX_INPROC_SERVER, ImageStudio::IID_IImageTransforms, (void**)&pTransform);
VARIANT_BOOL vbRes = VARIANT_FALSE;
BSTR bsLoad = strLoadXml.AllocSysString();
pTransform->SetXml(bsLoad, &vbRes);
SysFreeString(bsLoad);
pTransform->Transform(&vbRes);
VARIANT var;
var.punkVal = NULL;
pTransform->GetResult(0, &var);
if (NULL == var.punkVal)
{
RELEASEINTERFACE(pTransform);
return;
}
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
var.punkVal->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
RELEASEINTERFACE((var.punkVal));
if (NULL == pFrame)
{
RELEASEINTERFACE(pTransform);
return;
}
LONG lWidth = 0;
LONG lHeight = 0;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
oInfo.m_eType = GetImageType(pFrame);
RELEASEINTERFACE(pFrame);
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
if (itJPG == oInfo.m_eType)
{
strSaveItem = _T("<ImageFile-SaveAsJpeg destinationpath=\"") + m_strDstMedia + strSaveItem + _T("jpg\" format=\"888\"/>");
}
else
{
strSaveItem = _T("<ImageFile-SaveAsPng destinationpath=\"") + m_strDstMedia + strSaveItem + _T("png\" format=\"888\"/>");
}
CString strXml = _T("");
if ((lWidth <= m_lMaxSizeImage) && (lHeight <= m_lMaxSizeImage))
{
strXml = _T("<transforms>") + strSaveItem + _T("</transforms>");
}
else
{
LONG lW = 0;
LONG lH = 0;
double dAspect = (double)lWidth / lHeight;
if (lWidth >= lHeight)
{
lW = m_lMaxSizeImage;
lH = (LONG)((double)lW / dAspect);
}
else
{
lH = m_lMaxSizeImage;
lW = (LONG)(dAspect * lH);
}
CString strResize = _T("");
strResize.Format(_T("<ImageTransform-TransformResize width=\"%d\" height=\"%d\"/>"), lW, lH);
strXml = _T("<transforms>") + strResize + strSaveItem + _T("</transforms>");
}
VARIANT_BOOL vbSuccess = VARIANT_FALSE;
BSTR bsXml = strXml.AllocSysString();
pTransform->SetXml(bsXml, &vbSuccess);
SysFreeString(bsXml);
pTransform->Transform(&vbSuccess);
RELEASEINTERFACE(pTransform);
}
void SaveImage(IUnknown* punkImage, CImageInfo& oInfo)
{
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkImage->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
if (NULL == pFrame)
return;
LONG lWidth = 0;
LONG lHeight = 0;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
oInfo.m_eType = GetImageType(pFrame);
RELEASEINTERFACE(pFrame);
ImageStudio::IImageTransforms* pTransform = NULL;
CoCreateInstance(ImageStudio::CLSID_ImageTransforms, NULL ,CLSCTX_INPROC_SERVER, ImageStudio::IID_IImageTransforms, (void**)&pTransform);
VARIANT var;
var.vt = VT_UNKNOWN;
var.punkVal = punkImage;
pTransform->SetSource(0, var);
CString strSaveItem = _T("");
strSaveItem.Format(_T("\\image%d."), oInfo.m_lID);
if (itJPG == oInfo.m_eType)
{
strSaveItem = _T("<ImageFile-SaveAsJpeg destinationpath=\"") + m_strDstMedia + strSaveItem + _T("jpg\" format=\"888\"/>");
}
else
{
strSaveItem = _T("<ImageFile-SaveAsPng destinationpath=\"") + m_strDstMedia + strSaveItem + _T("png\" format=\"888\"/>");
}
CString strXml = _T("");
if ((lWidth <= m_lMaxSizeImage) && (lHeight <= m_lMaxSizeImage))
{
strXml = _T("<transforms>") + strSaveItem + _T("</transforms>");
}
else
{
LONG lW = 0;
LONG lH = 0;
double dAspect = (double)lWidth / lHeight;
if (lWidth >= lHeight)
{
lW = m_lMaxSizeImage;
lH = (LONG)((double)lW / dAspect);
}
else
{
lH = m_lMaxSizeImage;
lW = (LONG)(dAspect * lH);
}
CString strResize = _T("");
strResize.Format(_T("<ImageTransform-TransformResize width=\"%d\" height=\"%d\"/>"), lW, lH);
strXml = _T("<transforms>") + strResize + strSaveItem + _T("</transforms>");
}
VARIANT_BOOL vbSuccess = VARIANT_FALSE;
BSTR bsXml = strXml.AllocSysString();
pTransform->SetXml(bsXml, &vbSuccess);
SysFreeString(bsXml);
pTransform->Transform(&vbSuccess);
RELEASEINTERFACE(pTransform);
}
CImageInfo GenerateImageID(IUnknown* punkData)
{
CImageInfo oInfo;
if (NULL == punkData)
return oInfo;
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkData->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
BYTE* pBuffer = NULL;
LONG lLen = 0;
pFrame->get_Buffer(&pBuffer);
pFrame->get_BufferSize(&lLen);
DWORD dwSum = m_oCRC.Calc(pBuffer, lLen);
CAtlMap<DWORD, CImageInfo>::CPair* pPair = m_mapImageData.Lookup(dwSum);
if (NULL == pPair)
{
//
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
SaveImage(punkData, oInfo);
m_mapImageData.SetAt(dwSum, oInfo);
}
else
{
oInfo = pPair->m_value;
}
RELEASEINTERFACE(pFrame);
return oInfo;
}
CImageInfo GenerateImageID(CString& strFileName)
{
CImageInfo oInfo;
CAtlMap<CString, CImageInfo>::CPair* pPair = m_mapImagesFile.Lookup(strFileName);
if (NULL == pPair)
{
//
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
SaveImage(strFileName, oInfo);
m_mapImagesFile.SetAt(strFileName, oInfo);
}
else
{
oInfo = pPair->m_value;
}
return oInfo;
}
ImageType GetImageType(MediaCore::IAVSUncompressedVideoFrame* pFrame)
{
LONG lWidth = 0;
LONG lHeight = 0;
BYTE* pBuffer = NULL;
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
pFrame->get_Buffer(&pBuffer);
BYTE* pBufferMem = pBuffer + 3;
LONG lCountPix = lWidth * lHeight;
for (LONG i = 0; i < lCountPix; ++i, pBufferMem += 4)
{
if (255 != *pBufferMem)
return itPNG;
}
return itJPG;
}
void FlipY(IUnknown* punkImage)
{
if (NULL == punkImage)
return;
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkImage->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
if (NULL == pFrame)
return;
BYTE* pBuffer = NULL;
LONG lWidth = 0;
LONG lHeight = 0;
LONG lStride = 0;
pFrame->get_Buffer(&pBuffer);
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
pFrame->get_Stride(0, &lStride);
if (lStride < 0)
lStride = -lStride;
if ((lWidth * 4) != lStride)
{
RELEASEINTERFACE(pFrame);
return;
}
BYTE* pBufferMem = new BYTE[lStride];
BYTE* pBufferEnd = pBuffer + lStride * (lHeight - 1);
LONG lCountV = lHeight / 2;
for (LONG lIndexV = 0; lIndexV < lCountV; ++lIndexV)
{
memcpy(pBufferMem, pBuffer, lStride);
memcpy(pBuffer, pBufferEnd, lStride);
memcpy(pBufferEnd, pBufferMem, lStride);
pBuffer += lStride;
pBufferEnd -= lStride;
}
RELEASEARRAYOBJECTS(pBufferMem);
RELEASEINTERFACE(pFrame);
}
void FlipX(IUnknown* punkImage)
{
if (NULL == punkImage)
return;
MediaCore::IAVSUncompressedVideoFrame* pFrame = NULL;
punkImage->QueryInterface(MediaCore::IID_IAVSUncompressedVideoFrame, (void**)&pFrame);
if (NULL == pFrame)
return;
BYTE* pBuffer = NULL;
LONG lWidth = 0;
LONG lHeight = 0;
LONG lStride = 0;
pFrame->get_Buffer(&pBuffer);
pFrame->get_Width(&lWidth);
pFrame->get_Height(&lHeight);
pFrame->get_Stride(0, &lStride);
if (lStride < 0)
lStride = -lStride;
if ((lWidth * 4) != lStride)
{
RELEASEINTERFACE(pFrame);
return;
}
DWORD* pBufferDWORD = (DWORD*)pBuffer;
LONG lW2 = lWidth / 2;
for (LONG lIndexV = 0; lIndexV < lHeight; ++lIndexV)
{
DWORD* pMem1 = pBufferDWORD;
DWORD* pMem2 = pBufferDWORD + lWidth - 1;
LONG lI = 0;
while (lI < lW2)
{
DWORD dwMem = *pMem1;
*pMem1++ = *pMem2;
*pMem2-- = dwMem;
}
}
RELEASEINTERFACE(pFrame);
}
};
}
namespace NSDocxRenderer
{
// 2-byte number
inline short little_endian_2_big_endian( short s )
{
return ( ( s >> 8) & 0xff ) + ( ( s << 8 ) & 0xff00 );
}
/*========================================================================================================*/
// 4-byte number
inline int little_endian_2_big_endian( int i )
{
return ( ( i & 0xff ) << 24 ) + ( ( i & 0xff00 ) << 8 ) + ( ( i & 0xff0000 ) >> 8 ) + ( ( i >> 24 ) & 0xff );
}
AVSINLINE CString ToHexString( unsigned int ui )
{
CString strRes = _T("");
strRes.Format(_T("%08X"), ui);
return strRes;
}
/*========================================================================================================*/
AVSINLINE CString ToHexString( short s )
{
CString strRes = _T("");
strRes.Format(_T("%04X"), s);
return strRes;
}
/*========================================================================================================*/
AVSINLINE CString ToHexString( unsigned short us )
{
CString strRes = _T("");
strRes.Format(_T("%04X"), us);
return strRes;
}
/*========================================================================================================*/
AVSINLINE CString ToHexString( char c )
{
CString strRes = _T("");
strRes.Format(_T("%02X"), c);
return strRes;
}
/*========================================================================================================*/
AVSINLINE CString ToHexString( BYTE uc )
{
CString strRes = _T("");
strRes.Format(_T("%02X"), uc);
return strRes;
}
/*========================================================================================================*/
}
\ No newline at end of file
#pragma once
#include "Page.h"
namespace NSDocxRenderer
{
static CString g_string_imageRID_png = _T("<Relationship Id=\"rId%d\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"media/image%d.png\"/>");
static CString g_string_imageRID_jpg = _T("<Relationship Id=\"rId%d\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"media/image%d.jpg\"/>");
static _bstr_t g_bstr_FontNameStart = L"<w:font w:name=\"";
static _bstr_t g_bstr_FontPanoseStart = L"<w:panose1 w:val=\"";
static _bstr_t g_bstr_FontCharsetStart = L"<w:charset w:val=\"";
static _bstr_t g_bstr_FontFamilyStart = L"<w:family w:val=\"";
static _bstr_t g_bstr_FontPitchTrue = L"<w:pitch w:val=\"fixed\" />";
static _bstr_t g_bstr_FontPitchFalse = L"<w:pitch w:val=\"variable\" />";
static CString g_string_SIG = _T("<w:sig w:usb0=\"%08x\" w:usb1=\"%08x\" w:usb2=\"%08x\" w:usb3=\"%08x\" w:csb0=\"%08x\" w:csb1=\"%08x\"/>");
static _bstr_t g_bstr_end = L"\"/>";
static _bstr_t g_bstr_end2 = L"\">";
static _bstr_t g_bstr_FontNameEnd = L"</w:font>";
static CString g_string_DocumentStart = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<w:document xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\">\
<w:body>";
static CString g_string_DocumentEnd = L"</w:body></w:document>";
class CDocument
{
public:
NSStructures::CPen m_oPen;
NSStructures::CBrush m_oBrush;
NSStructures::CFont m_oFont;
NSStructures::CShadow m_oShadow;
NSStructures::CEdgeText m_oEdge;
NSStructures::CFont m_oInstalledFont;
AVSGraphics::IASCGraphicSimpleComverter* m_pSimpleGraphicsConverter;
AVSGraphics::IASCFontManager* m_pFontManager;
NSDocxRenderer::CMatrix m_oTransform;
LONG m_lCurrentCommandType;
LONG m_lClipMode;
CPage m_oCurrentPage;
IUnknown* m_punkRenderer;
CImageManager m_oManager;
double m_dWidth;
double m_dHeight;
double m_dDpiX;
double m_dDpiY;
CString m_strTempDirectory;
CFile m_oDocumentStream;
LONG m_lPagesCount;
NSDocxRenderer::CStringWriter m_oWriter;
bool m_bIsNeedPDFTextAnalyzer;
public:
CDocument() : m_oWriter()
{
m_pSimpleGraphicsConverter = NULL;
m_lCurrentCommandType = 0;
m_pFontManager = NULL;
m_punkRenderer = NULL;
m_dWidth = 0;
m_dHeight = 0;
m_dDpiX = 72;
m_dDpiY = 72;
m_strTempDirectory = _T("");
m_lPagesCount = 0;
m_bIsNeedPDFTextAnalyzer = false;
}
AVSINLINE void Clear()
{
m_lClipMode = 0;
RELEASEINTERFACE(m_punkRenderer);
RELEASEINTERFACE(m_pSimpleGraphicsConverter);
RELEASEINTERFACE(m_pFontManager);
}
~CDocument()
{
m_lClipMode = 0;
RELEASEINTERFACE(m_pSimpleGraphicsConverter);
RELEASEINTERFACE(m_pFontManager);
}
public:
AVSINLINE HRESULT NewPage()
{
if (0 != m_lPagesCount)
{
m_oCurrentPage.WriteSectionToFile(false, m_oWriter);
m_oDocumentStream.WriteStringUTF8(m_oWriter.GetData());
m_oWriter.ClearNoAttack();
}
m_oPen.SetDefaultParams();
m_oBrush.SetDefaultParams();
m_oFont.SetDefaultParams();
m_oShadow.SetDefaultParams();
m_oEdge.SetDefaultParams();
m_oTransform.Reset();
++m_lPagesCount;
m_oCurrentPage.Clear();
return S_OK;
}
AVSINLINE HRESULT get_Height(double* dHeight)
{
*dHeight = m_dHeight;
return S_OK;
}
AVSINLINE HRESULT put_Height(double dHeight)
{
m_dHeight = dHeight;
m_oCurrentPage.m_dHeight = dHeight;
return S_OK;
}
AVSINLINE HRESULT get_Width(double* dWidth)
{
*dWidth = m_dWidth;
return S_OK;
}
AVSINLINE HRESULT put_Width(double dWidth)
{
m_dWidth = dWidth;
m_oCurrentPage.m_dWidth = dWidth;
return S_OK;
}
AVSINLINE HRESULT get_DpiX(double* dDpiX)
{
*dDpiX = m_dDpiX;
return S_OK;
}
AVSINLINE HRESULT get_DpiY(double* dDpiY)
{
*dDpiY = m_dDpiY;
return S_OK;
}
//-------- ----------------------------------------------
// pen --------------------------------------------------------------------------------------
AVSINLINE HRESULT SetPen(BSTR bsXML)
{
m_oPen.FromXmlString((CString)bsXML);
return S_OK;
}
AVSINLINE HRESULT get_PenColor(LONG* lColor)
{
*lColor = m_oPen.Color;
return S_OK;
}
AVSINLINE HRESULT put_PenColor(LONG lColor)
{
m_oPen.Color = lColor;
return S_OK;
}
AVSINLINE HRESULT get_PenAlpha(LONG* lAlpha)
{
*lAlpha = m_oPen.Alpha;
return S_OK;
}
AVSINLINE HRESULT put_PenAlpha(LONG lAlpha)
{
m_oPen.Alpha = lAlpha;
return S_OK;
}
AVSINLINE HRESULT get_PenSize(double* dSize)
{
*dSize = m_oPen.Size;
return S_OK;
}
AVSINLINE HRESULT put_PenSize(double dSize)
{
m_oPen.Size = dSize;
return S_OK;
}
AVSINLINE HRESULT get_PenDashStyle(BYTE* val)
{
*val = m_oPen.DashStyle;
return S_OK;
}
AVSINLINE HRESULT put_PenDashStyle(BYTE val)
{
m_oPen.DashStyle = val;
return S_OK;
}
AVSINLINE HRESULT get_PenLineStartCap(BYTE* val)
{
*val = m_oPen.LineStartCap;
return S_OK;
}
AVSINLINE HRESULT put_PenLineStartCap(BYTE val)
{
m_oPen.LineStartCap = val;
return S_OK;
}
AVSINLINE HRESULT get_PenLineEndCap(BYTE* val)
{
*val = m_oPen.LineEndCap;
return S_OK;
}
AVSINLINE HRESULT put_PenLineEndCap(BYTE val)
{
m_oPen.LineEndCap = val;
return S_OK;
}
AVSINLINE HRESULT get_PenLineJoin(BYTE* val)
{
*val = m_oPen.LineJoin;
return S_OK;
}
AVSINLINE HRESULT put_PenLineJoin(BYTE val)
{
m_oPen.LineJoin = val;
return S_OK;
}
AVSINLINE HRESULT get_PenDashOffset(double* val)
{
*val = m_oPen.DashOffset;
return S_OK;
}
AVSINLINE HRESULT put_PenDashOffset(double val)
{
m_oPen.DashOffset = val;
return S_OK;
}
AVSINLINE HRESULT get_PenAlign(LONG* val)
{
*val = m_oPen.Align;
return S_OK;
}
AVSINLINE HRESULT put_PenAlign(LONG val)
{
m_oPen.Align = val;
return S_OK;
}
AVSINLINE HRESULT get_PenMiterLimit(double* val)
{
*val = m_oPen.MiterLimit;
return S_OK;
}
AVSINLINE HRESULT put_PenMiterLimit(double val)
{
m_oPen.MiterLimit = val;
return S_OK;
}
AVSINLINE HRESULT PenDashPattern(SAFEARRAY* pPattern)
{
if (NULL != pPattern)
{
m_oPen.SetDashPattern((double*)pPattern->pvData, pPattern->rgsabound[0].cElements);
}
return S_OK;
}
// brush ------------------------------------------------------------------------------------
AVSINLINE HRESULT SetBrush(BSTR bsXML)
{
m_oBrush.FromXmlString((CString)bsXML);
return S_OK;
}
AVSINLINE HRESULT get_BrushType(LONG* lType)
{
*lType = m_oBrush.Type;
return S_OK;
}
AVSINLINE HRESULT put_BrushType(LONG lType)
{
m_oBrush.Type = lType;
return S_OK;
}
AVSINLINE HRESULT get_BrushColor1(LONG* lColor)
{
*lColor = m_oBrush.Color1;
return S_OK;
}
AVSINLINE HRESULT put_BrushColor1(LONG lColor)
{
m_oBrush.Color1 = lColor;
return S_OK;
}
AVSINLINE HRESULT get_BrushAlpha1(LONG* lAlpha)
{
*lAlpha = m_oBrush.Alpha1;
return S_OK;
}
AVSINLINE HRESULT put_BrushAlpha1(LONG lAlpha)
{
m_oBrush.Alpha1 = lAlpha;
return S_OK;
}
AVSINLINE HRESULT get_BrushColor2(LONG* lColor)
{
*lColor = m_oBrush.Color2;
return S_OK;
}
AVSINLINE HRESULT put_BrushColor2(LONG lColor)
{
m_oBrush.Color2 = lColor;
return S_OK;
}
AVSINLINE HRESULT get_BrushAlpha2(LONG* lAlpha)
{
*lAlpha = m_oBrush.Alpha2;
return S_OK;
}
AVSINLINE HRESULT put_BrushAlpha2(LONG lAlpha)
{
m_oBrush.Alpha2 = lAlpha;
return S_OK;
}
AVSINLINE HRESULT get_BrushTexturePath(BSTR* bsPath)
{
*bsPath = m_oBrush.TexturePath.AllocSysString();
return S_OK;
}
AVSINLINE HRESULT put_BrushTexturePath(BSTR bsPath)
{
m_oBrush.TexturePath = (CString)bsPath;
return S_OK;
}
AVSINLINE HRESULT get_BrushTextureMode(LONG* lMode)
{
*lMode = m_oBrush.TextureMode;
return S_OK;
}
AVSINLINE HRESULT put_BrushTextureMode(LONG lMode)
{
m_oBrush.TextureMode = lMode;
return S_OK;
}
AVSINLINE HRESULT get_BrushTextureAlpha(LONG* lTxAlpha)
{
*lTxAlpha = m_oBrush.TextureAlpha;
return S_OK;
}
AVSINLINE HRESULT put_BrushTextureAlpha(LONG lTxAlpha)
{
m_oBrush.TextureAlpha = lTxAlpha;
return S_OK;
}
AVSINLINE HRESULT get_BrushLinearAngle(double* dAngle)
{
*dAngle = m_oBrush.LinearAngle;
return S_OK;
}
AVSINLINE HRESULT put_BrushLinearAngle(double dAngle)
{
m_oBrush.LinearAngle = dAngle;
return S_OK;
}
AVSINLINE HRESULT BrushRect(BOOL val, double left, double top, double width, double height)
{
m_oBrush.Rectable = val;
m_oBrush.Rect.X = (float)left;
m_oBrush.Rect.Y = (float)top;
m_oBrush.Rect.Width = (float)width;
m_oBrush.Rect.Height = (float)height;
return S_OK;
}
// font -------------------------------------------------------------------------------------
AVSINLINE HRESULT SetFont(BSTR bsXML)
{
m_oFont.FromXmlString((CString)bsXML);
return S_OK;
}
AVSINLINE HRESULT get_FontName(BSTR* bsName)
{
*bsName = m_oFont.Name.AllocSysString();
return S_OK;
}
AVSINLINE HRESULT put_FontName(BSTR bsName)
{
m_oFont.Name = (CString)bsName;
return S_OK;
}
AVSINLINE HRESULT get_FontPath(BSTR* bsName)
{
*bsName = m_oFont.Path.AllocSysString();
return S_OK;
}
AVSINLINE HRESULT put_FontPath(BSTR bsName)
{
m_oFont.Path = bsName;
return S_OK;
}
AVSINLINE HRESULT get_FontSize(double* dSize)
{
*dSize = m_oFont.Size;
return S_OK;
}
AVSINLINE HRESULT put_FontSize(double dSize)
{
m_oFont.Size = dSize;
return S_OK;
}
AVSINLINE HRESULT get_FontStyle(LONG* lStyle)
{
*lStyle = m_oFont.GetStyle();
return S_OK;
}
AVSINLINE HRESULT put_FontStyle(LONG lStyle)
{
m_oFont.SetStyle(lStyle);
return S_OK;
}
AVSINLINE HRESULT get_FontStringGID(BOOL* bGID)
{
*bGID = m_oFont.StringGID;
return S_OK;
}
AVSINLINE HRESULT put_FontStringGID(BOOL bGID)
{
m_oFont.StringGID = bGID;
return S_OK;
}
AVSINLINE HRESULT get_FontCharSpace(double* dSpace)
{
*dSpace = m_oFont.CharSpace;
return S_OK;
}
AVSINLINE HRESULT put_FontCharSpace(double dSpace)
{
m_oFont.CharSpace = dSpace;
return S_OK;
}
// shadow -----------------------------------------------------------------------------------
AVSINLINE HRESULT SetShadow(BSTR bsXML)
{
m_oShadow.FromXmlString((CString)bsXML);
return S_OK;
}
AVSINLINE HRESULT get_ShadowDistanceX(double* val)
{
*val = m_oShadow.DistanceX;
return S_OK;
}
AVSINLINE HRESULT put_ShadowDistanceX(double val)
{
m_oShadow.DistanceX = val;
return S_OK;
}
AVSINLINE HRESULT get_ShadowDistanceY(double* val)
{
*val = m_oShadow.DistanceY;
return S_OK;
}
AVSINLINE HRESULT put_ShadowDistanceY(double val)
{
m_oShadow.DistanceY = val;
return S_OK;
}
AVSINLINE HRESULT get_ShadowBlurSize(double* val)
{
*val = m_oShadow.BlurSize;
return S_OK;
}
AVSINLINE HRESULT put_ShadowBlurSize(double val)
{
m_oShadow.BlurSize = val;
return S_OK;
}
AVSINLINE HRESULT get_ShadowColor(LONG* val)
{
*val = m_oShadow.Color;
return S_OK;
}
AVSINLINE HRESULT put_ShadowColor(LONG val)
{
m_oShadow.Color = val;
return S_OK;
}
AVSINLINE HRESULT get_ShadowAlpha(LONG* val)
{
*val = m_oShadow.Alpha;
return S_OK;
}
AVSINLINE HRESULT put_ShadowAlpha(LONG val)
{
m_oShadow.Alpha = val;
return S_OK;
}
AVSINLINE HRESULT get_ShadowVisible(BOOL* val)
{
*val = m_oShadow.Visible;
return S_OK;
}
AVSINLINE HRESULT put_ShadowVisible(BOOL val)
{
m_oShadow.Visible = val;
return S_OK;
}
// edge -------------------------------------------------------------------------------------
AVSINLINE HRESULT SetEdgeText(BSTR bsXML)
{
m_oEdge.FromXmlString((CString)bsXML);
return S_OK;
}
AVSINLINE HRESULT get_EdgeVisible(LONG* val)
{
*val = m_oEdge.Visible;
return S_OK;
}
AVSINLINE HRESULT put_EdgeVisible(LONG val)
{
m_oEdge.Visible = val;
return S_OK;
}
AVSINLINE HRESULT get_EdgeColor(LONG* val)
{
*val = m_oEdge.Color;
return S_OK;
}
AVSINLINE HRESULT put_EdgeColor(LONG val)
{
m_oEdge.Color = val;
return S_OK;
}
AVSINLINE HRESULT get_EdgeAlpha(LONG* val)
{
*val = m_oEdge.Alpha;
return S_OK;
}
AVSINLINE HRESULT put_EdgeAlpha(LONG val)
{
m_oEdge.Alpha = val;
return S_OK;
}
AVSINLINE HRESULT get_EdgeDist(double* val)
{
*val = m_oEdge.Dist;
return S_OK;
}
AVSINLINE HRESULT put_EdgeDist(double val)
{
m_oEdge.Dist = val;
return S_OK;
}
//-------- --------------------------------------------------------
AVSINLINE HRESULT CommandDrawText(BSTR bsText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset)
{
double dAngleMatrix = m_oTransform.z_Rotation();
if (abs(dAngleMatrix) > 1)
{
PathCommandEnd();
BeginCommand(c_nPathType);
PathCommandText(bsText, fX, fY, fWidth, fHeight, fBaseLineOffset);
DrawPath(c_nWindingFillMode);
EndCommand(c_nPathType);
PathCommandEnd();
return S_OK;
}
m_oCurrentPage.WriteText(bsText, NULL, fX, fY, fWidth, fHeight, fBaseLineOffset, m_bIsNeedPDFTextAnalyzer);
return S_OK;
}
AVSINLINE HRESULT CommandDrawTextEx(BSTR bsUnicodeText, BSTR bsGidText, BSTR bsSourceCodeText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags)
{
double dAngleMatrix = m_oTransform.z_Rotation();
if (abs(dAngleMatrix) > 1)
{
PathCommandEnd();
BeginCommand(c_nPathType);
PathCommandTextEx(bsUnicodeText, bsGidText, bsSourceCodeText, fX, fY, fWidth, fHeight, fBaseLineOffset, lFlags);
DrawPath(c_nWindingFillMode);
EndCommand(c_nPathType);
PathCommandEnd();
return S_OK;
}
m_oCurrentPage.WriteText(bsUnicodeText, bsGidText, fX, fY, fWidth, fHeight, fBaseLineOffset, m_bIsNeedPDFTextAnalyzer);
return S_OK;
}
//-------- ---------------------------------------------------------------
AVSINLINE HRESULT BeginCommand(DWORD lType)
{
m_lCurrentCommandType = (LONG)lType;
m_oCurrentPage.m_lCurrentCommand = m_lCurrentCommandType;
return S_OK;
}
AVSINLINE HRESULT EndCommand(DWORD lType)
{
m_lCurrentCommandType = -1;
m_oCurrentPage.m_lCurrentCommand = m_lCurrentCommandType;
if (c_nPageType == lType)
{
//
m_oCurrentPage.Build();
m_oCurrentPage.Write(m_oWriter);
}
else if (c_nPathType == lType)
{
m_oCurrentPage.End();
}
return S_OK;
}
//-------- Graphics Path -----------------------------------------------
AVSINLINE HRESULT PathCommandMoveTo(double fX, double fY)
{
if (c_nSimpleGraphicType == m_lCurrentCommandType)
{
m_oCurrentPage.MoveTo(fX, fY);
}
else
{
m_pSimpleGraphicsConverter->PathCommandMoveTo(fX, fY);
}
return S_OK;
}
AVSINLINE HRESULT PathCommandLineTo(double fX, double fY)
{
if (c_nSimpleGraphicType == m_lCurrentCommandType)
{
m_oCurrentPage.LineTo(fX, fY);
}
else
{
m_pSimpleGraphicsConverter->PathCommandLineTo(fX, fY);
}
return S_OK;
}
AVSINLINE HRESULT PathCommandLinesTo(SAFEARRAY* pPoints)
{
m_pSimpleGraphicsConverter->PathCommandLinesTo(pPoints);
return S_OK;
}
AVSINLINE HRESULT PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3)
{
if (c_nSimpleGraphicType == m_lCurrentCommandType)
{
m_oCurrentPage.CurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
}
else
{
m_pSimpleGraphicsConverter->PathCommandCurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
}
return S_OK;
}
AVSINLINE HRESULT PathCommandCurvesTo(SAFEARRAY* pPoints)
{
m_pSimpleGraphicsConverter->PathCommandCurvesTo(pPoints);
return S_OK;
}
AVSINLINE HRESULT PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle)
{
m_pSimpleGraphicsConverter->PathCommandArcTo(fX, fY, fWidth, fHeight, fStartAngle, fSweepAngle);
return S_OK;
}
AVSINLINE HRESULT PathCommandClose()
{
if (c_nSimpleGraphicType == m_lCurrentCommandType)
{
m_oCurrentPage.Close();
}
else
{
m_pSimpleGraphicsConverter->PathCommandClose();
}
return S_OK;
}
AVSINLINE HRESULT PathCommandEnd()
{
if (c_nSimpleGraphicType == m_lCurrentCommandType)
{
m_oCurrentPage.End();
}
else
{
m_pSimpleGraphicsConverter->PathCommandEnd();
}
return S_OK;
}
AVSINLINE HRESULT DrawPath(long nType)
{
LONG lTxId = -1;
if ((nType > 0xFF) && (c_BrushTypeTexture == m_oBrush.Type))
{
double x = 0;
double y = 0;
double w = 0;
double h = 0;
CImageInfo oInfo = m_oManager.WriteImage(m_oBrush.TexturePath, x, y, w, h);
lTxId = oInfo.m_lID;
}
m_oCurrentPage.DrawPath(nType, lTxId);
return S_OK;
}
AVSINLINE HRESULT PathCommandStart()
{
if (c_nSimpleGraphicType == m_lCurrentCommandType)
{
m_oCurrentPage.Start();
}
else
{
m_pSimpleGraphicsConverter->PathCommandStart();
}
return S_OK;
}
AVSINLINE HRESULT PathCommandGetCurrentPoint(double* fX, double* fY)
{
m_pSimpleGraphicsConverter->PathCommandGetCurrentPoint(fX, fY);
return S_OK;
}
AVSINLINE HRESULT PathCommandText(BSTR bsText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset)
{
_SetFont();
m_pSimpleGraphicsConverter->PathCommandText(bsText, m_pFontManager, fX, fY, fWidth, fHeight, fBaseLineOffset);
return S_OK;
}
AVSINLINE HRESULT PathCommandTextEx(BSTR bsUnicodeText, BSTR bsGidText, BSTR bsSourceCodeText, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags)
{
if (NULL != bsGidText)
{
m_oFont.StringGID = TRUE;
return PathCommandText(bsGidText, fX, fY, fWidth, fHeight, fBaseLineOffset);
}
m_oFont.StringGID = FALSE;
return PathCommandText(bsUnicodeText, fX, fY, fWidth, fHeight, fBaseLineOffset);
}
AVSINLINE HRESULT GetCommandParams(double* dAngle, double* dLeft, double* dTop, double* dWidth, double* dHeight, DWORD* lFlags)
{
return S_OK;
}
AVSINLINE HRESULT SetCommandParams(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags)
{
ApplyTransform2(dAngle, dLeft, dTop, dWidth, dHeight, lFlags);
return S_OK;
}
//-------- --------------------------------------------------
AVSINLINE HRESULT DrawImage(IUnknown* pInterface, double fX, double fY, double fWidth, double fHeight)
{
CImageInfo oInfo = m_oManager.WriteImage(pInterface, fX, fY, fWidth, fHeight);
m_oCurrentPage.WriteImage(oInfo, fX, fY, fWidth, fHeight);
return S_OK;
}
AVSINLINE HRESULT DrawImageFromFile(BSTR bstrVal, double fX, double fY, double fWidth, double fHeight)
{
CImageInfo oInfo = m_oManager.WriteImage((CString)bstrVal, fX, fY, fWidth, fHeight);
m_oCurrentPage.WriteImage(oInfo, fX, fY, fWidth, fHeight);
return S_OK;
}
//------------------------------------------------------------------------------------------
AVSINLINE HRESULT SetAdditionalParam(BSTR ParamName, VARIANT ParamValue)
{
return S_OK;
}
AVSINLINE HRESULT GetAdditionalParam(BSTR ParamName, VARIANT* ParamValue)
{
return S_OK;
}
AVSINLINE HRESULT SetTransform(double dA, double dB, double dC, double dD, double dE, double dF)
{
ApplyTransform(dA, dB, dC, dD, dE, dF);
return S_OK;
}
AVSINLINE HRESULT GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF)
{
return S_OK;
}
AVSINLINE HRESULT ResetTransform(void)
{
m_oTransform.Reset();
return S_OK;
}
AVSINLINE HRESULT get_ClipMode(LONG* plMode)
{
*plMode = m_lClipMode;
return S_OK;
}
AVSINLINE HRESULT put_ClipMode(LONG lMode)
{
m_lClipMode = lMode;
return S_OK;
}
protected:
AVSINLINE void ApplyTransform(double d1, double d2, double d3, double d4, double d5, double d6)
{
m_oTransform.SetElements(d1, d2, d3, d4, d5, d6);
}
void ApplyTransform2(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, DWORD lFlags)
{
if ((dWidth <= 1) || (dHeight <= 1))
lFlags = 0;
BOOL bFlipX = (0 != (c_nParamFlipX & lFlags));
BOOL bFlipY = (0 != (c_nParamFlipY & lFlags));
double m11 = bFlipX ? -1.0 : 1.0;
double m22 = bFlipY ? -1.0 : 1.0;
NSDocxRenderer::CMatrix oMatrix(1, 0, 0, 1, 0, 0);
if ((0 != dAngle) || (0 != lFlags))
{
double dCentreX = (dLeft + dWidth / 2.0);
double dCentreY = (dTop + dHeight / 2.0);
oMatrix.Translate(-dCentreX, -dCentreY , Aggplus::MatrixOrderAppend);
oMatrix.Rotate(dAngle , Aggplus::MatrixOrderAppend);
oMatrix.Scale(m11, m22 , Aggplus::MatrixOrderAppend);
oMatrix.Translate(dCentreX, dCentreY , Aggplus::MatrixOrderAppend);
}
m_oTransform = oMatrix;
}
void _SetFont()
{
if (NULL == m_pFontManager)
{
CoCreateInstance(__uuidof(AVSGraphics::CASCFontManager), NULL, CLSCTX_ALL, __uuidof(AVSGraphics::IASCFontManager), (void**)&m_pFontManager);
m_pFontManager->Initialize(L"");
}
double dPix = m_oFont.CharSpace * m_dDpiX / 25.4;
if (m_oInstalledFont.IsEqual(&m_oFont))
{
if (1 < m_dWidth)
{
m_pFontManager->SetCharSpacing(dPix);
}
return;
}
m_pFontManager->SetStringGID(m_oFont.StringGID);
if (1 < m_dWidth)
{
m_pFontManager->SetCharSpacing(dPix);
}
if (_T("") == m_oFont.Path)
{
BSTR bsName = m_oFont.Name.AllocSysString();
m_pFontManager->LoadFontByName(bsName, (float)m_oFont.Size, m_oFont.GetStyle(), m_dDpiX, m_dDpiY);
SysFreeString(bsName);
}
else
{
BSTR bsName = m_oFont.Path.AllocSysString();
m_pFontManager->LoadFontFromFile(bsName, (float)m_oFont.Size, m_dDpiX, m_dDpiY, 0);
SysFreeString(bsName);
}
m_oInstalledFont = m_oFont;
}
public:
bool CreateDocument(IUnknown* pRenderer, CString strTempDirectory)
{
HINSTANCE hInst = _AtlBaseModule.GetModuleInstance();
m_strTempDirectory = strTempDirectory;
// rels
CString strRels = strTempDirectory + _T("\\_rels");
CDirectory::CreateDirectory(strRels);
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_RELS), _T("DOCXREND"), strRels + _T("\\.rels"));
// docProps
CString strDocProps = strTempDirectory + _T("\\docProps");
CDirectory::CreateDirectory(strDocProps);
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_APP), _T("DOCXREND"), strDocProps + _T("\\app.xml"));
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_CORE), _T("DOCXREND"), strDocProps + _T("\\core.xml"));
// contentTypes
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_CONTENT_TYPES), _T("DOCXREND"), strTempDirectory + _T("\\[Content_Types].xml"));
// word
CString strWord = strTempDirectory + _T("\\word");
CDirectory::CreateDirectory(strWord);
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_SETTINGS), _T("DOCXREND"), strWord + _T("\\settings.xml"));
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_STYLES), _T("DOCXREND"), strWord + _T("\\styles.xml"));
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_WEBSETTINGS), _T("DOCXREND"), strWord + _T("\\webSettings.xml"));
// theme
CString strTheme = strWord + _T("\\theme");
CDirectory::CreateDirectory(strTheme);
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_THEME), _T("DOCXREND"), strTheme + _T("\\theme.xml"));
// documentRels
CDirectory::CreateDirectory(strWord + _T("\\_rels"));
// Init
Clear();
CoCreateInstance(__uuidof(AVSGraphics::CASCGraphicSimpleComverter), NULL, CLSCTX_ALL,
__uuidof(AVSGraphics::IASCGraphicSimpleComverter), (void**)&m_pSimpleGraphicsConverter);
m_punkRenderer = pRenderer;
ADDREFINTERFACE(m_punkRenderer);
m_pSimpleGraphicsConverter->put_Renderer(m_punkRenderer);
m_lCurrentCommandType = 0;
m_oCurrentPage.Init(&m_oFont, &m_oPen, &m_oBrush, &m_oShadow, &m_oEdge, &m_oTransform, m_pSimpleGraphicsConverter);
m_oManager.NewDocument();
// media
m_oManager.m_strDstMedia = strWord + _T("\\media");
CDirectory::CreateDirectory(m_oManager.m_strDstMedia);
m_oCurrentPage.m_oManager.m_oFontTable.m_mapTable.RemoveAll();
m_oDocumentStream.CloseFile();
m_oDocumentStream.CreateFile(strWord + _T("\\document.xml"));
m_oDocumentStream.WriteStringUTF8(g_string_DocumentStart);
m_lPagesCount = 0;
m_oWriter.Clear();
m_oWriter.AddSize(10000);
return true;
}
void Close()
{
// rels (images & docs)
CFile oFile;
oFile.CreateFile(m_strTempDirectory + _T("\\word\\_rels\\document.xml.rels"));
NSDocxRenderer::CStringWriter oWriter;
CString strStart = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>\
<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\" Target=\"settings.xml\"/>\
<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\" Target=\"webSettings.xml\"/>\
<Relationship Id=\"rId4\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\" Target=\"fontTable.xml\"/>\
<Relationship Id=\"rId5\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme.xml\"/>");
oWriter.WriteString(strStart);
POSITION pos = m_oManager.m_mapImageData.GetStartPosition();
while (NULL != pos)
{
CAtlMap<DWORD, CImageInfo>::CPair* pPair = m_oManager.m_mapImageData.GetNext(pos);
LONG lId = pPair->m_value.m_lID;
if (pPair->m_value.m_eType == itPNG)
{
CString strImage = _T("");
strImage.Format(g_string_imageRID_png, 10 + lId, lId);
oWriter.WriteString(strImage);
}
else
{
CString strImage = _T("");
strImage.Format(g_string_imageRID_jpg, 10 + lId, lId);
oWriter.WriteString(strImage);
}
}
pos = m_oManager.m_mapImagesFile.GetStartPosition();
while (NULL != pos)
{
CAtlMap<CString, CImageInfo>::CPair* pPair = m_oManager.m_mapImagesFile.GetNext(pos);
LONG lId = pPair->m_value.m_lID;
if (pPair->m_value.m_eType == itPNG)
{
CString strImage = _T("");
strImage.Format(g_string_imageRID_png, 10 + lId, lId);
oWriter.WriteString(strImage);
}
else
{
CString strImage = _T("");
strImage.Format(g_string_imageRID_jpg, 10 + lId, lId);
oWriter.WriteString(strImage);
}
}
CString strEnd = _T("</Relationships>");
oWriter.WriteString(strEnd);
oFile.WriteStringUTF8(oWriter.GetData());
oFile.CloseFile();
// fontTable
CFile oFileFontTable;
oFileFontTable.CreateFile(m_strTempDirectory + _T("\\word\\fontTable.xml"));
oWriter.ClearNoAttack();
strStart = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<w:fonts xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">");
oWriter.WriteString(strStart);
CFontTable* pFontTable = &m_oCurrentPage.m_oManager.m_oFontTable;
pos = pFontTable->m_mapTable.GetStartPosition();
while (NULL != pos)
{
CAtlMap<CString, CFontTableEntry>::CPair* pPair = pFontTable->m_mapTable.GetNext(pos);
oWriter.WriteString(g_bstr_FontNameStart);
oWriter.WriteString((CString)pPair->m_value.m_strFamilyName);
oWriter.WriteString(g_bstr_end2);
oWriter.WriteString(g_bstr_FontPanoseStart);
oWriter.WriteString(pPair->m_value.m_strPANOSE);
oWriter.WriteString(g_bstr_end);
oWriter.WriteString(g_bstr_FontCharsetStart);
oWriter.WriteString((CString)_T("00"));
oWriter.WriteString(g_bstr_end);
//oWriter.WriteString(g_bstr_FontFamilyStart);
//oWriter.WriteString((CString)_T("roman"));
//oWriter.WriteString(g_bstr_end);
if (pPair->m_value.m_bIsFixedWidth)
{
oWriter.WriteString(g_bstr_FontPitchTrue);
}
else
{
oWriter.WriteString(g_bstr_FontPitchFalse);
}
CString strSig = _T("");
strSig.Format(g_string_SIG, pPair->m_value.m_arSignature[0], pPair->m_value.m_arSignature[1], pPair->m_value.m_arSignature[2],
pPair->m_value.m_arSignature[3], pPair->m_value.m_arSignature[4], pPair->m_value.m_arSignature[5]);
oWriter.WriteString(strSig);
oWriter.WriteString(g_bstr_FontNameEnd);
}
strEnd = _T("</w:fonts>");
oWriter.WriteString(strEnd);
oFileFontTable.WriteStringUTF8(oWriter.GetData());
oFileFontTable.CloseFile();
// document
m_oCurrentPage.WriteSectionToFile(true, m_oWriter);
m_oWriter.WriteString(g_string_DocumentEnd);
m_oDocumentStream.WriteStringUTF8(m_oWriter.GetData());
m_oWriter.ClearNoAttack();
m_oDocumentStream.CloseFile();
}
protected:
void LoadResourceFile(HINSTANCE hInst, LPCTSTR sResName, LPCTSTR sResType, const CString& strDstFile)
{
HRSRC hrRes = FindResource(hInst, sResName, sResType);
if (!hrRes)
return;
HGLOBAL hGlobal = LoadResource(hInst, hrRes);
DWORD sz = SizeofResource(hInst, hrRes);
void* ptrRes = LockResource(hGlobal);
CFile oFile;
oFile.CreateFile(strDstFile);
oFile.WriteFile(ptrRes, sz);
UnlockResource(hGlobal);
FreeResource(hGlobal);
}
};
}
\ No newline at end of file
#pragma once
#include "Common.h"
namespace NSDocxRenderer
{
static _bstr_t g_bstr_image_1 = L"<w:r><w:pict><v:shape id=\"\" type=\"\" style=\"position:absolute;";
static _bstr_t g_bstr_image_2 = L"z-index:-1;mso-position-horizontal-relative:page;mso-position-vertical-relative:page\" filled=\"f\">";
static _bstr_t g_bstr_image_3 = L"</v:shape></w:pict></w:r>";
static CString g_string_image_position = _T("margin-left:%.2lfmm;margin-top:%.2lfmm;width:%.2lfmm;height:%.2lfmm;");
static CString g_string_image_position_rotate = _T("margin-left:%.2lfmm;margin-top:%.2lfmm;width:%.2lfmm;height:%.2lfmm;rotation:%d;");
static CString g_string_image_rid = _T("<v:imagedata r:id=\"rId%d\" o:title=\"\"/>");
class CImage : public CBaseItem
{
public:
CString m_strPath;
LONG m_lID;
double m_dLeft;
double m_dTop;
double m_dWidth;
double m_dHeight;
double m_dRotate;
public:
CImage()
{
m_eType = etImage;
m_strPath = _T("");
m_lID = -1;
}
CImage(const CImage& oSrc)
{
*this = oSrc;
}
CImage(const CImageInfo& oInfo, const CString& strDstMedia)
{
m_eType = etImage;
m_strPath = strDstMedia;
m_lID = oInfo.m_lID;
}
CImage& operator=(const CImage& oSrc)
{
m_eType = etImage;
m_strPath = oSrc.m_strPath;
m_lID = oSrc.m_lID;
m_dLeft = oSrc.m_dLeft;
m_dTop = oSrc.m_dTop;
m_dWidth = oSrc.m_dWidth;
m_dHeight = oSrc.m_dHeight;
m_dRotate = oSrc.m_dRotate;
return *this;
}
virtual void ToXml(NSDocxRenderer::CStringWriter& oWriter)
{
oWriter.WriteString(g_bstr_image_1);
if (0.0 == m_dRotate)
{
CString strPosition = _T("");
strPosition.Format(g_string_image_position, m_dLeft, m_dTop, m_dWidth, m_dHeight);
oWriter.WriteString(strPosition);
}
else
{
CString strPosition = _T("");
strPosition.Format(g_string_image_position_rotate, m_dLeft, m_dTop, m_dWidth, m_dHeight, (int)m_dRotate);
oWriter.WriteString(strPosition);
}
oWriter.WriteString(g_bstr_image_2);
CString strRid = _T("");
strRid.Format(g_string_image_rid, 10 + m_lID);
oWriter.WriteString(strRid);
oWriter.WriteString(g_bstr_image_3);
}
};
}
\ No newline at end of file
#pragma once
#include "Common.h"
//#include "../../Common/DocxFormat/Source/DocxFormat/Logic/Paragraph.h"
#include "FontManager.h"
namespace NSDocxRenderer
{
const double c_dMMToDx = 72 * 20 / 25.4;
// T IsBigger, IsBiggerOrEqual
template<typename T>
void SortElements(CAtlArray<T*>& oArray)
{
int nSize = (int)oArray.GetCount();
// handle 0, 1 and 2 elements
if (nSize <= 1)
return;
if (nSize == 2)
{
if (oArray[0]->IsBigger(oArray[1]))
{
T* pTemp = oArray[0];
oArray[0] = oArray[1];
oArray[1] = pTemp;
}
return;
}
T* tTemp;
// arrange elements as tree with greater elements appearing first
int nIndex = (nSize >> 1) - 1, nCurr = 0, nNext = 0;
int nLast = nSize - 1;
int nHalf = nSize >> 1;
do
{
// save element at start of chain
tTemp = oArray[nIndex];
nCurr = nIndex;
while (nCurr < nHalf)
{
nNext = (nCurr << 1) + 1;
if (nNext < nLast && (oArray[nNext + 1]->IsBigger(oArray[nNext])))
nNext++;
if (tTemp->IsBiggerOrEqual(oArray[nNext]))
break;
// promote element in chain
oArray[nCurr] = oArray[nNext];
nCurr = nNext;
}
// restore element at end of chain
oArray[nCurr] = tTemp;
}
while (nIndex--);
// sequentially reduce tree size by removing maximum element and rebalancing
nIndex = nSize;
while (--nIndex)
{
// save element at start of chain
tTemp = oArray[nIndex];
oArray[nIndex] = oArray[0];
nCurr = 0;
nLast = nIndex - 1;
nHalf = nIndex >> 1;
while (nCurr < nHalf)
{
nNext = (nCurr << 1) + 1;
if (nNext < nLast && (oArray[nNext + 1]->IsBigger(oArray[nNext])))
nNext++;
if (tTemp->IsBiggerOrEqual(oArray[nNext]))
break;
// promote element in chain
oArray[nCurr] = oArray[nNext];
nCurr = nNext;
}
// restore element at end of chain
oArray[nCurr] = tTemp;
}
}
static _bstr_t g_bstr_text_run_Start = L"<w:r><w:rPr>";
static _bstr_t g_bstr_text_run_PropEnd = L"</w:rPr>";
static _bstr_t g_bstr_text_run_End = L"</w:r>";
static _bstr_t g_bstr_text_run_text1 = L"<w:t xml:space=\"preserve\">";
static _bstr_t g_bstr_text_run_text2 = L"</w:t>";
static _bstr_t g_bstr_text_bold_true = L"<w:b w:val=\"true\"/>";
static _bstr_t g_bstr_text_italic_true = L"<w:i w:val=\"true\"/>";
static CString g_string_text_font_size = _T("<w:sz w:val=\"%d\"/><w:szCs w:val=\"%d\"/>");
static CString g_string_text_font_name = _T("<w:rFonts w:ascii=\"%s\" w:hAnsi=\"%s\" w:cs=\"%s\"/>");
static CString g_string_text_color = _T("<w:color w:val=\"%06x\"/>");
static CString g_string_text_paragraph_noframes = _T("<w:pPr><w:spacing w:before=\"%d\" w:line=\"%d\" w:lineRule=\"exact\"/><w:ind w:left=\"%d\"/></w:pPr>");
static _bstr_t g_bstr_text_par_start = L"<w:p>";
static _bstr_t g_bstr_text_par_end = L"</w:p>";
static CString g_string_spacing_character = _T("<w:spacing w:val=\"%d\"/>");
static CString g_string_spacing_character2 = _T("<w:spacing w:val=\"%.3lfpt\"/>");
static CString g_string_par_props_mode2 = _T("<w:pPr><w:framePr w:hAnchor=\"page\" w:vAnchor=\"page\" w:x=\"%d\" w:y=\"%d\"/></w:pPr>");
AVSINLINE void DeleteSpaces(CString& strText)
{
int nLen = strText.GetLength();
int nStart = 0;
while ((nStart < nLen) && (TCHAR(' ') == strText[nStart]))
++nStart;
if (nStart == nLen)
{
strText = _T("");
return;
}
int nEnd = nLen - 1;
while ((nEnd > nStart) && (TCHAR(' ') == strText[nEnd]))
--nEnd;
strText = strText.Mid(nStart, nEnd - nStart + 1);
}
class CContText
{
public:
NSStructures::CFont m_oFont;
NSStructures::CBrush m_oBrush;
CString m_strPickFontName;
LONG m_lPickFontStyle;
CString m_strText;
CString m_strGidText;
double m_dX;
double m_dY;
double m_dWidth;
double m_dHeight;
double m_dWidthWithoutSpaces;
double m_dLeftWithoutSpaces;
double m_dPosition;
double m_dSpaceWidthMM;
double m_dCalculateWidth;
public:
CContText()
{
m_strText = _T("");
m_strGidText = _T("");
m_strPickFontName = _T("");
m_lPickFontStyle = 0;
m_dX = 0;
m_dY = 0;
m_dWidth = 0;
m_dHeight = 0;
m_dWidthWithoutSpaces = 0;
m_dLeftWithoutSpaces = 0;
m_dPosition = 0;
m_dSpaceWidthMM = 0;
m_dCalculateWidth = 0;
}
~CContText()
{
}
AVSINLINE void Clear()
{
}
CContText(const CContText& oSrc)
{
*this = oSrc;
}
CContText& operator=(const CContText& oSrc)
{
m_oFont = oSrc.m_oFont;
m_oBrush = oSrc.m_oBrush;
m_strText = oSrc.m_strText;
m_strGidText = oSrc.m_strGidText;
m_strPickFontName = oSrc.m_strPickFontName;
m_lPickFontStyle = oSrc.m_lPickFontStyle;
m_dX = oSrc.m_dX;
m_dY = oSrc.m_dY;
m_dWidth = oSrc.m_dWidth;
m_dHeight = oSrc.m_dHeight;
m_dWidthWithoutSpaces = oSrc.m_dWidthWithoutSpaces;
m_dLeftWithoutSpaces = oSrc.m_dLeftWithoutSpaces;
m_dPosition = oSrc.m_dPosition;
m_dSpaceWidthMM = oSrc.m_dSpaceWidthMM;
m_dCalculateWidth = oSrc.m_dCalculateWidth;
return *this;
}
AVSINLINE bool IsBigger(const CContText* oSrc)
{
return (m_dX > oSrc->m_dX) ? true : false;
}
AVSINLINE bool IsBiggerOrEqual(const CContText* oSrc)
{
return (m_dX >= oSrc->m_dX) ? true : false;
}
AVSINLINE void Write(NSDocxRenderer::CStringWriter& oWriter, CFontManagerLight* pManagerLight, bool bIsAddSpace = false)
{
oWriter.WriteString(g_bstr_text_run_Start);
if (m_dWidth != m_dWidthWithoutSpaces)
{
DeleteSpaces(m_strText);
m_dWidth = m_dWidthWithoutSpaces;
}
if (_T("") == m_strPickFontName)
{
if (m_oFont.Bold)
oWriter.WriteString(g_bstr_text_bold_true);
if (m_oFont.Italic)
oWriter.WriteString(g_bstr_text_italic_true);
if (bIsAddSpace)
{
m_dWidth += m_dSpaceWidthMM;
m_strText += _T(" ");
}
}
else
{
if (0x01 == (0x01 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_bold_true);
if (0x02 == (0x02 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_italic_true);
if (bIsAddSpace)
{
m_dWidth += pManagerLight->GetSpaceWidth();
m_strText += _T(" ");
}
// ...
double ___dSize = (double)((LONG)(m_oFont.Size * 2)) / 2;
pManagerLight->LoadFont(m_strPickFontName, m_lPickFontStyle, ___dSize, FALSE);
double dWidth = pManagerLight->MeasureStringWidth(m_strText);
if (fabs(dWidth - m_dWidth) > 2)
{
double dSpacing = (m_dWidth - dWidth) / (m_strText.GetLength() + 1);
dSpacing *= c_dMMToDx;
CString strSpacing = _T("");
strSpacing.Format(g_string_spacing_character, (LONG)dSpacing);
oWriter.WriteString(strSpacing);
}
}
CString strSize = _T("");
LONG lSize = (LONG)(2 * m_oFont.Size);
strSize.Format(g_string_text_font_size, lSize, lSize);
oWriter.WriteString(strSize);
CString strName = _T("");
if (_T("") == m_strPickFontName)
strName.Format(g_string_text_font_name, m_oFont.Name, m_oFont.Name, m_oFont.Name);
else
strName.Format(g_string_text_font_name, m_strPickFontName, m_strPickFontName, m_strPickFontName);
oWriter.WriteString(strName);
CString strColor = _T("");
strColor.Format(g_string_text_color, ConvertColor(m_oBrush.Color1));
oWriter.WriteString(strColor);
oWriter.WriteString(g_bstr_text_run_PropEnd);
oWriter.WriteString(g_bstr_text_run_text1);
CString strText = m_strText;
CorrectString(strText);
oWriter.WriteString(strText);
oWriter.WriteString(g_bstr_text_run_text2);
oWriter.WriteString(g_bstr_text_run_End);
}
AVSINLINE void WriteTo(double dSpacingMM, NSDocxRenderer::CStringWriter& oWriter, CFontManagerLight* pManagerLight)
{
oWriter.WriteString(g_bstr_text_run_Start);
double dSpaceMMSize = m_dSpaceWidthMM;
if (_T("") == m_strPickFontName)
{
if (m_oFont.Bold)
oWriter.WriteString(g_bstr_text_bold_true);
if (m_oFont.Italic)
oWriter.WriteString(g_bstr_text_italic_true);
}
else
{
if (0x01 == (0x01 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_bold_true);
if (0x02 == (0x02 & m_lPickFontStyle))
oWriter.WriteString(g_bstr_text_italic_true);
dSpaceMMSize = pManagerLight->GetSpaceWidth();
}
CString strSize = _T("");
LONG lSize = (LONG)(2 * m_oFont.Size);
strSize.Format(g_string_text_font_size, lSize, lSize);
oWriter.WriteString(strSize);
CString strName = _T("");
if (_T("") == m_strPickFontName)
strName.Format(g_string_text_font_name, m_oFont.Name, m_oFont.Name, m_oFont.Name);
else
strName.Format(g_string_text_font_name, m_strPickFontName, m_strPickFontName, m_strPickFontName);
oWriter.WriteString(strName);
CString strColor = _T("");
strColor.Format(g_string_text_color, ConvertColor(m_oBrush.Color1));
oWriter.WriteString(strColor);
LONG lSpacing = (LONG)((dSpacingMM - dSpaceMMSize) * c_dMMToDx);
CString strSpacing = _T("");
strSpacing.Format(g_string_spacing_character, lSpacing);
oWriter.WriteString(strSpacing);
oWriter.WriteString(g_bstr_text_run_PropEnd);
oWriter.WriteString(g_bstr_text_run_text1);
CString strText = _T(" ");
oWriter.WriteString(strText);
oWriter.WriteString(g_bstr_text_run_text2);
oWriter.WriteString(g_bstr_text_run_End);
}
};
class CTextLine
{
public:
CAtlArray<CContText*> m_arConts;
double m_dBaselinePos;
double m_dBaselineOffset;
double m_dX;
double m_dY;
double m_dWidth;
double m_dHeight;
public:
CTextLine() : m_arConts()
{
m_dBaselinePos = 0;
m_dX = 0;
m_dY = 0;
m_dWidth = 0;
m_dHeight = 0;
}
AVSINLINE void Clear()
{
size_t nCount = m_arConts.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CContText* pText = m_arConts[i];
RELEASEOBJECT(pText);
}
m_arConts.RemoveAll();
}
~CTextLine()
{
Clear();
}
CTextLine(const CTextLine& oSrc)
{
*this = oSrc;
}
CTextLine& operator=(const CTextLine& oSrc)
{
Clear();
size_t nCount = oSrc.m_arConts.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
m_arConts.Add(new CContText(*oSrc.m_arConts[i]));
}
m_dBaselinePos = oSrc.m_dBaselinePos;
m_dX = oSrc.m_dX;
m_dY = oSrc.m_dY;
m_dWidth = oSrc.m_dWidth;
m_dHeight = oSrc.m_dHeight;
}
AVSINLINE void AddCont(CContText* pCont, double dBaselineOffset)
{
if (0 == m_arConts.GetCount())
m_dBaselineOffset = dBaselineOffset;
if ( ( pCont->m_dX > 0 ) && ( ( m_dX == 0 ) || ( pCont->m_dX < m_dX ) ) )
m_dX = pCont->m_dX;
if (m_dHeight < pCont->m_dHeight)
m_dHeight = pCont->m_dHeight;
m_arConts.Add(pCont);
}
AVSINLINE bool IsBigger(const CTextLine* oSrc)
{
return (m_dBaselinePos > oSrc->m_dBaselinePos) ? true : false;
}
AVSINLINE bool IsBiggerOrEqual(const CTextLine* oSrc)
{
return (m_dBaselinePos >= oSrc->m_dBaselinePos) ? true : false;
}
AVSINLINE void SortConts()
{
// m_dX
SortElements(m_arConts);
}
void Merge(CTextLine* pTextLine)
{
size_t nCount = pTextLine->m_arConts.GetCount();
if (0 != nCount)
{
if (pTextLine->m_dX < m_dX)
{
m_dX = pTextLine->m_dX;
}
if (pTextLine->m_dBaselinePos < m_dBaselinePos)
{
m_dHeight = (m_dBaselinePos - pTextLine->m_dBaselinePos + pTextLine->m_dHeight);
}
else
{
m_dHeight = (pTextLine->m_dBaselinePos - m_dBaselinePos + m_dHeight);
}
double dSubPosition = m_dBaselinePos - pTextLine->m_dBaselinePos;
for (size_t i = 0; i < nCount; ++i)
{
pTextLine->m_arConts[i]->m_dPosition = dSubPosition;
m_arConts.Add(pTextLine->m_arConts[i]);
}
}
}
void ToXml(NSDocxRenderer::CStringWriter& oWriter, CFontManagerLight* pManagerLight)
{
size_t nCountConts = m_arConts.GetCount();
if (0 == nCountConts)
return;
CContText* pPrev = m_arConts[0];
double dDelta = 0;
for (size_t i = 1; i < nCountConts; ++i)
{
CContText* pCurrent = m_arConts[i];
if (0 == pCurrent->m_dWidthWithoutSpaces)
continue;
dDelta = pCurrent->m_dLeftWithoutSpaces - (pPrev->m_dLeftWithoutSpaces + pPrev->m_dWidthWithoutSpaces);
if (dDelta < 0.5)
{
// (font/brush)
pPrev->Write(oWriter, pManagerLight);
pPrev = pCurrent;
}
//else if (dDelta < 2 * pPrev->m_dSpaceWidthMM)
//{
// // , -
// pPrev->Write(oWriter, pManagerLight, true);
// pPrev = pCurrent;
//}
else
{
// .
pPrev->Write(oWriter, pManagerLight);
pPrev->WriteTo(dDelta, oWriter, pManagerLight);
pPrev = pCurrent;
}
}
pPrev->Write(oWriter, pManagerLight);
}
};
class CParagraph : public CBaseItem
{
public:
// text frame properties
bool m_bIsTextFrameProperties;
// geometry paragraph
double m_dLeft;
double m_dTop;
double m_dWidth;
double m_dHeight;
CFontManagerLight* m_pManagerLight;
double m_dSpaceBefore;
TextAssociationType m_eTextAssociationType;
CAtlArray<CTextLine*> m_arLines;
public:
CParagraph(const TextAssociationType& eType) : m_arLines()
{
m_eType = etParagraph;
m_bIsTextFrameProperties = false;
m_dLeft = 0.0;
m_dTop = 0.0;
m_dWidth = 0.0;
m_dHeight = 0.0;
m_dSpaceBefore = 0.0;
m_pManagerLight = NULL;
m_eTextAssociationType = eType;
}
CParagraph(const CParagraph& oSrc)
{
*this = oSrc;
}
~CParagraph()
{
Clear();
}
AVSINLINE void Clear()
{
size_t nCount = m_arLines.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pText = m_arLines[i];
RELEASEOBJECT(pText);
}
m_arLines.RemoveAll();
m_pManagerLight = NULL;
}
CParagraph& operator=(const CParagraph& oSrc)
{
m_eType = etParagraph;
m_bIsTextFrameProperties = oSrc.m_bIsTextFrameProperties;
m_dLeft = oSrc.m_dLeft;
m_dTop = oSrc.m_dTop;
m_dWidth = oSrc.m_dWidth;
m_dHeight = oSrc.m_dHeight;
m_dSpaceBefore = oSrc.m_dSpaceBefore;
m_eTextAssociationType = oSrc.m_eTextAssociationType;
Clear();
size_t nCount = oSrc.m_arLines.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
m_arLines.Add(new CTextLine(*oSrc.m_arLines[i]));
}
m_pManagerLight = oSrc.m_pManagerLight;
return *this;
}
virtual void ToXml(NSDocxRenderer::CStringWriter& oWriter)
{
oWriter.WriteString(g_bstr_text_par_start);
switch (m_eTextAssociationType)
{
case TextAssociationTypeDefault:
case TextAssociationTypeLine:
{
LONG lX = (LONG)(m_dLeft * c_dMMToDx);
LONG lY = (LONG)(m_dTop * c_dMMToDx);
CString strTextProps = _T("");
strTextProps.Format(g_string_par_props_mode2, lX, lY);
oWriter.WriteString(strTextProps);
break;
}
case TextAssociationTypeBlock:
{
LONG lX = (LONG)(m_dLeft * c_dMMToDx);
LONG lY = (LONG)(m_dTop * c_dMMToDx);
CString strTextProps = _T("");
strTextProps.Format(g_string_par_props_mode2, lX, lY);
oWriter.WriteString(strTextProps);
break;
}
case TextAssociationTypeNoFrames:
{
LONG lSpaceBefore = (LONG)(m_dSpaceBefore * c_dMMToDx);
LONG lHeight = (LONG)(m_dHeight * c_dMMToDx);
LONG lLeft = (LONG)(m_dLeft * c_dMMToDx);
CString strParProperties = _T("");
strParProperties.Format(g_string_text_paragraph_noframes, lSpaceBefore, lHeight, lLeft);
oWriter.WriteString(strParProperties);
break;
}
default:
break;
}
size_t nCount = m_arLines.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arLines[i];
pTextLine->SortConts();
pTextLine->ToXml(oWriter, m_pManagerLight);
}
oWriter.WriteString(g_bstr_text_par_end);
}
};
}
\ No newline at end of file
#pragma once
#include "Common.h"
namespace NSDocxRenderer
{
static _bstr_t g_vml_bstr_ClosePath = L"x";
static _bstr_t g_vml_bstr_EndPath = L"e";
static _bstr_t g_vml_bstr_NoFill = L"nf";
static _bstr_t g_vml_bstr_NoStroke = L"ns";
static CString g_vml_string_MoveTo = _T("m%d,%d");
static CString g_vml_string_LineTo = _T("l%d,%d");
static CString g_vml_string_CurveTo = _T("c%d,%d %d,%d %d,%d");
static _bstr_t g_bstr_shape1 = L"<w:r><w:pict><v:shape id=\"\" o:spid=\"\" style=\"position:absolute;";
static _bstr_t g_bstr_shape2 = L"z-index:-1;mso-position-horizontal-relative:page;mso-position-vertical-relative:page;\"";
static CString g_string_shape_position = _T("margin-left:%.2lfmm;margin-top:%.2lfmm;width:%.2lfmm;height:%.2lfmm;");
static CString g_string_shape_geometry = _T(" coordsize=\"%d,%d\" path=\"%s\" fillcolor=\"#%06x\" strokecolor=\"#%06x\" strokeweight=\"%.2lfmm\">");
static CString g_string_tx_rid = _T("<v:imagedata r:id=\"rId%d\" o:title=\"\"/>");
static CString g_string_fill_opacity = _T("<v:fill opacity=\"%.2lf\"/>");
static CString g_string_stroke_opacity = _T("<v:stroke opacity=\"%.2lf\"/>");
static _bstr_t g_bstr_shape3 = L"<w10:wrap anchorx=\"page\" anchory=\"page\"/></v:shape></w:pict></w:r>";
class CVectorGraphics
{
public:
double* m_pData;
size_t m_lSize;
double* m_pDataCur;
size_t m_lSizeCur;
public:
double m_dLeft;
double m_dTop;
double m_dRight;
double m_dBottom;
public:
CVectorGraphics()
{
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = m_lSize;
End();
}
~CVectorGraphics()
{
RELEASEMEM(m_pData);
}
AVSINLINE void AddSize(size_t nSize)
{
if (NULL == m_pData)
{
m_lSize = max(nSize, 500);
m_pData = (double*)malloc(m_lSize * sizeof(double));
m_lSizeCur = 0;
m_pDataCur = m_pData;
return;
}
if ((m_lSizeCur + nSize) > m_lSize)
{
while ((m_lSizeCur + nSize) > m_lSize)
{
m_lSize *= 2;
}
double* pRealloc = (double*)realloc(m_pData, m_lSize * sizeof(double));
if (NULL != pRealloc)
{
//
m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur;
}
else
{
double* pMalloc = (double*)malloc(m_lSize * sizeof(double));
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(double));
free(m_pData);
m_pData = pMalloc;
m_pDataCur = m_pData + m_lSizeCur;
}
}
}
public:
AVSINLINE void MoveTo(const double& x1, const double& y1)
{
AddSize(3);
*m_pDataCur = 0; ++m_pDataCur;
*m_pDataCur = x1; ++m_pDataCur;
*m_pDataCur = y1; ++m_pDataCur;
m_lSizeCur += 3;
CheckPoint(x1, y1);
}
AVSINLINE void LineTo(const double& x1, const double& y1)
{
AddSize(3);
*m_pDataCur = 1; ++m_pDataCur;
*m_pDataCur = x1; ++m_pDataCur;
*m_pDataCur = y1; ++m_pDataCur;
m_lSizeCur += 3;
CheckPoint(x1, y1);
}
AVSINLINE void CurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3)
{
AddSize(7);
*m_pDataCur = 2; ++m_pDataCur;
*m_pDataCur = x1; ++m_pDataCur;
*m_pDataCur = y1; ++m_pDataCur;
*m_pDataCur = x2; ++m_pDataCur;
*m_pDataCur = y2; ++m_pDataCur;
*m_pDataCur = x3; ++m_pDataCur;
*m_pDataCur = y3; ++m_pDataCur;
m_lSizeCur += 7;
CheckPoint(x1, y1);
CheckPoint(x2, y2);
CheckPoint(x3, y3);
}
AVSINLINE void Close()
{
AddSize(1);
*m_pDataCur = 3; ++m_pDataCur;
m_lSizeCur += 1;
}
AVSINLINE size_t GetCurSize()
{
return m_lSizeCur;
}
AVSINLINE void Clear()
{
RELEASEMEM(m_pData);
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE void ClearNoAttack()
{
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
AVSINLINE void End()
{
ClearNoAttack();
m_dLeft = 0xFFFFFF;
m_dTop = 0xFFFFFF;
m_dRight = -0xFFFFFF;
m_dBottom = -0xFFFFFF;
}
AVSINLINE void CheckPoint(const double& x, const double& y)
{
if (m_dLeft > x)
m_dLeft = x;
if (m_dRight < x)
m_dRight = x;
if (m_dTop > y)
m_dTop = y;
if (m_dBottom < y)
m_dBottom = y;
}
};
class CShape : public CBaseItem
{
public:
CString m_strPath;
NSStructures::CBrush m_oBrush;
NSStructures::CPen m_oPen;
double m_dLeft;
double m_dTop;
double m_dWidth;
double m_dHeight;
bool m_bIsFill;
bool m_bIsStroke;
LONG m_lCoordSizeX;
LONG m_lCoordSizeY;
LONG m_lTxId;
public:
CShape()
{
m_dLeft = 0;
m_dTop = 0;
m_dWidth = 0;
m_dHeight = 0;
m_bIsFill = false;
m_bIsStroke = false;
m_lCoordSizeX = 100000;
m_lCoordSizeY = 100000;
m_lTxId = -1;
}
CShape(const CShape& oSrc)
{
*this = oSrc;
}
CShape& operator=(const CShape& oSrc)
{
m_eType = etShape;
m_strPath = oSrc.m_strPath;
m_oBrush = oSrc.m_oBrush;
m_oPen = oSrc.m_oPen;
m_dLeft = oSrc.m_dLeft;
m_dTop = oSrc.m_dTop;
m_dWidth = oSrc.m_dWidth;
m_dHeight = oSrc.m_dHeight;
m_bIsFill = oSrc.m_bIsFill;
m_bIsStroke = oSrc.m_bIsStroke;
m_lTxId = oSrc.m_lTxId;
return *this;
}
void CreateFromVectorData(CVectorGraphics* pVector, NSDocxRenderer::CStringWriter& oWriter, const LONG& lCoordSize, LONG lType)
{
m_dLeft = pVector->m_dLeft;
m_dTop = pVector->m_dTop;
m_dWidth = pVector->m_dRight - m_dLeft;
m_dHeight = pVector->m_dBottom - m_dTop;
m_lCoordSizeX = lCoordSize;
m_lCoordSizeY = lCoordSize;
size_t nCount = pVector->GetCurSize();
double* pData = pVector->m_pData;
while (nCount > 0)
{
double dType = *pData++;
if (0 == dType)
{
LONG lX = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
CString strPath = _T("");
strPath.Format(g_vml_string_MoveTo, lX, lY);
oWriter.WriteString(strPath);
nCount -= 3;
}
else if (1 == dType)
{
LONG lX = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
CString strPath = _T("");
strPath.Format(g_vml_string_LineTo, lX, lY);
oWriter.WriteString(strPath);
nCount -= 3;
}
else if (2 == dType)
{
LONG lX1 = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY1 = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
LONG lX2 = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY2 = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
LONG lX3 = (LONG)((*pData - m_dLeft) * lCoordSize / m_dWidth);
++pData;
LONG lY3 = (LONG)((*pData - m_dTop) * lCoordSize / m_dHeight);
++pData;
CString strPath = _T("");
strPath.Format(g_vml_string_CurveTo, lX1, lY1, lX2, lY2, lX3, lY3);
oWriter.WriteString(strPath);
nCount -= 7;
}
else
{
oWriter.WriteString(g_vml_bstr_ClosePath);
--nCount;
}
}
if (0x00 == (lType & 0x01))
oWriter.WriteString(g_vml_bstr_NoStroke);
if (0x00 == (lType >> 8))
oWriter.WriteString(g_vml_bstr_NoFill);
oWriter.WriteString(g_vml_bstr_EndPath);
m_strPath = oWriter.GetData();
oWriter.ClearNoAttack();
}
virtual void ToXml(NSDocxRenderer::CStringWriter& oWriter)
{
oWriter.WriteString(g_bstr_shape1);
CString strPosition = _T("");
strPosition.Format(g_string_shape_position, m_dLeft, m_dTop, m_dWidth, m_dHeight);
oWriter.WriteString(strPosition);
oWriter.WriteString(strPosition);
oWriter.WriteString(g_bstr_shape2);
CString strStyle = _T("");
strStyle.Format(g_string_shape_geometry, m_lCoordSizeX, m_lCoordSizeY, m_strPath, ConvertColor(m_oBrush.Color1), ConvertColor(m_oPen.Color), m_oPen.Size);
oWriter.WriteString(strStyle);
if (c_BrushTypeTexture == m_oBrush.Type)
{
CString strImage = _T("");
strImage.Format(g_string_tx_rid, 10 + m_lTxId);
oWriter.WriteString(strImage);
if (0xFF != m_oBrush.TextureAlpha)
{
CString strFillOpacity = _T("");
strFillOpacity.Format(g_string_fill_opacity, (double)m_oBrush.TextureAlpha / 255.0);
oWriter.WriteString(strFillOpacity);
}
}
else
{
if (0xFF != m_oBrush.Alpha1)
{
CString strFillOpacity = _T("");
strFillOpacity.Format(g_string_fill_opacity, (double)m_oBrush.Alpha1 / 255.0);
oWriter.WriteString(strFillOpacity);
}
if (0xFF != m_oPen.Alpha)
{
CString strPenOpacity = _T("");
strPenOpacity.Format(g_string_stroke_opacity, (double)m_oPen.Alpha / 255.0);
oWriter.WriteString(strPenOpacity);
}
}
oWriter.WriteString(g_bstr_shape3);
}
};
}
\ No newline at end of file
#pragma once
#include "windows.h"
class CFile
{
public:
CFile()
{
m_hFileHandle = NULL;
m_lFileSize = 0;
m_lFilePosition = 0;
}
virtual ~CFile()
{
CloseFile();
}
virtual HRESULT OpenFile(CString FileName)
{
CloseFile();
HRESULT hRes = S_OK;
DWORD AccessMode = GENERIC_READ;
DWORD ShareMode = FILE_SHARE_READ;
DWORD Disposition = OPEN_EXISTING;
m_hFileHandle = ::CreateFile(FileName, AccessMode, ShareMode, NULL, Disposition, FILE_ATTRIBUTE_NORMAL, NULL);
if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle)
hRes = S_FALSE;
else
{
ULARGE_INTEGER nTempSize;
nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart);
m_lFileSize = nTempSize.QuadPart;
SetPosition(0);
}
return hRes;
}
virtual HRESULT OpenFileRW(CString FileName)
{
CloseFile();
HRESULT hRes = S_OK;
DWORD AccessMode = GENERIC_READ | GENERIC_WRITE;
DWORD ShareMode = FILE_SHARE_READ;
DWORD Disposition = OPEN_EXISTING;
m_hFileHandle = ::CreateFile(FileName, AccessMode, ShareMode, NULL, Disposition, 0, 0);
if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle)
{
hRes = S_FALSE;
}
else
{
ULARGE_INTEGER nTempSize;
nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart);
m_lFileSize = nTempSize.QuadPart;
SetPosition(0);
}
return hRes;
}
HRESULT ReadFile(BYTE* pData, DWORD nBytesToRead)
{
DWORD nBytesRead = 0;
if(NULL == pData)
return S_FALSE;
if(m_hFileHandle && (pData))
{
SetPosition(m_lFilePosition);
::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL);
m_lFilePosition += nBytesRead;
}
return S_OK;
}
HRESULT ReadFile2(BYTE* pData, DWORD nBytesToRead)
{
DWORD nBytesRead = 0;
if(NULL == pData)
return S_FALSE;
if(m_hFileHandle && (pData))
{
SetPosition(m_lFilePosition);
::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL);
m_lFilePosition += nBytesRead;
for (size_t index = 0; index < nBytesToRead / 2; ++index)
{
BYTE temp = pData[index];
pData[index] = pData[nBytesToRead - index - 1];
pData[nBytesToRead - index - 1] = temp;
}
}
return S_OK;
}
HRESULT ReadFile3(void* pData, DWORD nBytesToRead)
{
DWORD nBytesRead = 0;
if(NULL == pData)
return S_FALSE;
if(m_hFileHandle && (pData))
{
SetPosition(m_lFilePosition);
::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL);
m_lFilePosition += nBytesRead;
}
return S_OK;
}
HRESULT WriteFile(void* pData, DWORD nBytesToWrite)
{
if(m_hFileHandle)
{
DWORD dwWritten = 0;
::WriteFile(m_hFileHandle, pData, nBytesToWrite, &dwWritten, NULL);
m_lFilePosition += nBytesToWrite;
}
return S_OK;
}
HRESULT WriteFile2(void* pData, DWORD nBytesToWrite)
{
if(m_hFileHandle)
{
BYTE* mem = new BYTE[nBytesToWrite];
memcpy(mem, pData, nBytesToWrite);
for (size_t index = 0; index < nBytesToWrite / 2; ++index)
{
BYTE temp = mem[index];
mem[index] = mem[nBytesToWrite - index - 1];
mem[nBytesToWrite - index - 1] = temp;
}
DWORD dwWritten = 0;
::WriteFile(m_hFileHandle, (void*)mem, nBytesToWrite, &dwWritten, NULL);
m_lFilePosition += nBytesToWrite;
RELEASEARRAYOBJECTS(mem);
}
return S_OK;
}
HRESULT CreateFile(CString strFileName)
{
CloseFile();
DWORD AccessMode = GENERIC_WRITE;
DWORD ShareMode = FILE_SHARE_WRITE;
DWORD Disposition = CREATE_ALWAYS;
m_hFileHandle = ::CreateFile(strFileName, AccessMode, ShareMode, NULL, Disposition, FILE_ATTRIBUTE_NORMAL, NULL);
return SetPosition(0);
}
HRESULT SetPosition( ULONG64 nPos )
{
if (m_hFileHandle && nPos < (ULONG)m_lFileSize)
{
LARGE_INTEGER nTempPos;
nTempPos.QuadPart = nPos;
::SetFilePointer(m_hFileHandle, nTempPos.LowPart, &nTempPos.HighPart, FILE_BEGIN);
m_lFilePosition = nPos;
return S_OK;
}
else
{
return (INVALID_HANDLE_VALUE == m_hFileHandle) ? S_FALSE : S_OK;
}
}
LONG64 GetPosition()
{
return m_lFilePosition;
}
HRESULT SkipBytes(ULONG64 nCount)
{
return SetPosition(m_lFilePosition + nCount);
}
HRESULT CloseFile()
{
m_lFileSize = 0;
m_lFilePosition = 0;
RELEASEHANDLE(m_hFileHandle);
return S_OK;
}
ULONG64 GetFileSize()
{
return m_lFileSize;
}
HRESULT WriteReserved(DWORD dwCount)
{
BYTE* buf = new BYTE[dwCount];
memset(buf, 0, (size_t)dwCount);
HRESULT hr = WriteFile(buf, dwCount);
RELEASEARRAYOBJECTS(buf);
return hr;
}
HRESULT WriteReserved2(DWORD dwCount)
{
BYTE* buf = new BYTE[dwCount];
memset(buf, 0xFF, (size_t)dwCount);
HRESULT hr = WriteFile(buf, dwCount);
RELEASEARRAYOBJECTS(buf);
return hr;
}
HRESULT WriteReservedTo(DWORD dwPoint)
{
if (m_lFilePosition >= dwPoint)
return S_OK;
DWORD dwCount = dwPoint - (DWORD)m_lFilePosition;
BYTE* buf = new BYTE[dwCount];
memset(buf, 0, (size_t)dwCount);
HRESULT hr = WriteFile(buf, dwCount);
RELEASEARRAYOBJECTS(buf);
return hr;
}
HRESULT SkipReservedTo(DWORD dwPoint)
{
if (m_lFilePosition >= dwPoint)
return S_OK;
DWORD dwCount = dwPoint - (DWORD)m_lFilePosition;
return SkipBytes(dwCount);
}
LONG GetProgress()
{
if (0 >= m_lFileSize)
return -1;
double dVal = (double)(100 * m_lFilePosition);
LONG lProgress = (LONG)(dVal / m_lFileSize);
return lProgress;
}
void WriteStringUTF8(CString& strXml)
{
int nLength = strXml.GetLength();
CStringA saStr;
#ifdef UNICODE
// Encoding Unicode to UTF-8
WideCharToMultiByte(CP_UTF8, 0, strXml.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
saStr.ReleaseBuffer();
#else
wchar_t* pWStr = new wchar_t[nLength + 1];
if (!pWStr)
return;
// set end string
pWStr[nLength] = 0;
// Encoding ASCII to Unicode
MultiByteToWideChar(CP_ACP, 0, strXml, nLength, pWStr, nLength);
int nLengthW = (int)wcslen(pWStr);
// Encoding Unicode to UTF-8
WideCharToMultiByte(CP_UTF8, 0, pWStr, nLengthW + 1, saStr.GetBuffer(nLengthW*3 + 1), nLengthW*3, NULL, NULL);
saStr.ReleaseBuffer();
delete[] pWStr;
#endif
WriteFile((void*)saStr.GetBuffer(), saStr.GetLength());
}
protected:
HANDLE m_hFileHandle;
LONG64 m_lFileSize;
LONG64 m_lFilePosition;
};
namespace CDirectory
{
static CString GetFolderName(CString strFolderPath)
{
int n1 = strFolderPath.ReverseFind('\\');
if (-1 == n1)
return _T("");
return strFolderPath.Mid(n1 + 1);
}
static BOOL OpenFile(CString strFolderPath, CString strFileName, CFile* pFile)
{
CString strFile = strFolderPath + '\\' + strFileName;
return (S_OK == pFile->OpenFile(strFile));
}
static BOOL CreateFile(CString strFolderPath, CString strFileName, CFile* pFile)
{
CString strFile = strFolderPath + '\\' + strFileName;
return (S_OK == pFile->CreateFile(strFile));
}
static BOOL CreateDirectory(CString strFolderPathRoot, CString strFolderName)
{
CString strFolder = strFolderPathRoot + '\\' + strFolderName;
return ::CreateDirectory(strFolder, NULL);
}
static BOOL CreateDirectory(CString strFolderPath)
{
return ::CreateDirectory(strFolderPath, NULL);
}
static BOOL MoveFile(CString strExists, CString strNew, LPPROGRESS_ROUTINE lpFunc, LPVOID lpData)
{
#if (_WIN32_WINNT >= 0x0500)
return ::MoveFileWithProgress(strExists, strNew, lpFunc, lpData, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
#else
return ::MoveFileEx(strExists, strNew, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
#endif
}
static BOOL CopyFile(CString strExists, CString strNew, LPPROGRESS_ROUTINE lpFunc, LPVOID lpData)
{
DeleteFile(strNew);
return ::CopyFileEx(strExists, strNew, lpFunc, lpData, FALSE, 0);
}
static CString GetUnder(CString strFolderPathRoot, CString strFolderName)
{
CString strFolder = strFolderPathRoot + '\\' + strFolderName;
return strFolder;
}
static CString GetFileName(CString strFullName)
{
int nStart = strFullName.ReverseFind('\\');
CString strName = strFullName.Mid(nStart + 1);
return strName;
}
static void SaveToFile(CString strFileName, CString strXml)
{
int nLength = strXml.GetLength();
CStringA saStr;
#ifdef UNICODE
// Encoding Unicode to UTF-8
WideCharToMultiByte(CP_UTF8, 0, strXml.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
saStr.ReleaseBuffer();
#else
wchar_t* pWStr = new wchar_t[nLength + 1];
if (!pWStr)
return;
// set end string
pWStr[nLength] = 0;
// Encoding ASCII to Unicode
MultiByteToWideChar(CP_ACP, 0, strXml, nLength, pWStr, nLength);
int nLengthW = (int)wcslen(pWStr);
// Encoding Unicode to UTF-8
WideCharToMultiByte(CP_UTF8, 0, pWStr, nLengthW + 1, saStr.GetBuffer(nLengthW*3 + 1), nLengthW*3, NULL, NULL);
saStr.ReleaseBuffer();
delete[] pWStr;
#endif
CFile oFile;
oFile.CreateFile(strFileName);
oFile.WriteFile((void*)saStr.GetBuffer(), saStr.GetLength());
oFile.CloseFile();
}
}
#pragma once
#include "Common.h"
#include "FontManagerBase.h"
namespace NSDocxRenderer
{
using namespace NSFontManager;
const double c_dDpiX = 72.0;
const double c_dDpiY = 72.0;
enum TextAssociationType
{
TextAssociationTypeDefault = 0,
TextAssociationTypeLine = 1,
TextAssociationTypeNoFrames = 2,
TextAssociationTypeBlock = 3
};
class CFontTableEntry
{
public:
CString m_strFamilyName;
CString m_strPANOSE;
LONG m_lStyle;
CAtlArray<DWORD> m_arSignature;
bool m_bIsFixedWidth;
public:
CFontTableEntry() : m_arSignature()
{
m_strFamilyName = _T("");
m_strPANOSE = _T("");
m_lStyle = 0;
m_bIsFixedWidth = false;
}
~CFontTableEntry()
{
}
CFontTableEntry(const CFontTableEntry& oSrc)
{
*this = oSrc;
}
CFontTableEntry& operator =(const CFontTableEntry& oSrc)
{
m_strFamilyName = oSrc.m_strFamilyName;
m_strPANOSE = oSrc.m_strPANOSE;
m_lStyle = oSrc.m_lStyle;
m_arSignature.Copy(oSrc.m_arSignature);
m_bIsFixedWidth = oSrc.m_bIsFixedWidth;
return *this;
}
};
class CFontTable
{
public:
CAtlMap<CString, CFontTableEntry> m_mapTable;
public:
CFontTable() : m_mapTable()
{
}
};
class CFontManager : public CFontManagerBase
{
public:
NSStructures::CFont* m_pFont;
NSDocxRenderer::CMatrix* m_pTransform;
double m_dSpaceWidthMM;
public:
CFontTable m_oFontTable;
public:
CFontManager() : m_pFont(NULL), CFontManagerBase()
{
m_pTransform = NULL;
m_dSpaceWidthMM = 0;
}
virtual ~CFontManager()
{
}
public:
AVSINLINE void Init()
{
m_oFontTable.m_mapTable.RemoveAll();
}
AVSINLINE void AddFontToMap()
{
CAtlMap<CString, CFontTableEntry>::CPair* pPair = m_oFontTable.m_mapTable.Lookup(m_oFont.m_strFamilyName);
if (NULL == pPair)
{
CFontTableEntry oEntry;
oEntry.m_strFamilyName = m_oFont.m_strFamilyName;
oEntry.m_strPANOSE = m_oFont.m_strPANOSE;
oEntry.m_lStyle = m_oFont.m_lStyle;
oEntry.m_bIsFixedWidth = m_oFont.m_bIsFixedWidth;
oEntry.m_arSignature.Copy(m_oFont.m_arSignature);
m_oFontTable.m_mapTable.SetAt(m_oFont.m_strFamilyName, oEntry);
}
}
public:
virtual void LoadFont(long lFaceIndex = 0, bool bNeedAddToMap = 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);
double dPix = m_pFont->CharSpace / c_dPixToMM;
m_pFont->Size = dSizeFont;
if (m_pFont->IsEqual2(&m_oFont.m_oFont))
{
m_pFont->Size = dSize;
m_pManager->SetCharSpacing(dPix);
m_pManager->SetStringGID(m_oFont.m_oFont.StringGID);
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(), c_dDpiX, c_dDpiY);
}
else
{
CFontManagerBase::LoadFontByFile(m_oFont.m_oFont.Path, m_oFont.m_oFont.Size, c_dDpiX, c_dDpiY, lFaceIndex);
m_pFont->SetStyle(m_oFont.m_lStyle);
m_oFont.m_oFont.SetStyle(m_oFont.m_lStyle);
bIsPath = true;
}
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);
LoadFontMetrics();
LoadFontParams(bIsPath);
if (bNeedAddToMap)
AddFontToMap();
}
AVSINLINE void MeasureString(const CString& strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
BSTR bsText = strText.AllocSysString();
MeasureString(bsText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
SysFreeString(bsText);
}
AVSINLINE void MeasureStringUNICODE(const CString& strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
m_pManager->SetStringGID(FALSE);
MeasureString(strText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
m_pManager->SetStringGID(TRUE);
}
AVSINLINE void MeasureStringUNICODE(BSTR strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
m_pManager->SetStringGID(FALSE);
MeasureString(strText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
m_pManager->SetStringGID(TRUE);
}
void MeasureString(BSTR bsText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
LoadFont();
dBoxX = 0;
dBoxY = 0;
dBoxWidth = 0;
dBoxHeight = 0;
if (NULL == m_pManager)
return;
m_pManager->LoadString(bsText, (float)x, (float)y);
float fx = 0;
float fy = 0;
float fwidth = 0;
float fheight = 0;
if (MeasureTypeGlyph == measureType)
{
m_pManager->MeasureString(&fx, &fy, &fwidth, &fheight);
}
else if (MeasureTypePosition == measureType)
{
m_pManager->MeasureString2(&fx, &fy, &fwidth, &fheight);
}
dBoxX = (double)fx;
dBoxY = (double)fy;
dBoxWidth = (double)fwidth;
dBoxHeight = (double)fheight;
//
dBoxX *= c_dPixToMM;
dBoxY *= c_dPixToMM;
dBoxWidth *= c_dPixToMM;
dBoxHeight *= c_dPixToMM;
}
__forceinline double GetBaseLineOffset()
{
LoadFont();
double d1 = 3 * (m_oFont.m_dLineSpacing - m_oFont.m_dDescent) - m_oFont.m_dAscent;
d1 /= 2.0;
d1 *= (m_oFont.m_oFont.Size / m_oFont.m_dEmHeight);
return d1;
}
__forceinline double GetFontHeight()
{
return c_dPtToMM * (m_oFont.m_dLineSpacing * m_oFont.m_oFont.Size ) / m_oFont.m_dEmHeight;
}
__forceinline void SetStringGid(const LONG& lGid)
{
if (NULL != m_pManager)
m_pManager->SetStringGID(lGid);
}
__forceinline void GenerateFontName2(CString& strText)
{
bool bIsNeedAddToMap = CFontManagerBase::GenerateFontName(strText);
if (bIsNeedAddToMap)
{
CAtlMap<CString, CFontTableEntry>::CPair* pPair = m_oFontTable.m_mapTable.Lookup(m_strCurrentPickFont);
if (NULL == pPair)
{
CFontTableEntry oEntry;
oEntry.m_strFamilyName = m_strCurrentPickFont;
oEntry.m_strPANOSE = m_oFont.m_strPANOSE;
oEntry.m_lStyle = m_oFont.m_lStyle;
oEntry.m_bIsFixedWidth = m_oFont.m_bIsFixedWidth;
oEntry.m_arSignature.Copy(m_oFont.m_arSignature);
m_oFontTable.m_mapTable.SetAt(m_oFont.m_oFont.Path, oEntry);
}
}
}
};
class CFontManagerLight
{
private:
CString m_strFontName;
LONG m_lFontStyle;
double m_dSize;
double m_dSpaceWidth;
AVSGraphics::IASCFontManager* m_pManager;
public:
CFontManagerLight()
{
m_strFontName = _T("");
m_lFontStyle = 0;
m_dSize = 0;
m_dSpaceWidth = 0;
m_pManager = NULL;
CoCreateInstance(AVSGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, AVSGraphics::IID_IASCFontManager, (void**)&m_pManager);
m_pManager->Initialize(L"");
m_pManager->SetDefaultFont(L"Arial");
}
~CFontManagerLight()
{
RELEASEINTERFACE(m_pManager);
}
AVSINLINE double GetSpaceWidth()
{
return m_dSpaceWidth;
}
public:
AVSINLINE void LoadFont(CString& strFontName, LONG& lStyle, double& dSize, const BOOL& bIsGID)
{
if ((strFontName == m_strFontName) && (lStyle == m_lFontStyle) && (dSize == m_dSize))
{
m_pManager->SetStringGID(bIsGID);
return;
}
m_strFontName = strFontName;
m_lFontStyle = lStyle;
m_dSize = dSize;
BSTR bsName = m_strFontName.AllocSysString();
m_pManager->LoadFontByName(bsName, (float)m_dSize, m_lFontStyle, c_dDpiX, c_dDpiY);
SysFreeString(bsName);
CString strSpace = _T(" ");
m_dSpaceWidth = MeasureStringWidth(strSpace);
m_pManager->SetStringGID(bIsGID);
}
AVSINLINE double MeasureStringWidth(CString& sText)
{
BSTR bsText = sText.AllocSysString();
m_pManager->LoadString(bsText, (float)0, (float)0);
SysFreeString(bsText);
float fx = 0;
float fy = 0;
float fwidth = 0;
float fheight = 0;
m_pManager->MeasureString2(&fx, &fy, &fwidth, &fheight);
return fwidth * c_dPixToMM;
}
};
}
\ No newline at end of file
#pragma once
#include "ElementShape.h"
#include "ElementParagraph.h"
#include "ElementImage.h"
namespace NSDocxRenderer
{
const double STANDART_STRING_HEIGHT_MM = 4.2333333333333334;
const double THE_SAME_STRING_Y_PRECISION_MM = 0.01;
static _bstr_t g_bstr_sectStart = L"<w:p><w:pPr><w:sectPr>";
static _bstr_t g_bstr_lastSect = L"<w:type w:val=\"continuous\"/>";
static _bstr_t g_bstr_sectEnd = L"<w:pgMar w:top=\"0\" w:right=\"0\" w:bottom=\"0\" w:left=\"0\"/></w:sectPr><w:spacing w:line=\"1\" w:lineRule=\"exact\"/></w:pPr></w:p>";
static CString g_string_sectSizeVer = _T("<w:pgSz w:w=\"%d\" w:h=\"%d\" w:orient=\"portrait\"/>");
static CString g_string_sectSizeHor = _T("<w:pgSz w:w=\"%d\" w:h=\"%d\" w:orient=\"landscape\"/>");
static _bstr_t g_bstr_drawingParStart = L"<w:p><w:pPr><w:spacing w:line=\"1\" w:lineRule=\"exact\"/></w:pPr>";
static _bstr_t g_bstr_ParEnd = L"</w:p>";
static CString g_bstr_lastsection1 = L"<w:sectPr>";
static CString g_bstr_lastsection2 = L"<w:pgMar w:top=\"0\" w:right=\"0\" w:bottom=\"0\" w:left=\"0\" w:header=\"0\" w:footer=\"0\" w:gutter=\"0\"/></w:sectPr>";
AVSINLINE bool IsUnicodeSymbol( WCHAR symbol )
{
bool result = false;
if ( ( 0x0009 == symbol ) || ( 0x000A == symbol ) || ( 0x000D == symbol ) ||
( ( 0x0020 <= symbol ) && ( 0xD7FF >= symbol ) ) || ( ( 0xE000 <= symbol ) && ( symbol <= 0xFFFD ) ) ||
( ( 0x10000 <= symbol ) && symbol ) )
{
result = true;
}
return result;
}
class CPage
{
public:
NSStructures::CFont* m_pFont;
NSStructures::CPen* m_pPen;
NSStructures::CBrush* m_pBrush;
NSStructures::CShadow* m_pShadow;
NSStructures::CEdgeText* m_pEdgeText;
NSDocxRenderer::CMatrix* m_pTransform;
AVSGraphics::IASCGraphicSimpleComverter* m_pSimpleGraphicsConverter;
CVectorGraphics m_oVector;
double m_dWidth;
double m_dHeight;
LONG m_lCurrentCommand;
CAtlArray<CBaseItem*> m_arGraphicItems;
CAtlArray<CParagraph*> m_arParagraphs;
CAtlArray<CTextLine*> m_arTextLine;
CTextLine* m_pCurrentLine;
CFontManager m_oManager;
CFontManagerLight m_oManagerLight;
TextAssociationType m_eTextAssociationType;
NSDocxRenderer::CStringWriter m_oWriterVML;
bool m_bIsDeleteTextClipPage;
public:
CPage() : m_oManager(), m_oManagerLight()
{
m_pFont = NULL;
m_pBrush = NULL;
m_pPen = NULL;
m_pShadow = NULL;
m_pEdgeText = NULL;
m_pTransform = NULL;
m_pSimpleGraphicsConverter = NULL;
m_dWidth = 0;
m_dHeight = 0;
m_pCurrentLine = NULL;
m_eTextAssociationType = TextAssociationTypeNoFrames;
m_bIsDeleteTextClipPage = true;
}
public:
AVSINLINE void Init(NSStructures::CFont* pFont, NSStructures::CPen* pPen, NSStructures::CBrush* pBrush,
NSStructures::CShadow* pShadow, NSStructures::CEdgeText* pEdge, NSDocxRenderer::CMatrix* pMatrix, AVSGraphics::IASCGraphicSimpleComverter* pSimple)
{
m_pFont = pFont;
m_pPen = pPen;
m_pBrush = pBrush;
m_pShadow = pShadow;
m_pEdgeText = pEdge;
m_pTransform = pMatrix;
m_pSimpleGraphicsConverter = pSimple;
m_oManager.m_pFont = m_pFont;
m_oManager.m_pTransform = m_pTransform;
m_pCurrentLine = NULL;
m_oWriterVML.AddSize(1000, 1000);
}
AVSINLINE void Clear()
{
size_t nCount = 0;
nCount = m_arTextLine.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTemp = m_arTextLine[i];
RELEASEOBJECT(pTemp);
}
m_arTextLine.RemoveAll();
nCount = m_arGraphicItems.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CBaseItem* pTemp = m_arGraphicItems[i];
RELEASEOBJECT(pTemp);
}
m_arGraphicItems.RemoveAll();
nCount = m_arParagraphs.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CParagraph* pTemp = m_arParagraphs[i];
RELEASEOBJECT(pTemp);
}
m_arParagraphs.RemoveAll();
m_pCurrentLine = NULL;
m_oWriterVML.ClearNoAttack();
}
~CPage()
{
Clear();
}
AVSINLINE void SetCurrentLineByBaseline(const double& dBaseLinePos)
{
if ((NULL == m_pCurrentLine) || (TextAssociationTypeDefault == m_eTextAssociationType))
{
// ( )
m_pCurrentLine = new CTextLine();
m_pCurrentLine->m_dBaselinePos = dBaseLinePos;
m_arTextLine.Add(m_pCurrentLine);
return;
}
if (fabs(m_pCurrentLine->m_dBaselinePos - dBaseLinePos) <= THE_SAME_STRING_Y_PRECISION_MM)
{
return;
}
size_t nCount = m_arTextLine.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
if (fabs(m_arTextLine[i]->m_dBaselinePos - dBaseLinePos) <= THE_SAME_STRING_Y_PRECISION_MM)
{
m_pCurrentLine = m_arTextLine[i];
return;
}
}
// - -
m_pCurrentLine = new CTextLine();
m_pCurrentLine->m_dBaselinePos = dBaseLinePos;
m_arTextLine.Add(m_pCurrentLine);
return;
}
// image commands
AVSINLINE void WriteImage(CImageInfo& oInfo, double& fX, double& fY, double& fWidth, double& fHeight)
{
CImage* pImage = new CImage(oInfo, _T(""));
double dRotation = m_pTransform->z_Rotation();
if (fabs(dRotation) < 5.0)
{
double x1 = fX;
double y1 = fY;
double x2 = fX + fWidth;
double y2 = fY + fHeight;
m_pTransform->TransformPoint(x1, y1);
m_pTransform->TransformPoint(x2, y2);
if (x1 <= x2)
{
pImage->m_dLeft = x1;
pImage->m_dWidth = x2 - x1;
}
else
{
pImage->m_dLeft = x2;
pImage->m_dWidth = x1 - x2;
}
if (y1 <= y2)
{
pImage->m_dTop = y1;
pImage->m_dHeight = y2 - y1;
}
else
{
pImage->m_dTop = y2;
pImage->m_dHeight = y1 - y2;
}
pImage->m_dRotate = 0.0;
}
else
{
double x1 = fX;
double y1 = fY;
double x2 = fX + fWidth;
double y2 = fY + fHeight;
NSDocxRenderer::CMatrix oTemp = *m_pTransform;
double dCx = (x1 + x2) / 2;
double dCy = (y1 + y2) / 2;
m_pTransform->TransformPoint(dCx, dCy);
oTemp.RotateAt(-dRotation, dCx, dCy, Aggplus::MatrixOrderAppend);
oTemp.TransformPoint(x1, y1);
oTemp.TransformPoint(x2, y2);
if (x1 <= x2)
{
pImage->m_dLeft = x1;
pImage->m_dWidth = x2 - x1;
}
else
{
pImage->m_dLeft = x2;
pImage->m_dWidth = x1 - x2;
}
if (y1 <= y2)
{
pImage->m_dTop = y1;
pImage->m_dHeight = y2 - y1;
}
else
{
pImage->m_dTop = y2;
pImage->m_dHeight = y1 - y2;
}
pImage->m_dRotate = dRotation;
}
m_arGraphicItems.Add(pImage);
}
// path commands
AVSINLINE void MoveTo(double& dX, double& dY)
{
m_pTransform->TransformPoint(dX, dY);
m_oVector.MoveTo(dX, dY);
}
AVSINLINE void LineTo(double& dX, double& dY)
{
m_pTransform->TransformPoint(dX, dY);
m_oVector.LineTo(dX, dY);
}
AVSINLINE void CurveTo(double& x1, double& y1, double& x2, double& y2, double& x3, double& y3)
{
m_pTransform->TransformPoint(x1, y1);
m_pTransform->TransformPoint(x2, y2);
m_pTransform->TransformPoint(x3, y3);
m_oVector.CurveTo(x1, y1, x2, y2, x3, y3);
}
AVSINLINE void Start()
{
}
AVSINLINE void End()
{
m_oVector.End();
m_oWriterVML.ClearNoAttack();
}
AVSINLINE void Close()
{
m_oVector.Close();
}
AVSINLINE void DrawPath(LONG lType, LONG lTxId)
{
if ((m_oVector.m_dLeft <= m_oVector.m_dRight) && (m_oVector.m_dTop <= m_oVector.m_dBottom))
{
CShape* pShape = new CShape();
pShape->m_lTxId = lTxId;
pShape->m_oPen = *m_pPen;
pShape->m_oBrush = *m_pBrush;
//
double dScaleTransform = (m_pTransform->m_agg_mtx.sx + m_pTransform->m_agg_mtx.sy) / 2.0;
pShape->m_oPen.Size *= dScaleTransform;
if ((lType & 0x01) == 0x00)
{
if ((fabs(m_oVector.m_dLeft - m_oVector.m_dRight) < 0.3) || (fabs(m_oVector.m_dTop - m_oVector.m_dBottom) < 0.3))
{
lType = 0x01;
pShape->m_bIsStroke = true;
pShape->m_oPen.Color = m_pBrush->Color1;
pShape->m_oPen.Alpha = m_pBrush->Alpha1;
//pShape->m_oPen.Size = max(pShape->m_oPen.Size, 1);
}
}
pShape->CreateFromVectorData(&m_oVector, m_oWriterVML, 100000, lType);
m_arGraphicItems.Add(pShape);
}
}
AVSINLINE void WriteText(BSTR bsText, BSTR bsGid, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, bool bIsPDFAnalyzer)
{
double dTextX = fX;
double dTextY = fY;
double dTextR = fX + fWidth;
double dTextB = fY + fHeight;
m_pTransform->TransformPoint(dTextX, dTextY);
m_pTransform->TransformPoint(dTextR, dTextB);
double dTextW = dTextR - dTextX;
double dTextH = dTextB - dTextY;
CString strText = _T("");
if ((bsText != NULL) && (bsGid != NULL))
{
UINT lLen = SysStringLen(bsText);
for (unsigned int i = 0; i < lLen; ++i)
{
if ( IsUnicodeSymbol( bsText[i] ) )
{
strText += bsText[i];
}
else
{
strText += _T(" ");
}
}
}
else
{
strText = (CString)bsText;
}
bool bIsPath = ((NULL == bsGid) && !bIsPDFAnalyzer) ? false : true;
m_oManager.LoadFont(0, !bIsPath);
if (bIsPath)
m_oManager.GenerateFontName2(strText);
if ((0 == dTextW) || (dTextW > 5 * m_oManager.m_dSpaceWidthMM))
{
double _x = 0;
double _y = 0;
double _w = 0;
double _h = 0;
if (NULL != bsGid)
{
m_oManager.SetStringGid(1);
m_oManager.MeasureString(bsGid, dTextX, dTextY, _x, _y, _w, _h, CFontManager::MeasureTypePosition);
}
else
{
// ( xps)
m_oManager.SetStringGid(0);
m_oManager.MeasureString(bsText, dTextX, dTextY, _x, _y, _w, _h, CFontManager::MeasureTypePosition);
}
dTextW = _w;
//dTextW *= c_dPixToMM;
}
double dBaseLinePos = dTextY + fBaseLineOffset;
dTextH = m_oManager.GetFontHeight();
SetCurrentLineByBaseline(dBaseLinePos);
CContText* pLastCont = NULL;
size_t nCountConts = m_pCurrentLine->m_arConts.GetCount();
if (nCountConts != 0)
pLastCont = m_pCurrentLine->m_arConts[nCountConts - 1];
if (NULL == pLastCont)
{
//
CContText* pCont = new CContText();
pCont->m_dX = dTextX;
pCont->m_dY = dBaseLinePos;
pCont->m_dWidth = dTextW;
pCont->m_dHeight = dTextH;
if (_T(" ") == strText)
{
pCont->m_dWidthWithoutSpaces = 0;
pCont->m_dLeftWithoutSpaces = dTextX + dTextW;
}
else
{
pCont->m_dWidthWithoutSpaces = dTextW;
pCont->m_dLeftWithoutSpaces = dTextX;
}
pCont->m_strText = strText;
pCont->m_oFont = m_oManager.m_oFont.m_oFont;
pCont->m_oBrush = *m_pBrush;
if (bIsPath)
{
pCont->m_strPickFontName = m_oManager.m_strCurrentPickFont;
pCont->m_lPickFontStyle = m_oManager.m_lCurrentPictFontStyle;
}
pCont->m_dSpaceWidthMM = m_oManager.m_dSpaceWidthMM;
m_pCurrentLine->AddCont(pCont, m_oManager.m_oFont.m_dBaselineOffset);
return;
}
//
//if (m_lCurrentCommand == c_nTextType && pLastCont->m_oFont.IsEqual(&m_oManager.m_oFontOld) && pLastCont->m_oBrush.IsEqual(m_pBrush))
//{
// //
// pLastCont->m_strText += strText;
// pLastCont->m_dWidth = (dTextX + dTextW - pLastCont->m_dX);
// return;
//}
double dRight = pLastCont->m_dX + pLastCont->m_dWidth;
if (pLastCont->m_oFont.IsEqual(&m_oManager.m_oFont.m_oFont) && pLastCont->m_oBrush.IsEqual(m_pBrush))
{
// . ,
if (fabs(dRight - dTextX) < 0.5)
{
//
pLastCont->m_strText += strText;
pLastCont->m_dWidth = (dTextX + dTextW - pLastCont->m_dX);
if (_T(" ") != strText)
{
if (0 == pLastCont->m_dWidthWithoutSpaces)
pLastCont->m_dLeftWithoutSpaces = dTextX;
pLastCont->m_dWidthWithoutSpaces = dTextX + dTextW - pLastCont->m_dLeftWithoutSpaces;
}
else if (0 == pLastCont->m_dWidthWithoutSpaces)
{
pLastCont->m_dLeftWithoutSpaces = dTextX + dTextW;
}
return;
}
else if ((dRight < dTextX) && ((dTextX - dRight) < m_oManager.m_dSpaceWidthMM))
{
//
pLastCont->m_strText += (_T(" ") + strText);
pLastCont->m_dWidth = (dTextX + dTextW - pLastCont->m_dX);
if (_T(" ") != strText)
{
if (0 == pLastCont->m_dWidthWithoutSpaces)
pLastCont->m_dLeftWithoutSpaces = dTextX;
pLastCont->m_dWidthWithoutSpaces = dTextX + dTextW - pLastCont->m_dLeftWithoutSpaces;
}
else if (0 == pLastCont->m_dWidthWithoutSpaces)
{
pLastCont->m_dLeftWithoutSpaces = dTextX + dTextW;
}
return;
}
}
// , , (, )
// ...
CContText* pCont = new CContText();
pCont->m_dX = dTextX;
pCont->m_dY = dBaseLinePos;
pCont->m_dWidth = dTextW;
pCont->m_dHeight = dTextH;
if (_T(" ") == strText)
{
pCont->m_dWidthWithoutSpaces = 0;
pCont->m_dLeftWithoutSpaces = dTextX + dTextW;
}
else
{
pCont->m_dWidthWithoutSpaces = dTextW;
pCont->m_dLeftWithoutSpaces = dTextX;
}
pCont->m_strText = strText;
pCont->m_oFont = m_oManager.m_oFont.m_oFont;
pCont->m_oBrush = *m_pBrush;
if (bIsPath)
{
pCont->m_strPickFontName = m_oManager.m_strCurrentPickFont;
pCont->m_lPickFontStyle = m_oManager.m_lCurrentPictFontStyle;
}
pCont->m_dSpaceWidthMM = m_oManager.m_dSpaceWidthMM;
m_pCurrentLine->AddCont(pCont, m_oManager.m_oFont.m_dBaselineOffset);
}
void Build()
{
if (m_bIsDeleteTextClipPage)
{
// ,
size_t nCount = m_arTextLine.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arTextLine[i];
double _top = pTextLine->m_dBaselinePos - pTextLine->m_dHeight;
double _bottom = pTextLine->m_dBaselinePos;
if (_top >= m_dHeight || _bottom <= 0)
{
m_arTextLine.RemoveAt(i);
--i;
--nCount;
}
}
}
switch (m_eTextAssociationType)
{
case TextAssociationTypeDefault:
case TextAssociationTypeLine:
{
size_t nCount = m_arTextLine.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arTextLine[i];
CParagraph* pParagraph = new CParagraph(m_eTextAssociationType);
pParagraph->m_pManagerLight = &m_oManagerLight;
pParagraph->m_bIsTextFrameProperties = true;
pParagraph->m_dLeft = pTextLine->m_dX;
pParagraph->m_dTop = pTextLine->m_dBaselinePos - pTextLine->m_dHeight + pTextLine->m_dBaselineOffset;
pParagraph->m_arLines.Add(pTextLine);
m_arParagraphs.Add(pParagraph);
}
//
m_arTextLine.RemoveAll();
break;
}
case TextAssociationTypeBlock:
{
size_t nCount = m_arTextLine.GetCount();
if (0 == nCount)
break;
CTextLine* pFirstLine = m_arTextLine[0];
CParagraph* pParagraph = new CParagraph(m_eTextAssociationType);
pParagraph->m_pManagerLight = &m_oManagerLight;
pParagraph->m_bIsTextFrameProperties = true;
pParagraph->m_dLeft = pFirstLine->m_dX;
pParagraph->m_dTop = pFirstLine->m_dBaselinePos - pFirstLine->m_dHeight + pFirstLine->m_dBaselineOffset;
pParagraph->m_arLines.Add(pFirstLine);
m_arParagraphs.Add(pParagraph);
for (size_t i = 1; i < nCount; ++i)
{
CTextLine* pTextLine = m_arTextLine[i];
CParagraph* pParagraph = new CParagraph(m_eTextAssociationType);
pParagraph->m_pManagerLight = &m_oManagerLight;
pParagraph->m_bIsTextFrameProperties = true;
if (((fabs(pTextLine->m_dBaselinePos - pTextLine->m_dHeight - pFirstLine->m_dBaselinePos) > STANDART_STRING_HEIGHT_MM) && (pTextLine->m_dX == pFirstLine->m_dX)) ||
((pTextLine->m_dX != pFirstLine->m_dX) && (pTextLine->m_dBaselinePos != pFirstLine->m_dBaselinePos)))
{
pParagraph->m_dLeft = pTextLine->m_dX;
pParagraph->m_dTop = pTextLine->m_dBaselinePos - pTextLine->m_dHeight + pTextLine->m_dBaselineOffset;
}
else
{
pParagraph->m_dLeft = pFirstLine->m_dX;
pParagraph->m_dTop = pFirstLine->m_dBaselinePos - pFirstLine->m_dHeight + pFirstLine->m_dBaselineOffset;
}
pFirstLine = pTextLine;
pParagraph->m_arLines.Add(pTextLine);
m_arParagraphs.Add(pParagraph);
}
//
m_arTextLine.RemoveAll();
break;
}
case TextAssociationTypeNoFrames:
{
SortElements(m_arTextLine);
Merge(STANDART_STRING_HEIGHT_MM / 3);
double previousStringOffset = 0;
size_t nCount = m_arTextLine.GetCount();
for (size_t i = 0; i < nCount; ++i)
{
CTextLine* pTextLine = m_arTextLine[i];
CParagraph* pParagraph = new CParagraph(m_eTextAssociationType);
pParagraph->m_pManagerLight = &m_oManagerLight;
pParagraph->m_bIsTextFrameProperties = false;
pParagraph->m_dLeft = pTextLine->m_dX;
double dBeforeSpacing = (pTextLine->m_dBaselinePos - previousStringOffset - pTextLine->m_dHeight + pTextLine->m_dBaselineOffset);
pParagraph->m_dSpaceBefore = max(dBeforeSpacing, 0);
double dHeight = 1;
if (pTextLine->m_dHeight != 0)
{
dHeight = pTextLine->m_dHeight;
if (dBeforeSpacing < 0)
dHeight += dBeforeSpacing;
}
pParagraph->m_dHeight = dHeight;
previousStringOffset = pTextLine->m_dBaselinePos + pTextLine->m_dBaselineOffset;
pParagraph->m_arLines.Add(pTextLine);
m_arParagraphs.Add(pParagraph);
}
m_arTextLine.RemoveAll();
break;
}
}
}
void Merge(double dAffinity)
{
size_t nCount = m_arTextLine.GetCount();
if (1 < nCount)
{
CTextLine* pPrev = m_arTextLine[0];
for (size_t i = 1; i < nCount; ++i)
{
CTextLine* pNext = m_arTextLine[i];
if (fabs(pNext->m_dBaselinePos - pPrev->m_dBaselinePos) < dAffinity)
{
pPrev->Merge(pNext);
pNext->m_arConts.RemoveAll();
RELEASEOBJECT(pNext);
m_arTextLine.RemoveAt(i);
--i;
--nCount;
continue;
}
pPrev = pNext;
}
}
}
void Write(NSDocxRenderer::CStringWriter& oWriter)
{
// drawings
size_t nCountDrawings = m_arGraphicItems.GetCount();
if (0 != nCountDrawings)
{
oWriter.WriteString(g_bstr_drawingParStart);
for (size_t i = 0; i < nCountDrawings; ++i)
{
m_arGraphicItems[i]->ToXml(oWriter);
}
oWriter.WriteString(g_bstr_ParEnd);
}
size_t nCountParagraphs = m_arParagraphs.GetCount();
for (size_t i = 0; i < nCountParagraphs; ++i)
{
m_arParagraphs[i]->ToXml(oWriter);
}
}
AVSINLINE void WriteSectionToFile(bool bLastPage, NSDocxRenderer::CStringWriter& oWriter)
{
// section
LONG lWidthDx = (LONG)(m_dWidth * c_dMMToDx);
LONG lHeightDx = (LONG)(m_dHeight * c_dMMToDx);
if (!bLastPage)
oWriter.WriteString(g_bstr_sectStart);
else
oWriter.WriteString(g_bstr_lastsection1);
if (lWidthDx >= lHeightDx)
{
CString strSize = _T("");
strSize.Format(g_string_sectSizeHor, lWidthDx, lHeightDx);
oWriter.WriteString(strSize);
}
else
{
CString strSize = _T("");
strSize.Format(g_string_sectSizeVer, lWidthDx, lHeightDx);
oWriter.WriteString(strSize);
}
if (!bLastPage)
oWriter.WriteString(g_bstr_sectEnd);
else
oWriter.WriteString(g_bstr_lastsection2);
}
};
}
\ No newline at end of file
#pragma once
#include "File.h"
const double c_ag_Inch_to_MM = 25.4;
const double c_ag_1pxWidth = 25.4 / 96;
namespace NSDocxRenderer
{
enum ImageType
{
itJPG = 0,
itPNG = 1
};
class CImageInfo
{
public:
ImageType m_eType;
LONG m_lID;
CImageInfo()
{
m_eType = itJPG;
m_lID = -1;
}
CImageInfo(const CImageInfo& oSrc)
{
*this = oSrc;
}
CImageInfo& operator=(const CImageInfo& oSrc)
{
m_eType = oSrc.m_eType;
m_lID = oSrc.m_lID;
return *this;
}
};
inline static double FABS(double dVal)
{
return (dVal >= 0) ? dVal : -dVal;
}
inline static int round(double dVal)
{
return (int)(dVal + 0.5);
}
class CStringWriter
{
private:
wchar_t* m_pData;
size_t m_lSize;
wchar_t* m_pDataCur;
size_t m_lSizeCur;
public:
CStringWriter()
{
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = m_lSize;
}
~CStringWriter()
{
RELEASEMEM(m_pData);
}
__forceinline void AddSize(size_t nSize, const size_t nSizeMin = 1000)
{
if (NULL == m_pData)
{
m_lSize = max(nSize, nSizeMin);
m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
m_lSizeCur = 0;
m_pDataCur = m_pData;
return;
}
if ((m_lSizeCur + nSize) > m_lSize)
{
while ((m_lSizeCur + nSize) > m_lSize)
{
m_lSize *= 2;
}
wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t));
if (NULL != pRealloc)
{
//
m_pData = pRealloc;
m_pDataCur = m_pData + m_lSizeCur;
}
else
{
wchar_t* pMalloc = (wchar_t*)malloc(m_lSize * sizeof(wchar_t));
memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(wchar_t));
free(m_pData);
m_pData = pMalloc;
m_pDataCur = m_pData + m_lSizeCur;
}
}
}
public:
inline void WriteString(wchar_t* pString, size_t& nLen)
{
AddSize(nLen);
//memcpy(m_pDataCur, pString, nLen * sizeof(wchar_t));
memcpy(m_pDataCur, pString, nLen << 1);
m_pDataCur += nLen;
m_lSizeCur += nLen;
}
inline void WriteString(_bstr_t& bsString)
{
size_t nLen = bsString.length();
WriteString(bsString.GetBSTR(), nLen);
}
inline void WriteString(CString& sString)
{
size_t nLen = (size_t)sString.GetLength();
#ifdef _UNICODE
WriteString(sString.GetBuffer(), nLen);
#else
CStringW str = (CStringW)sString;
WriteString(str.GetBuffer(), nLen);
#endif
}
inline size_t GetCurSize()
{
return m_lSizeCur;
}
inline void Write(CStringWriter& oWriter)
{
WriteString(oWriter.m_pData, oWriter.m_lSizeCur);
}
inline void Clear()
{
RELEASEMEM(m_pData);
m_pData = NULL;
m_lSize = 0;
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
inline void ClearNoAttack()
{
m_pDataCur = m_pData;
m_lSizeCur = 0;
}
CString GetData()
{
CString str(m_pData, (int)m_lSizeCur);
return str;
}
};
}
\ No newline at end of file
#pragma once
#include "..\stdafx.h"
#include "StringWriter.h"
#include "..\Graphics\Structures.h"
#include "..\Graphics\Matrix.h"
namespace NSFontManager
{
const double c_dInchToMM = 25.4;
const double c_dPixToMM = 25.4 / 72.0;
const double c_dPtToMM = 25.4 / 72.0;
const double c_dMMToPt = 72.0 / 25.4;
class CFontAdvanced
{
public:
NSStructures::CFont m_oFont;
// font metrics
double m_dAscent;
double m_dDescent;
double m_dLineSpacing;
double m_dEmHeight;
double m_dBaselineOffset;
double m_dSpaceWidthMM;
// font params
CString m_strFamilyName;
CString m_strPANOSE;
LONG m_lStyle;
CAtlArray<DWORD> m_arSignature;
bool m_bIsFixedWidth;
LONG m_lAvgWidth;
public:
CFontAdvanced()
{
m_oFont.SetDefaultParams();
m_dAscent = 0;
m_dDescent = 0;
m_dLineSpacing = 0;
m_dEmHeight = 0;
m_dBaselineOffset = 0;
m_dSpaceWidthMM = 0;
m_strFamilyName = _T("");
m_strPANOSE = _T("");
m_lStyle = 0;
m_arSignature.RemoveAll();
m_bIsFixedWidth = false;
m_lAvgWidth = -1;
}
CFontAdvanced(const CFontAdvanced& oSrc)
{
*this = oSrc;
}
CFontAdvanced& operator=(const CFontAdvanced& oSrc)
{
m_oFont = oSrc.m_oFont;
m_dAscent = oSrc.m_dAscent;
m_dDescent = oSrc.m_dDescent;
m_dLineSpacing = oSrc.m_dLineSpacing;
m_dEmHeight = oSrc.m_dEmHeight;
m_dBaselineOffset = oSrc.m_dBaselineOffset;
m_dSpaceWidthMM = oSrc.m_dSpaceWidthMM;
m_strFamilyName = oSrc.m_strFamilyName;
m_strPANOSE = oSrc.m_strPANOSE;
m_lStyle = oSrc.m_lStyle;
m_arSignature.Copy(oSrc.m_arSignature);
m_bIsFixedWidth = oSrc.m_bIsFixedWidth;
m_lAvgWidth = oSrc.m_lAvgWidth;
return *this;
}
};
class CFontPickUp
{
public:
CFontAdvanced m_oFont;
BYTE m_lRangeNum;
BYTE m_lRange;
CString m_strPickFont;
LONG m_lPickStyle;
public:
CFontPickUp() : m_oFont()
{
m_lRangeNum = 0xFF;
m_lRange = 0xFF;
m_strPickFont = _T("");
m_lPickStyle = 0;
}
CFontPickUp(const CFontPickUp& oSrc)
{
*this = oSrc;
}
CFontPickUp& operator=(const CFontPickUp& oSrc)
{
m_oFont = oSrc.m_oFont;
m_lRange = oSrc.m_lRange;
m_lRangeNum = oSrc.m_lRangeNum;
m_strPickFont = oSrc.m_strPickFont;
m_lPickStyle = oSrc.m_lPickStyle;
return *this;
}
};
class CFontManagerBase
{
public:
enum MeasureType
{
MeasureTypeGlyph = 0,
MeasureTypePosition = 1
};
protected:
AVSGraphics::IASCWinFonts* m_pWinFonts;
AVSGraphics::IASCFontManager* m_pManager;
CString m_strDefaultFont;
public:
CFontAdvanced m_oFont;
//
BYTE m_pRanges[0xFFFF];
BYTE m_pRangesNums[0xFFFF];
CAtlList<CFontPickUp> m_arListPicUps;
CString m_strCurrentPickFont;
LONG m_lCurrentPictFontStyle;
public:
CFontManagerBase() : m_oFont()
{
m_pManager = NULL;
CoCreateInstance(AVSGraphics::CLSID_CASCFontManager, NULL, CLSCTX_ALL, AVSGraphics::IID_IASCFontManager, (void**)&m_pManager);
m_pManager->Initialize(L"");
SetDefaultFont(_T("Arial"));
ClearPickUps();
InitializeRanges();
ClearPickUps();
}
virtual ~CFontManagerBase()
{
RELEASEINTERFACE(m_pManager);
}
__forceinline void ClearPickUps()
{
m_arListPicUps.RemoveAll();
m_strCurrentPickFont = _T("");
m_lCurrentPictFontStyle = 0;
}
public:
__forceinline void SetDefaultFont(const CString& strName)
{
m_strDefaultFont = strName;
BSTR bsDefault = m_strDefaultFont.AllocSysString();
m_pManager->SetDefaultFont(bsDefault);
SysFreeString(bsDefault);
}
__forceinline CString GetDefaultFont()
{
return m_strDefaultFont;
}
virtual void LoadFont(long lFaceIndex = 0, bool bIsNeedAddToMap = true)
{
}
void LoadFontByName(CString& strName, const double& dSize, const LONG& lStyle, const double& dDpiX, const double& dDpiY)
{
BSTR bsName = strName.AllocSysString();
m_pManager->LoadFontByName(bsName, (float)dSize, lStyle, dDpiX, dDpiY);
SysFreeString(bsName);
LoadFontMetrics();
LoadFontParams();
m_oFont.m_lAvgWidth = -1;
}
void LoadFontByFile(CString& strPath, const double& dSize, const double& dDpiX, const double& dDpiY, const LONG& lFaceIndex)
{
BSTR bsPath = strPath.AllocSysString();
m_pManager->LoadFontFromFile(bsPath, (float)dSize, dDpiX, dDpiY, lFaceIndex);
SysFreeString(bsPath);
LoadFontMetrics();
LoadFontParams();
m_oFont.m_lAvgWidth = -1;
wchar_t wsDrive[MAX_PATH], wsDir[MAX_PATH], wsFilename[MAX_PATH], wsExt[MAX_PATH];
_wsplitpath( strPath.GetBuffer(), wsDrive, wsDir, wsFilename, wsExt );
CString wsEncodingPath = CString(wsDrive) + CString(wsDir) + CString(wsFilename) + CString(_T(".enc"));
bool bIsCID = false;
CString strExt(wsExt);
if (-1 != strExt.Find(_T("cid")))
bIsCID = true;
XmlUtils::CXmlNode oMainNode;
oMainNode.FromXmlFile(wsEncodingPath);
if (_T("PDF-resources") == oMainNode.GetName())
{
if (bIsCID)
{
XmlUtils::CXmlNode oType0Node;
if ( oMainNode.GetNode( _T("Type0"), oType0Node ) )
{
XmlUtils::CXmlNode oNode;
if ( oType0Node.GetNode( _T("DescendantFonts"), oNode ) )
{
XmlUtils::CXmlNode oDescNode;
if ( oNode.GetNode( _T("FontDescriptor"), oDescNode ) )
{
XmlUtils::CXmlNode oCurNode;
if ( oNode.GetNode( _T("AvgWidth"), oCurNode ) )
{
CString sValue = oCurNode.GetAttribute( _T("value") );
m_oFont.m_lAvgWidth = XmlUtils::GetInteger( sValue );
}
}
}
}
}
else
{
XmlUtils::CXmlNode oNode;
if ( oMainNode.GetNode( _T("FontDescriptor"), oNode ) )
{
XmlUtils::CXmlNode oCurNode;
if ( oNode.GetNode( _T("AvgWidth"), oCurNode ) )
{
CString sValue = oCurNode.GetAttribute( _T("value") );
m_oFont.m_lAvgWidth = XmlUtils::GetInteger( sValue );
}
}
}
}
}
public:
__forceinline void MeasureString(const CString& strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
BSTR bsText = strText.AllocSysString();
MeasureString(bsText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
SysFreeString(bsText);
}
__forceinline void MeasureStringUNICODE(const CString& strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
m_pManager->SetStringGID(FALSE);
MeasureString(strText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
m_pManager->SetStringGID(TRUE);
}
__forceinline void MeasureStringUNICODE(BSTR strText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
m_pManager->SetStringGID(FALSE);
MeasureString(strText, x, y, dBoxX, dBoxY, dBoxWidth, dBoxHeight, measureType);
m_pManager->SetStringGID(TRUE);
}
virtual void MeasureString(BSTR bsText, double x, double y, double& dBoxX, double& dBoxY, double& dBoxWidth, double& dBoxHeight, MeasureType measureType)
{
}
virtual void CalculateBaselineOffset()
{
LoadFont();
double d1 = 3 * (m_oFont.m_dLineSpacing - m_oFont.m_dDescent) - m_oFont.m_dAscent;
d1 /= 2.0;
d1 *= (m_oFont.m_oFont.Size / m_oFont.m_dEmHeight);
m_oFont.m_dBaselineOffset = d1;
}
public:
void LoadFontMetrics()
{
unsigned short iTemp = 0;
m_pManager->GetCellAscent(&iTemp);
m_oFont.m_dAscent = iTemp;
m_pManager->GetCellDescent(&iTemp);
m_oFont.m_dDescent = iTemp;
m_pManager->GetLineSpacing(&iTemp);
m_oFont.m_dLineSpacing = iTemp;
m_pManager->GetEmHeight(&iTemp);
m_oFont.m_dEmHeight = iTemp;
m_oFont.m_dBaselineOffset = (c_dPtToMM * m_oFont.m_dDescent * m_oFont.m_oFont.Size / m_oFont.m_dEmHeight);
}
__forceinline CString ToHexString( BYTE uc )
{
CString strRes = _T("");
strRes.Format(_T("%02X"), uc);
return strRes;
}
void LoadFontParams(BOOL bIsPath = TRUE)
{
//
if (NULL == m_pManager)
return;
if (_T("") == m_oFont.m_oFont.Name)
{
// FamilyName
BSTR bsFamilyName = NULL;
m_pManager->GetFamilyNameEx(_bstr_t("<DeletePDFPrefix/>"), &bsFamilyName);
m_oFont.m_strFamilyName = (CString)bsFamilyName;
SysFreeString(bsFamilyName);
}
else
{
m_oFont.m_strFamilyName = m_oFont.m_oFont.Name;
}
// StyleName
BSTR bsStyleName = NULL;
m_pManager->GetStyleName(&bsStyleName);
CString strStyle = (CString)bsStyleName;
SysFreeString(bsStyleName);
if (_T("Bold") == strStyle)
{
m_oFont.m_lStyle = 0x01;
}
else if (_T("Italic") == strStyle)
{
m_oFont.m_lStyle = 0x02;
}
else if (_T("Bold Italic") == strStyle)
{
m_oFont.m_lStyle = 0x03;
}
else
{
m_oFont.m_lStyle = 0x00;
}
// PANOSE
SAFEARRAY* panoseSafeArray = NULL;
m_oFont.m_strPANOSE = _T("");
m_pManager->GetPanose(&panoseSafeArray);
if (NULL != panoseSafeArray)
{
LONG lCount = panoseSafeArray->rgsabound[0].cElements;
BYTE* pData = (BYTE*)(panoseSafeArray->pvData);
for ( LONG i = 0; i < (LONG)( lCount ); i++ )
{
m_oFont.m_strPANOSE += ToHexString(pData[i]);
}
SafeArrayDestroy(panoseSafeArray);
}
// IsFixed
LONG lIsFixedWidthLong = 0;
m_pManager->IsFixedWidth(&lIsFixedWidthLong);
m_oFont.m_bIsFixedWidth = (lIsFixedWidthLong != 0) ? true : false;
// Signature
VARIANT_BOOL vbSuccess = VARIANT_FALSE;
m_oFont.m_arSignature.RemoveAll();
for ( unsigned int i = 0; i < 6; i++ )
{
DWORD value = 0;
for ( unsigned long bit = 0; bit < 32; bit++ )
{
m_pManager->IsUnicodeRangeAvailable( bit, i, &vbSuccess );
if( VARIANT_TRUE == vbSuccess )
{
value |= ( 1 << bit );
}
}
m_oFont.m_arSignature.Add(value);
}
}
private:
void InitializeRanges()
{
memset(m_pRanges, 0xFF, 0xFFFF);
memset(m_pRangesNums, 0xFF, 0xFFFF);
//
int nStart = 0;
int nCount = 0;
// rangeNum 0
// case 00: sUCRName = "Basic Latin"; break; /* U+0020-U+007E */
nStart = 0x0020;
nCount = 0x007E - nStart + 1;
memset(m_pRanges + nStart, 0, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 01: sUCRName = "Latin-1 Supplement"; break; /* U+0080-U+00FF */
nStart = 0x0080;
nCount = 0x00FF - nStart + 1;
memset(m_pRanges + nStart, 1, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 02: sUCRName = "Latin Extended-A"; break; /* U+0100-U+017F */
nStart = 0x0100;
nCount = 0x017F - nStart + 1;
memset(m_pRanges + nStart, 2, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 03: sUCRName = "Latin Extended-B"; break; /* U+0180-U+024F */
nStart = 0x0180;
nCount = 0x024F - nStart + 1;
memset(m_pRanges + nStart, 3, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 04: sUCRName = "IPA Extensions"; break; /* U+0250-U+02AF */ /* U+1D00-U+1D7F */ /* U+1D80-U+1DBF */
nStart = 0x0250;
nCount = 0x02AF - nStart + 1;
memset(m_pRanges + nStart, 4, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x1D00;
nCount = 0x1D7F - nStart + 1;
memset(m_pRanges + nStart, 4, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x1D80;
nCount = 0x1DBF - nStart + 1;
memset(m_pRanges + nStart, 4, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 05: sUCRName = "Spacing Modifier Letters"; break; /* U+02B0-U+02FF */ /* U+A700-U+A71F */
nStart = 0x02B0;
nCount = 0x02FF - nStart + 1;
memset(m_pRanges + nStart, 5, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0xA700;
nCount = 0xA71F - nStart + 1;
memset(m_pRanges + nStart, 5, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 06: sUCRName = "Combining Diacritical Marks"; break; /* U+0300-U+036F */ /* U+1DC0-U+1DFF */
nStart = 0x0300;
nCount = 0x036F - nStart + 1;
memset(m_pRanges + nStart, 6, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x1DC0;
nCount = 0x1DFF - nStart + 1;
memset(m_pRanges + nStart, 6, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 07: sUCRName = "Greek and Coptic"; break; /* U+0370-U+03FF */
nStart = 0x0370;
nCount = 0x03FF - nStart + 1;
memset(m_pRanges + nStart, 7, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 08: sUCRName = "Coptic"; break; /* U+2C80-U+2CFF */
nStart = 0x2C80;
nCount = 0x2CFF - nStart + 1;
memset(m_pRanges + nStart, 8, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 09: sUCRName = "Cyrillic"; break; /* U+0400-U+04FF */ /* U+0500-U+052F */ /* U+2DE0-U+2DFF */ /* U+A640-U+A69F */
nStart = 0x0400;
nCount = 0x04FF - nStart + 1;
memset(m_pRanges + nStart, 9, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x0500;
nCount = 0x052F - nStart + 1;
memset(m_pRanges + nStart, 9, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x2DE0;
nCount = 0x2DFF - nStart + 1;
memset(m_pRanges + nStart, 9, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0xA640;
nCount = 0xA69F - nStart + 1;
memset(m_pRanges + nStart, 9, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 10: sUCRName = "Armenian"; break; /* U+0530-U+058F */
nStart = 0x0530;
nCount = 0x058F - nStart + 1;
memset(m_pRanges + nStart, 10, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 11: sUCRName = "Hebrew"; break; /* U+0590-U+05FF */
nStart = 0x0590;
nCount = 0x05FF - nStart + 1;
memset(m_pRanges + nStart, 11, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 12: sUCRName = "Vai"; break; /* U+A500-U+A63F */
nStart = 0xA500;
nCount = 0xA63F - nStart + 1;
memset(m_pRanges + nStart, 12, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 13: sUCRName = "Arabic"; break; /* U+0600-U+06FF */ /* U+0750-U+077F */
nStart = 0x0600;
nCount = 0x06FF - nStart + 1;
memset(m_pRanges + nStart, 13, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x0750;
nCount = 0x077F - nStart + 1;
memset(m_pRanges + nStart, 13, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 14: sUCRName = "NKo"; break; /* U+07C0-U+07FF */
nStart = 0x07C0;
nCount = 0x07FF - nStart + 1;
memset(m_pRanges + nStart, 14, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 15: sUCRName = "Devanagari"; break; /* U+0900-U+097F */
nStart = 0x0900;
nCount = 0x097F - nStart + 1;
memset(m_pRanges + nStart, 15, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 16: sUCRName = "Bengali"; break; /* U+0980-U+09FF */
nStart = 0x0980;
nCount = 0x09FF - nStart + 1;
memset(m_pRanges + nStart, 16, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 17: sUCRName = "Gurmukhi"; break; /* U+0A00-U+0A7F */
nStart = 0x0A00;
nCount = 0x0A7F - nStart + 1;
memset(m_pRanges + nStart, 17, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 18: sUCRName = "Gujarati"; break; /* U+0A80-U+0AFF */
nStart = 0x0A80;
nCount = 0x0AFF - nStart + 1;
memset(m_pRanges + nStart, 18, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 19: sUCRName = "Oriya"; break; /* U+0B00-U+0B7F */
nStart = 0x0B00;
nCount = 0x0B7F - nStart + 1;
memset(m_pRanges + nStart, 19, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 20: sUCRName = "Tamil"; break; /* U+0B80-U+0BFF */
nStart = 0x0B80;
nCount = 0x0BFF - nStart + 1;
memset(m_pRanges + nStart, 20, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 21: sUCRName = "Telugu"; break; /* U+0C00-U+0C7F */
nStart = 0x0C00;
nCount = 0x0C7F - nStart + 1;
memset(m_pRanges + nStart, 21, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 22: sUCRName = "Kannada"; break; /* U+0C80-U+0CFF */
nStart = 0x0C80;
nCount = 0x0CFF - nStart + 1;
memset(m_pRanges + nStart, 22, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 23: sUCRName = "Malayalam"; break; /* U+0D00-U+0D7F */
nStart = 0x0D00;
nCount = 0x0D7F - nStart + 1;
memset(m_pRanges + nStart, 23, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 24: sUCRName = "Thai"; break; /* U+0E00-U+0E7F */
nStart = 0x0E00;
nCount = 0x0E7F - nStart + 1;
memset(m_pRanges + nStart, 24, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 25: sUCRName = "Lao"; break; /* U+0E80-U+0EFF */
nStart = 0x0E80;
nCount = 0x0EFF - nStart + 1;
memset(m_pRanges + nStart, 25, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 26: sUCRName = "Georgian"; break; /* U+10A0-U+10FF */ /* U+2D00-U+2D2F */
nStart = 0x10A0;
nCount = 0x10FF - nStart + 1;
memset(m_pRanges + nStart, 26, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x2D00;
nCount = 0x2D2F - nStart + 1;
memset(m_pRanges + nStart, 26, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 27: sUCRName = "Balinese"; break; /* U+1B00-U+1B7F */
nStart = 0x1B00;
nCount = 0x1B7F - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 28: sUCRName = "Hangul Jamo"; break; /* U+1100-U+11FF */
nStart = 0x1100;
nCount = 0x11FF - nStart + 1;
memset(m_pRanges + nStart, 28, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 29: sUCRName = "Latin Extended Additional"; break; /* U+1E00-U+1EFF */ /* U+2C60-U+2C7F */ /* U+A720-U+A7FF */
nStart = 0x1E00;
nCount = 0x1EFF - nStart + 1;
memset(m_pRanges + nStart, 29, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x2C60;
nCount = 0x2C7F - nStart + 1;
memset(m_pRanges + nStart, 29, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0xA720;
nCount = 0xA7FF - nStart + 1;
memset(m_pRanges + nStart, 29, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 30: sUCRName = "Greek Extended"; break; /* U+1F00-U+1FFF */
nStart = 0x1F00;
nCount = 0x1FFF - nStart + 1;
memset(m_pRanges + nStart, 30, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
//case 31: sUCRName = "General Punctuation"; break; /* U+2000-U+206F */ /* U+2E00-U+2E7F */
nStart = 0x2000;
nCount = 0x206F - nStart + 1;
memset(m_pRanges + nStart, 31, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
nStart = 0x2E00;
nCount = 0x2E7F - nStart + 1;
memset(m_pRanges + nStart, 31, nCount);
memset(m_pRangesNums + nStart, 0, nCount);
// rangeNum 1
//case 00: sUCRName = "Superscripts And Subscripts"; break; /* U+2070-U+209F */
nStart = 0x2070;
nCount = 0x209F - nStart + 1;
memset(m_pRanges + nStart, 0, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 01: sUCRName = "Currency Symbols"; break; /* U+20A0-U+20CF */
nStart = 0x20A0;
nCount = 0x20CF - nStart + 1;
memset(m_pRanges + nStart, 1, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 02: sUCRName = "Combining Diacritical Marks For Symbols"; break; /* U+20D0-U+20FF */
nStart = 0x20D0;
nCount = 0x20FF - nStart + 1;
memset(m_pRanges + nStart, 2, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 03: sUCRName = "Letterlike Symbols"; break; /* U+2100-U+214F */
nStart = 0x2100;
nCount = 0x214F - nStart + 1;
memset(m_pRanges + nStart, 3, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 04: sUCRName = "Number Forms"; break; /* U+2150-U+218F */
nStart = 0x2150;
nCount = 0x218F - nStart + 1;
memset(m_pRanges + nStart, 4, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 05: sUCRName = "Arrows"; break; /* U+2190-U+21FF */ /* U+27F0-U+27FF */ /* U+2900-U+297F */ /* U+2B00-U+2BFF */
nStart = 0x2190;
nCount = 0x21FF - nStart + 1;
memset(m_pRanges + nStart, 5, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x27F0;
nCount = 0x27FF - nStart + 1;
memset(m_pRanges + nStart, 5, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x2900;
nCount = 0x297F - nStart + 1;
memset(m_pRanges + nStart, 5, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x2B00;
nCount = 0x2BFF - nStart + 1;
memset(m_pRanges + nStart, 5, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 06: sUCRName = "Mathematical Operators"; break; /* U+2200-U+22FF */ /* U+2A00-U+2AFF */ /* U+27C0-U+27EF */ /* U+2980-U+29FF */
nStart = 0x2200;
nCount = 0x22FF - nStart + 1;
memset(m_pRanges + nStart, 6, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x2A00;
nCount = 0x2AFF - nStart + 1;
memset(m_pRanges + nStart, 6, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x27C0;
nCount = 0x27EF - nStart + 1;
memset(m_pRanges + nStart, 6, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x2980;
nCount = 0x29FF - nStart + 1;
memset(m_pRanges + nStart, 6, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 07: sUCRName = "Miscellaneous Technical"; break; /* U+2300-U+23FF */
nStart = 0x2300;
nCount = 0x23FF - nStart + 1;
memset(m_pRanges + nStart, 7, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 08: sUCRName = "Control Pictures"; break; /* U+2400-U+243F */
nStart = 0x2400;
nCount = 0x243F - nStart + 1;
memset(m_pRanges + nStart, 8, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 09: sUCRName = "Optical Character Recognition"; break; /* U+2440-U+245F */
nStart = 0x2440;
nCount = 0x245F - nStart + 1;
memset(m_pRanges + nStart, 9, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 10: sUCRName = "Enclosed Alphanumerics"; break; /* U+2460-U+24FF */
nStart = 0x2460;
nCount = 0x24FF - nStart + 1;
memset(m_pRanges + nStart, 10, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 11: sUCRName = "Box Drawing"; break; /* U+2500-U+257F */
nStart = 0x2500;
nCount = 0x257F - nStart + 1;
memset(m_pRanges + nStart, 11, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 12: sUCRName = "Block Elements"; break; /* U+2580-U+259F */
nStart = 0x2580;
nCount = 0x259F - nStart + 1;
memset(m_pRanges + nStart, 12, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 13: sUCRName = "Geometric Shapes"; break; /* U+25A0-U+25FF */
nStart = 0x25A0;
nCount = 0x25FF - nStart + 1;
memset(m_pRanges + nStart, 13, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 14: sUCRName = "Miscellaneous Symbols"; break; /* U+2600-U+26FF */
nStart = 0x2600;
nCount = 0x26FF - nStart + 1;
memset(m_pRanges + nStart, 14, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 15: sUCRName = "Dingbats"; break; /* U+2700-U+27BF */
nStart = 0x2700;
nCount = 0x27BF - nStart + 1;
memset(m_pRanges + nStart, 15, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 16: sUCRName = "CJK Symbols and Punctuation"; break; /* U+3000-U+303F */
nStart = 0x3000;
nCount = 0x303F - nStart + 1;
memset(m_pRanges + nStart, 16, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 17: sUCRName = "Hiragana"; break; /* U+3040-U+309F */
nStart = 0x3040;
nCount = 0x309F - nStart + 1;
memset(m_pRanges + nStart, 17, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 18: sUCRName = "Katakana"; break; /* U+30A0-U+30FF */ /* U+31F0-U+31FF */
nStart = 0x30A0;
nCount = 0x30FF - nStart + 1;
memset(m_pRanges + nStart, 18, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x31F0;
nCount = 0x31FF - nStart + 1;
memset(m_pRanges + nStart, 18, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 19: sUCRName = "Bopomofo"; break; /* U+3100-U+312F */ /* U+31A0-U+31BF */
nStart = 0x3100;
nCount = 0x312F - nStart + 1;
memset(m_pRanges + nStart, 19, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x31A0;
nCount = 0x31BF - nStart + 1;
memset(m_pRanges + nStart, 19, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 20: sUCRName = "Hangul Compatibility Jamo"; break; /* U+3130-U+318F */
nStart = 0x3130;
nCount = 0x318F - nStart + 1;
memset(m_pRanges + nStart, 20, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 21: sUCRName = "Phags-pa"; break; /* U+A840-U+A87F */
nStart = 0xA840;
nCount = 0xA87F - nStart + 1;
memset(m_pRanges + nStart, 21, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 22: sUCRName = "Enclosed CJK Letters and Months"; break; /* U+3200-U+32FF */
nStart = 0x3200;
nCount = 0x32FF - nStart + 1;
memset(m_pRanges + nStart, 22, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 23: sUCRName = "CJK Compatibility"; break; /* U+3300-U+33FF */
nStart = 0x3300;
nCount = 0x33FF - nStart + 1;
memset(m_pRanges + nStart, 23, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 24: sUCRName = "Hangul Syllables"; break; /* U+AC00-U+D7AF */
nStart = 0xAC00;
nCount = 0xD7AF - nStart + 1;
memset(m_pRanges + nStart, 24, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 25: sUCRName = "Non-Plane 0"; break; /* U+D800-U+DB7F */ /* U+DB80-U+DBFF */ /* U+DC00-U+DFFF */ //
nStart = 0xD800;
nCount = 0xDB7F - nStart + 1;
memset(m_pRanges + nStart, 25, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0xDB80;
nCount = 0xDBFF - nStart + 1;
memset(m_pRanges + nStart, 25, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0xDC00;
nCount = 0xDFFF - nStart + 1;
memset(m_pRanges + nStart, 25, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 26: sUCRName = "Phoenician"; break; /*U+10900-U+1091F*/
//case 27: sUCRName = "CJK Unified Ideographs"; break; /* U+4E00-U+9FFF */ /* U+2E80-U+2EFF */ /* U+2F00-U+2FDF */ /* U+2FF0-U+2FFF */ /* U+3400-U+4DB5 */ /*U+20000-U+2A6D6*/ /* U+3190-U+319F */
nStart = 0x4E00;
nCount = 0x9FFF - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x2E80;
nCount = 0x2EFF - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x2F00;
nCount = 0x2FDF - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x2FF0;
nCount = 0x2FFF - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x3400;
nCount = 0x4DB5 - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0x3190;
nCount = 0x319F - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 28: sUCRName = "Private Use Area (plane 0)"; break; /* U+E000-U+F8FF */ //
nStart = 0xE000;
nCount = 0xF8FF - nStart + 1;
memset(m_pRanges + nStart, 28, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 29: sUCRName = "CJK Strokes"; break; /* U+31C0-U+31EF */ /* U+F900-U+FAFF */ /*U+2F800-U+2FA1F*/
nStart = 0x31C0;
nCount = 0x31EF - nStart + 1;
memset(m_pRanges + nStart, 29, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
nStart = 0xF900;
nCount = 0xFAFF - nStart + 1;
memset(m_pRanges + nStart, 29, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 30: sUCRName = "Alphabetic Presentation Forms"; break; /* U+FB00-U+FB4F */
nStart = 0xFB00;
nCount = 0xFB4F - nStart + 1;
memset(m_pRanges + nStart, 30, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
//case 31: sUCRName = "Arabic Presentation Forms-A"; break; /* U+FB50-U+FDFF */
nStart = 0xFB50;
nCount = 0xFDFF - nStart + 1;
memset(m_pRanges + nStart, 31, nCount);
memset(m_pRangesNums + nStart, 1, nCount);
// rangeNum 2
//case 00: sUCRName = "Combining Half Marks"; break; /* U+FE20-U+FE2F */
nStart = 0xFE20;
nCount = 0xFE2F - nStart + 1;
memset(m_pRanges + nStart, 0, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 01: sUCRName = "Vertical forms"; break; /* U+FE10-U+FE1F */ /* U+FE30-U+FE4F */
nStart = 0xFE10;
nCount = 0xFE1F - nStart + 1;
memset(m_pRanges + nStart, 1, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0xFE30;
nCount = 0xFE4F - nStart + 1;
memset(m_pRanges + nStart, 1, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 02: sUCRName = "Small Form Variants"; break; /* U+FE50-U+FE6F */
nStart = 0xFE50;
nCount = 0xFE6F - nStart + 1;
memset(m_pRanges + nStart, 2, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 03: sUCRName = "Arabic Presentation Forms-B"; break; /* U+FE70-U+FEFE */
nStart = 0xFE70;
nCount = 0xFEFE - nStart + 1;
memset(m_pRanges + nStart, 3, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 04: sUCRName = "Halfwidth and Fullwidth Forms"; break; /* U+FF00-U+FFEF */
nStart = 0xFF00;
nCount = 0xFFEF - nStart + 1;
memset(m_pRanges + nStart, 4, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 05: sUCRName = "Specials"; break; /* U+FFF0-U+FFFF */
nStart = 0xFFF0;
nCount = 0xFFFF - nStart + 1;
memset(m_pRanges + nStart, 5, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 06: sUCRName = "Tibetan"; break; /* U+0F00-U+0FFF */
nStart = 0x0F00;
nCount = 0x0FFF - nStart + 1;
memset(m_pRanges + nStart, 6, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 07: sUCRName = "Syriac"; break; /* U+0700-U+074F */
nStart = 0x0700;
nCount = 0x074F - nStart + 1;
memset(m_pRanges + nStart, 7, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 08: sUCRName = "Thaana"; break; /* U+0780-U+07BF */
nStart = 0x0780;
nCount = 0x07BF - nStart + 1;
memset(m_pRanges + nStart, 8, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 09: sUCRName = "Sinhala"; break; /* U+0D80-U+0DFF */
nStart = 0x0D80;
nCount = 0x0DFF - nStart + 1;
memset(m_pRanges + nStart, 9, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 10: sUCRName = "Myanmar"; break; /* U+1000-U+109F */
nStart = 0x1000;
nCount = 0x109F - nStart + 1;
memset(m_pRanges + nStart, 10, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 11: sUCRName = "Ethiopic"; break; /* U+1200-U+137F */ /* U+1380-U+139F */ /* U+2D80-U+2DDF */
nStart = 0x1200;
nCount = 0x137F - nStart + 1;
memset(m_pRanges + nStart, 11, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0x1380;
nCount = 0x139F - nStart + 1;
memset(m_pRanges + nStart, 11, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0x2D80;
nCount = 0x2DDF - nStart + 1;
memset(m_pRanges + nStart, 11, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 12: sUCRName = "Cherokee"; break; /* U+13A0-U+13FF */
nStart = 0x13A0;
nCount = 0x13FF - nStart + 1;
memset(m_pRanges + nStart, 12, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 13: sUCRName = "Unified Canadian Aboriginal Syllabics"; break; /* U+1400-U+167F */
nStart = 0x1400;
nCount = 0x167F - nStart + 1;
memset(m_pRanges + nStart, 13, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 14: sUCRName = "Ogham"; break; /* U+1680-U+169F */
nStart = 0x1680;
nCount = 0x169F - nStart + 1;
memset(m_pRanges + nStart, 14, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 15: sUCRName = "Runic"; break; /* U+16A0-U+16FF */
nStart = 0x16A0;
nCount = 0x16FF - nStart + 1;
memset(m_pRanges + nStart, 15, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 16: sUCRName = "Khmer"; break; /* U+1780-U+17FF */ /* U+19E0-U+19FF */
nStart = 0x1780;
nCount = 0x17FF - nStart + 1;
memset(m_pRanges + nStart, 16, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0x19E0;
nCount = 0x19FF - nStart + 1;
memset(m_pRanges + nStart, 16, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 17: sUCRName = "Mongolian"; break; /* U+1800-U+18AF */
nStart = 0x1800;
nCount = 0x18AF - nStart + 1;
memset(m_pRanges + nStart, 17, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 18: sUCRName = "Braille Patterns"; break; /* U+2800-U+28FF */
nStart = 0x2800;
nCount = 0x28FF - nStart + 1;
memset(m_pRanges + nStart, 18, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 19: sUCRName = "Yi Syllables"; break; /* U+A000-U+A48F */ /* U+A490-U+A4CF */
nStart = 0xA000;
nCount = 0xA48F - nStart + 1;
memset(m_pRanges + nStart, 19, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0xA490;
nCount = 0xA4CF - nStart + 1;
memset(m_pRanges + nStart, 19, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 20: sUCRName = "Tagalog"; break; /* U+1700-U+171F */ /* U+1720-U+173F */ /* U+1740-U+175F */ /* U+1760-U+177F */
nStart = 0x1700;
nCount = 0x171F - nStart + 1;
memset(m_pRanges + nStart, 20, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0x1720;
nCount = 0x173F - nStart + 1;
memset(m_pRanges + nStart, 20, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0x1740;
nCount = 0x175F - nStart + 1;
memset(m_pRanges + nStart, 20, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
nStart = 0x1760;
nCount = 0x177F - nStart + 1;
memset(m_pRanges + nStart, 20, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 21: sUCRName = "Old Italic"; break; /*U+10300-U+1032F*/
//case 22: sUCRName = "Gothic"; break; /*U+10330-U+1034F*/
//case 23: sUCRName = "Deseret"; break; /*U+10400-U+1044F*/
//case 24: sUCRName = "Byzantine Musical Symbols"; break; /*U+1D000-U+1D0FF*/ /*U+1D100-U+1D1FF*/ /*U+1D200-U+1D24F*/
//case 25: sUCRName = "Mathematical Alphanumeric Symbols"; break; /*U+1D400-U+1D7FF*/
//case 26: sUCRName = "Private Use (plane 15)"; break; /*U+F0000-U+FFFFD*/ /*U+100000-U+10FFFD*/ //
//case 27: sUCRName = "Variation Selectors"; break; /* U+FE00-U+FE0F */ /*U+E0100-U+E01EF*/
nStart = 0xFE00;
nCount = 0xFE0F - nStart + 1;
memset(m_pRanges + nStart, 27, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 28: sUCRName = "Tags"; break; /*U+E0000-U+E007F*/
//case 29: sUCRName = "Limbu"; break; /* U+1900-U+194F */
nStart = 0x1900;
nCount = 0x194F - nStart + 1;
memset(m_pRanges + nStart, 29, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 30: sUCRName = "Tai Le"; break; /* U+1950-U+197F */
nStart = 0x1950;
nCount = 0x197F - nStart + 1;
memset(m_pRanges + nStart, 30, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
//case 31: sUCRName = "New Tai Lue"; break; /* U+1980-U+19DF */
nStart = 0x1980;
nCount = 0x19DF - nStart + 1;
memset(m_pRanges + nStart, 31, nCount);
memset(m_pRangesNums + nStart, 2, nCount);
// rangeNum 3
//case 00: sUCRName = "Buginese"; break; /* U+1A00-U+1A1F */
nStart = 0x1A00;
nCount = 0x1A1F - nStart + 1;
memset(m_pRanges + nStart, 0, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 01: sUCRName = "Glagolitic"; break; /* U+2C00-U+2C5F */
nStart = 0x2C00;
nCount = 0x2C5F - nStart + 1;
memset(m_pRanges + nStart, 1, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 02: sUCRName = "Tifinagh"; break; /* U+2D30-U+2D7F */
nStart = 0x2D30;
nCount = 0x2D7F - nStart + 1;
memset(m_pRanges + nStart, 2, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 03: sUCRName = "Yijing Hexagram Symbols"; break; /* U+4DC0-U+4DFF */
nStart = 0x4DC0;
nCount = 0x4DFF - nStart + 1;
memset(m_pRanges + nStart, 3, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 04: sUCRName = "Syloti Nagri"; break; /* U+A800-U+A82F */
nStart = 0xA800;
nCount = 0xA82F - nStart + 1;
memset(m_pRanges + nStart, 4, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 05: sUCRName = "Linear B Syllabary"; break; /*U+10000-U+1007F*/ /*U+10080-U+100FF*/ /*U+10100-U+1013F*/
//case 06: sUCRName = "Ancient Greek Numbers"; break; /*U+10140-U+1018F*/
//case 07: sUCRName = "Ugaritic"; break; /*U+10380-U+1039F*/
//case 08: sUCRName = "Old Persian"; break; /*U+103A0-U+103DF*/
//case 09: sUCRName = "Shavian"; break; /*U+10450-U+1047F*/
//case 10: sUCRName = "Osmanya"; break; /*U+10480-U+104AF*/
//case 11: sUCRName = "Cypriot Syllabary"; break; /*U+10800-U+1083F*/
//case 12: sUCRName = "Kharoshthi"; break; /*U+10A00-U+10A5F*/
//case 13: sUCRName = "Tai Xuan Jing Symbols"; break; /*U+1D300-U+1D35F*/
//case 14: sUCRName = "Cuneiform"; break; /*U+12000-U+123FF*/ /*U+12400-U+1247F*/
//case 15: sUCRName = "Counting Rod Numerals"; break; /*U+1D360-U+1D37F*/
//case 16: sUCRName = "Sundanese"; break; /* U+1B80-U+1BBF */
nStart = 0x1B80;
nCount = 0x1BBF - nStart + 1;
memset(m_pRanges + nStart, 16, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 17: sUCRName = "Lepcha"; break; /* U+1C00-U+1C4F */
nStart = 0x1C00;
nCount = 0x1C4F - nStart + 1;
memset(m_pRanges + nStart, 17, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 18: sUCRName = "Ol Chiki"; break; /* U+1C50-U+1C7F */
nStart = 0x1C50;
nCount = 0x1C7F - nStart + 1;
memset(m_pRanges + nStart, 18, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 19: sUCRName = "Saurashtra"; break; /* U+A880-U+A8DF */
nStart = 0xA880;
nCount = 0xA8DF - nStart + 1;
memset(m_pRanges + nStart, 19, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 20: sUCRName = "Kayah Li"; break; /* U+A900-U+A92F */
nStart = 0xA900;
nCount = 0xA92F - nStart + 1;
memset(m_pRanges + nStart, 20, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 21: sUCRName = "Rejang"; break; /* U+A930-U+A95F */
nStart = 0xA930;
nCount = 0xA95F - nStart + 1;
memset(m_pRanges + nStart, 21, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 22: sUCRName = "Cham"; break; /* U+AA00-U+AA5F */
nStart = 0xAA00;
nCount = 0xAA5F - nStart + 1;
memset(m_pRanges + nStart, 22, nCount);
memset(m_pRangesNums + nStart, 3, nCount);
//case 23: sUCRName = "Ancient Symbols"; break; /*U+10190-U+101CF*/
//case 24: sUCRName = "Phaistos Disc"; break; /*U+101D0-U+101FF*/
//case 25: sUCRName = "Carian"; break; /*U+102A0-U+102DF*/ /*U+10280-U+1029F*/ /*U+10920-U+1093F*/
//case 26: sUCRName = "Domino Tiles"; break; /*U+1F030-U+1F09F*/ /*U+1F000-U+1F02F*/
//case 27: sUCRName = "Reserved for process-internal usage"; break;
//case 28: sUCRName = "Reserved for process-internal usage"; break;
//case 29: sUCRName = "Reserved for process-internal usage"; break;
//case 30: sUCRName = "Reserved for process-internal usage"; break;
//case 31: sUCRName = "Reserved for process-internal usage"; break;
}
__forceinline bool GetRange(const WCHAR& symbol, BYTE& lRangeNum, BYTE& lRange)
{
lRangeNum = m_pRangesNums[symbol];
lRange = m_pRanges[symbol];
return (0xFF != lRangeNum);
}
__forceinline void CheckRanges(DWORD& lRange1, DWORD& lRange2, DWORD& lRange3, DWORD& lRange4, CString strText)
{
int lCount = strText.GetLength();
WCHAR* pData = strText.GetBuffer();
BYTE lRangeNum = 0xFF;
BYTE lRange = 0xFF;
for (int i = 0; i < lCount; ++i, ++pData)
{
if (GetRange(*pData, lRangeNum, lRange))
{
if (0 == lRangeNum)
lRange1 |= 1 << lRange;
else if (1 == lRangeNum)
lRange2 |= 1 << lRange;
else if (2 == lRangeNum)
lRange3 |= 1 << lRange;
else
lRange4 |= 1 << lRange;
}
}
}
__forceinline void CheckRanges(DWORD& lRange1, DWORD& lRange2, DWORD& lRange3, DWORD& lRange4, BYTE& lRangeNum, BYTE& lRange)
{
if (0 == lRangeNum)
lRange1 |= 1 << lRange;
else if (1 == lRangeNum)
lRange2 |= 1 << lRange;
else if (2 == lRangeNum)
lRange3 |= 1 << lRange;
else
lRange4 |= 1 << lRange;
}
public:
__forceinline bool GenerateFontName(CString& strText)
{
if (_T("") == m_oFont.m_oFont.Path || (0 == strText.GetLength()))
{
m_strCurrentPickFont = m_oFont.m_strFamilyName;
m_lCurrentPictFontStyle = m_oFont.m_lStyle;
return false;
}
BYTE lRangeNum = 0xFF;
BYTE lRange = 0xFF;
GetRange(strText[0], lRangeNum, lRange);
POSITION posStart = m_arListPicUps.GetHeadPosition();
POSITION pos = posStart;
while (NULL != pos)
{
POSITION posOld = pos;
CFontPickUp& oPick = m_arListPicUps.GetNext(pos);
if ((oPick.m_oFont.m_oFont.IsEqual3(&m_oFont.m_oFont)) && (lRangeNum == oPick.m_lRangeNum) && (lRange == oPick.m_lRange))
{
// !
//
m_arListPicUps.MoveToHead(posOld);
m_strCurrentPickFont = oPick.m_strPickFont;
m_lCurrentPictFontStyle = oPick.m_lPickStyle;
return false;
}
}
// ...
m_arListPicUps.AddHead();
CFontPickUp& oPick = m_arListPicUps.GetHead();
oPick.m_lRangeNum = lRangeNum;
oPick.m_lRange = lRange;
oPick.m_oFont = m_oFont;
oPick.m_strPickFont = m_oFont.m_strFamilyName;
oPick.m_lPickStyle = m_oFont.m_lStyle;
AVSGraphics::IASCFontManager2* pManager2 = NULL;
m_pManager->QueryInterface(AVSGraphics::IID_IASCFontManager2, (void**)&pManager2);
BSTR bsFontName = m_oFont.m_strFamilyName.AllocSysString();
BSTR bsNewFontName = NULL;
DWORD dwR1 = m_oFont.m_arSignature[0];
DWORD dwR2 = m_oFont.m_arSignature[1];
DWORD dwR3 = m_oFont.m_arSignature[2];
DWORD dwR4 = m_oFont.m_arSignature[3];
DWORD dwCodePage1 = 0;
DWORD dwCodePage2 = 0;
if ((lRangeNum == 1) && (lRange == 28))
{
dwCodePage1 = 0x80000000;
//strText = (WCHAR)(strText[0] - 0xF000);
}
else if (((lRangeNum == 2) && (lRange == 3)) || ((lRangeNum == 1) && (lRange == 31)) || ((lRangeNum == 0) && (lRange == 13)))
{
// !!!
dwR1 = 1 << 13;
dwR2 = 1 << 31;
dwR3 = 1 << 3;
}
else
{
CheckRanges(dwR1, dwR2, dwR3, dwR4, lRangeNum, lRange);
}
BSTR bsPanose = m_oFont.m_strPANOSE.AllocSysString();
LONG lFontStyle = m_oFont.m_oFont.GetStyle();
pManager2->GetWinFontByParams2(&bsNewFontName, bsFontName, -1, NULL, &lFontStyle, m_oFont.m_bIsFixedWidth ? 1 : 0, bsPanose,
dwR1, dwR2, dwR3, dwR4, dwCodePage1, dwCodePage2, m_oFont.m_lAvgWidth);
oPick.m_strPickFont = (CString)bsNewFontName;
oPick.m_lPickStyle = lFontStyle;
m_strCurrentPickFont = oPick.m_strPickFont;
m_lCurrentPictFontStyle = oPick.m_lPickStyle;
SysFreeString(bsFontName);
SysFreeString(bsPanose);
SysFreeString(bsNewFontName);
RELEASEINTERFACE(pManager2);
return true;
}
};
};
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/></Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Default Extension="png" ContentType="image/png"/><Default Extension="jpg" ContentType="image/jpg"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"/><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/><Override PartName="/word/theme/theme.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/></Types>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Template>Normal.dotm</Template><TotalTime>1</TotalTime><Pages>1</Pages><Words>0</Words><Characters>0</Characters><Application>Microsoft Office Word</Application><DocSecurity>0</DocSecurity><Lines>1</Lines><Paragraphs>1</Paragraphs><ScaleCrop>false</ScaleCrop><LinksUpToDate>false</LinksUpToDate><CharactersWithSpaces>0</CharactersWithSpaces><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>12.0000</AppVersion></Properties>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:title/><dc:subject/><dc:creator/><cp:keywords/><dc:description/><cp:lastModifiedBy/><cp:revision>1</cp:revision></cp:coreProperties>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><w:settings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"><w:zoom w:percent="100"/><w:defaultTabStop w:val="708"/><w:drawingGridHorizontalSpacing/><w:displayHorizontalDrawingGridEvery/><w:characterSpacingControl w:val="doNotCompress"/><w:compat/><m:mathPr><m:mathFont m:val="Cambria Math"/><m:brkBin m:val="before"/><m:brkBinSub m:val="--"/><m:smallFrac m:val="off"/><m:dispDef/><m:lMargin m:val="0"/><m:rMargin m:val="0"/><m:defJc m:val="centerGroup"/><m:wrapIndent m:val="1440"/><m:intLim m:val="subSup"/><m:naryLim m:val="undOvr"/></m:mathPr><w:themeFontLang w:val="ru-RU"/><w:clrSchemeMapping w:bg1="light1" w:t1="dark1" w:bg2="light2" w:t2="dark2" w:accent1="accent1" w:accent2="accent2" w:accent3="accent3" w:accent4="accent4" w:accent5="accent5" w:accent6="accent6" w:hyperlink="hyperlink" w:followedHyperlink="followedHyperlink"/><w:shapeDefaults><o:shapedefaults v:ext="edit" spidmax="3074"/><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1"/><o:rules v:ext=""/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=","/><w:listSeparator w:val=";"/></w:settings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:docDefaults><w:rPrDefault><w:rPr><w:webHidden w:val="false"/><w:lang w:val="ru-RU" w:eastAsia="en-US" w:bidi="ar-SA"/><w:rFonts w:eastAsiaTheme="minorHAnsi" w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr/></w:pPrDefault></w:docDefaults><w:latentStyles w:defLockedState="false" w:defUIPriority="99" w:defSemiHidden="true" w:defUnhideWhenUsed="true" w:defQFormat="false" w:count="267"><w:lsdException w:name="Normal" w:semiHidden="false" w:uiPriority="0" w:unhideWhenUsed="false"/><w:lsdException w:name="heading 1" w:semiHidden="false" w:uiPriority="9" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="heading 2" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="heading 3" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="heading 4" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="heading 5" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="heading 6" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="heading 7" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="heading 8" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="heading 9" w:uiPriority="9" w:qFormat="true"/><w:lsdException w:name="toc 1" w:uiPriority="39"/><w:lsdException w:name="toc 2" w:uiPriority="39"/><w:lsdException w:name="toc 3" w:uiPriority="39"/><w:lsdException w:name="toc 4" w:uiPriority="39"/><w:lsdException w:name="toc 5" w:uiPriority="39"/><w:lsdException w:name="toc 6" w:uiPriority="39"/><w:lsdException w:name="toc 7" w:uiPriority="39"/><w:lsdException w:name="toc 8" w:uiPriority="39"/><w:lsdException w:name="toc 9" w:uiPriority="39"/><w:lsdException w:name="caption" w:uiPriority="35" w:qFormat="true"/><w:lsdException w:name="Title" w:semiHidden="false" w:uiPriority="10" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Default Paragraph Font" w:uiPriority="1"/><w:lsdException w:name="Subtitle" w:semiHidden="false" w:uiPriority="11" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Strong" w:semiHidden="false" w:uiPriority="22" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Emphasis" w:semiHidden="false" w:uiPriority="20" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Table Grid" w:semiHidden="false" w:uiPriority="59" w:unhideWhenUsed="false"/><w:lsdException w:name="Placeholder Text" w:unhideWhenUsed="false"/><w:lsdException w:name="No Spacing" w:semiHidden="false" w:uiPriority="1" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Light Shading" w:semiHidden="false" w:uiPriority="60" w:unhideWhenUsed="false"/><w:lsdException w:name="Light List" w:semiHidden="false" w:uiPriority="61" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Grid" w:semiHidden="false" w:uiPriority="62" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 1" w:semiHidden="false" w:uiPriority="63" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 2" w:semiHidden="false" w:uiPriority="64" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 1" w:semiHidden="false" w:uiPriority="65" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 2" w:semiHidden="false" w:uiPriority="66" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 1" w:semiHidden="false" w:uiPriority="67" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 2" w:semiHidden="false" w:uiPriority="68" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 3" w:semiHidden="false" w:uiPriority="69" w:unhideWhenUsed="false"/><w:lsdException w:name="Dark List" w:semiHidden="false" w:uiPriority="70" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Shading" w:semiHidden="false" w:uiPriority="71" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful List" w:semiHidden="false" w:uiPriority="72" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Grid" w:semiHidden="false" w:uiPriority="73" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Shading Accent 1" w:semiHidden="false" w:uiPriority="60" w:unhideWhenUsed="false"/><w:lsdException w:name="Light List Accent 1" w:semiHidden="false" w:uiPriority="61" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Grid Accent 1" w:semiHidden="false" w:uiPriority="62" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 1 Accent 1" w:semiHidden="false" w:uiPriority="63" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 2 Accent 1" w:semiHidden="false" w:uiPriority="64" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 1 Accent 1" w:semiHidden="false" w:uiPriority="65" w:unhideWhenUsed="false"/><w:lsdException w:name="Revision" w:unhideWhenUsed="false"/><w:lsdException w:name="List Paragraph" w:semiHidden="false" w:uiPriority="34" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Quote" w:semiHidden="false" w:uiPriority="29" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Intense Quote" w:semiHidden="false" w:uiPriority="30" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Medium List 2 Accent 1" w:semiHidden="false" w:uiPriority="66" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 1 Accent 1" w:semiHidden="false" w:uiPriority="67" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 2 Accent 1" w:semiHidden="false" w:uiPriority="68" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 3 Accent 1" w:semiHidden="false" w:uiPriority="69" w:unhideWhenUsed="false"/><w:lsdException w:name="Dark List Accent 1" w:semiHidden="false" w:uiPriority="70" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Shading Accent 1" w:semiHidden="false" w:uiPriority="71" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful List Accent 1" w:semiHidden="false" w:uiPriority="72" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Grid Accent 1" w:semiHidden="false" w:uiPriority="73" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Shading Accent 2" w:semiHidden="false" w:uiPriority="60" w:unhideWhenUsed="false"/><w:lsdException w:name="Light List Accent 2" w:semiHidden="false" w:uiPriority="61" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Grid Accent 2" w:semiHidden="false" w:uiPriority="62" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 1 Accent 2" w:semiHidden="false" w:uiPriority="63" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 2 Accent 2" w:semiHidden="false" w:uiPriority="64" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 1 Accent 2" w:semiHidden="false" w:uiPriority="65" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 2 Accent 2" w:semiHidden="false" w:uiPriority="66" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 1 Accent 2" w:semiHidden="false" w:uiPriority="67" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 2 Accent 2" w:semiHidden="false" w:uiPriority="68" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 3 Accent 2" w:semiHidden="false" w:uiPriority="69" w:unhideWhenUsed="false"/><w:lsdException w:name="Dark List Accent 2" w:semiHidden="false" w:uiPriority="70" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Shading Accent 2" w:semiHidden="false" w:uiPriority="71" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful List Accent 2" w:semiHidden="false" w:uiPriority="72" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Grid Accent 2" w:semiHidden="false" w:uiPriority="73" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Shading Accent 3" w:semiHidden="false" w:uiPriority="60" w:unhideWhenUsed="false"/><w:lsdException w:name="Light List Accent 3" w:semiHidden="false" w:uiPriority="61" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Grid Accent 3" w:semiHidden="false" w:uiPriority="62" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 1 Accent 3" w:semiHidden="false" w:uiPriority="63" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 2 Accent 3" w:semiHidden="false" w:uiPriority="64" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 1 Accent 3" w:semiHidden="false" w:uiPriority="65" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 2 Accent 3" w:semiHidden="false" w:uiPriority="66" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 1 Accent 3" w:semiHidden="false" w:uiPriority="67" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 2 Accent 3" w:semiHidden="false" w:uiPriority="68" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 3 Accent 3" w:semiHidden="false" w:uiPriority="69" w:unhideWhenUsed="false"/><w:lsdException w:name="Dark List Accent 3" w:semiHidden="false" w:uiPriority="70" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Shading Accent 3" w:semiHidden="false" w:uiPriority="71" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful List Accent 3" w:semiHidden="false" w:uiPriority="72" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Grid Accent 3" w:semiHidden="false" w:uiPriority="73" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Shading Accent 4" w:semiHidden="false" w:uiPriority="60" w:unhideWhenUsed="false"/><w:lsdException w:name="Light List Accent 4" w:semiHidden="false" w:uiPriority="61" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Grid Accent 4" w:semiHidden="false" w:uiPriority="62" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 1 Accent 4" w:semiHidden="false" w:uiPriority="63" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 2 Accent 4" w:semiHidden="false" w:uiPriority="64" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 1 Accent 4" w:semiHidden="false" w:uiPriority="65" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 2 Accent 4" w:semiHidden="false" w:uiPriority="66" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 1 Accent 4" w:semiHidden="false" w:uiPriority="67" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 2 Accent 4" w:semiHidden="false" w:uiPriority="68" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 3 Accent 4" w:semiHidden="false" w:uiPriority="69" w:unhideWhenUsed="false"/><w:lsdException w:name="Dark List Accent 4" w:semiHidden="false" w:uiPriority="70" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Shading Accent 4" w:semiHidden="false" w:uiPriority="71" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful List Accent 4" w:semiHidden="false" w:uiPriority="72" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Grid Accent 4" w:semiHidden="false" w:uiPriority="73" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Shading Accent 5" w:semiHidden="false" w:uiPriority="60" w:unhideWhenUsed="false"/><w:lsdException w:name="Light List Accent 5" w:semiHidden="false" w:uiPriority="61" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Grid Accent 5" w:semiHidden="false" w:uiPriority="62" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 1 Accent 5" w:semiHidden="false" w:uiPriority="63" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 2 Accent 5" w:semiHidden="false" w:uiPriority="64" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 1 Accent 5" w:semiHidden="false" w:uiPriority="65" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 2 Accent 5" w:semiHidden="false" w:uiPriority="66" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 1 Accent 5" w:semiHidden="false" w:uiPriority="67" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 2 Accent 5" w:semiHidden="false" w:uiPriority="68" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 3 Accent 5" w:semiHidden="false" w:uiPriority="69" w:unhideWhenUsed="false"/><w:lsdException w:name="Dark List Accent 5" w:semiHidden="false" w:uiPriority="70" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Shading Accent 5" w:semiHidden="false" w:uiPriority="71" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful List Accent 5" w:semiHidden="false" w:uiPriority="72" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Grid Accent 5" w:semiHidden="false" w:uiPriority="73" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Shading Accent 6" w:semiHidden="false" w:uiPriority="60" w:unhideWhenUsed="false"/><w:lsdException w:name="Light List Accent 6" w:semiHidden="false" w:uiPriority="61" w:unhideWhenUsed="false"/><w:lsdException w:name="Light Grid Accent 6" w:semiHidden="false" w:uiPriority="62" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 1 Accent 6" w:semiHidden="false" w:uiPriority="63" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Shading 2 Accent 6" w:semiHidden="false" w:uiPriority="64" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 1 Accent 6" w:semiHidden="false" w:uiPriority="65" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium List 2 Accent 6" w:semiHidden="false" w:uiPriority="66" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 1 Accent 6" w:semiHidden="false" w:uiPriority="67" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 2 Accent 6" w:semiHidden="false" w:uiPriority="68" w:unhideWhenUsed="false"/><w:lsdException w:name="Medium Grid 3 Accent 6" w:semiHidden="false" w:uiPriority="69" w:unhideWhenUsed="false"/><w:lsdException w:name="Dark List Accent 6" w:semiHidden="false" w:uiPriority="70" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Shading Accent 6" w:semiHidden="false" w:uiPriority="71" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful List Accent 6" w:semiHidden="false" w:uiPriority="72" w:unhideWhenUsed="false"/><w:lsdException w:name="Colorful Grid Accent 6" w:semiHidden="false" w:uiPriority="73" w:unhideWhenUsed="false"/><w:lsdException w:name="Subtle Emphasis" w:semiHidden="false" w:uiPriority="19" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Intense Emphasis" w:semiHidden="false" w:uiPriority="21" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Subtle Reference" w:semiHidden="false" w:uiPriority="31" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Intense Reference" w:semiHidden="false" w:uiPriority="32" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Book Title" w:semiHidden="false" w:uiPriority="33" w:unhideWhenUsed="false" w:qFormat="true"/><w:lsdException w:name="Bibliography" w:uiPriority="37"/><w:lsdException w:name="TOC Heading" w:uiPriority="39" w:qFormat="true"/></w:latentStyles><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/></w:style><w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font"/><w:semiHidden/><w:unhideWhenUsed/><w:uiPriority w:val="1"/></w:style><w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:semiHidden/><w:unhideWhenUsed/><w:qFormat/><w:uiPriority w:val="99"/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="numbering" w:default="1" w:styleId="NoList"><w:name w:val="No List"/><w:semiHidden/><w:unhideWhenUsed/><w:uiPriority w:val="99"/></w:style></w:styles>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS 明朝"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera ><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><w:webSettings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:optimizeForBrowser/></w:webSettings>
\ No newline at end of file
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AVSOfficeDocxRenderer.rc
//
#define IDS_PROJNAME 100
#define IDR_ASCOFFICEDOCXRENDERER 101
#define IDB_DEFAULT_DOC_RELS 201
#define IDB_DEFAULT_DOC_CONTENT_TYPES 202
#define IDB_DEFAULT_DOC_APP 203
#define IDB_DEFAULT_DOC_CORE 204
#define IDB_DEFAULT_DOC_STYLES 205
#define IDB_DEFAULT_DOC_THEME 206
#define IDB_DEFAULT_DOC_WEBSETTINGS 207
#define IDB_DEFAULT_DOC_SETTINGS 208
// 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
// AVSOfficeDocxRenderer.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/ASCGraphics.dll" named_guids raw_interfaces_only rename_namespace("AVSGraphics")
#import "../Redist/ASCMediaCore3.dll" named_guids raw_interfaces_only rename_namespace("MediaCore"), exclude("tagRECT")
#import "../Redist/ASCImageStudio3.dll" named_guids raw_interfaces_only rename_namespace("ImageStudio")
\ No newline at end of file
#pragma once
//2
//0
//0
//10
#define INTVER 2,0,0,10
#define STRVER "2,0,0,10\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