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

работа под линукс

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63679 954022d7-b5bf-4e40-9824-e11837661b57
parent 53e35b5a
......@@ -189,7 +189,7 @@ namespace NSOnlineOfficeBinToPdf
if (sizeof(wchar_t) == 4)
{
#if !defined(_WIN32) && !defined(_WIN64)
wsTempString = stringUtf16ToWString((UTF16*)pData, nLen / 2);
wsTempString = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)pData, nLen / 2);
#endif
}
else
......@@ -792,4 +792,4 @@ namespace NSOnlineOfficeBinToPdf
return true;
}
}
\ No newline at end of file
}
......@@ -1469,11 +1469,11 @@ bool CPdfRenderer::PathCommandDrawText(unsigned int* pUnicodes, unsigned int unL
void CPdfRenderer::UpdateFont()
{
m_bNeedUpdateTextFont = false;
std::wstring& wsFontPath = m_oFont.GetPath();
std::wstring wsFontPath = m_oFont.GetPath();
LONG lFaceIndex = m_oFont.GetFaceIndex();
if (L"" == wsFontPath)
{
std::wstring& wsFontName = m_oFont.GetName();
std::wstring wsFontName = m_oFont.GetName();
bool bBold = m_oFont.IsBold();
bool bItalic = m_oFont.IsItalic();
bool bFind = false;
......@@ -1521,7 +1521,7 @@ void CPdfRenderer::UpdateTransform()
}
void CPdfRenderer::UpdatePen()
{
TColor& oColor = m_oPen.GetTColor();
TColor oColor = m_oPen.GetTColor();
m_pPage->SetStrokeColor(oColor.r, oColor.g, oColor.b);
m_pPage->SetStrokeAlpha((unsigned char)m_oPen.GetAlpha());
m_pPage->SetLineWidth(MM_2_PT(m_oPen.GetSize()));
......@@ -1587,7 +1587,7 @@ void CPdfRenderer::UpdateBrush()
LONG lBrushType = m_oBrush.GetType();
if (c_BrushTypeTexture == lBrushType)
{
std::wstring& wsTexturePath = m_oBrush.GetTexturePath();
std::wstring wsTexturePath = m_oBrush.GetTexturePath();
CImageFileFormatChecker oImageFormat(wsTexturePath);
CImageDict* pImage = NULL;
......@@ -1636,8 +1636,8 @@ void CPdfRenderer::UpdateBrush()
dR += 1;
// Растягиваем картинку по размерам пата
dW = max(10, dR - dL);
dH = max(10, dB - dT);
dW = std::max(10.0, dR - dL);
dH = std::max(10.0, dB - dT);
}
else
{
......@@ -1657,13 +1657,13 @@ void CPdfRenderer::UpdateBrush()
}
else if (c_BrushTypeHatch1 == lBrushType)
{
std::wstring& wsHatchType = m_oBrush.GetTexturePath();
std::wstring wsHatchType = m_oBrush.GetTexturePath();
double dW = 8 * 72 / 96;
double dH = 8 * 72 / 96;
TColor& oColor1 = m_oBrush.GetTColor1();
TColor& oColor2 = m_oBrush.GetTColor2();
TColor oColor1 = m_oBrush.GetTColor1();
TColor oColor2 = m_oBrush.GetTColor2();
BYTE nAlpha1 = (BYTE)m_oBrush.GetAlpha1();
BYTE nAlpha2 = (BYTE)m_oBrush.GetAlpha2();
......@@ -1710,7 +1710,7 @@ void CPdfRenderer::UpdateBrush()
}
else// if (c_BrushTypeSolid == lBrushType)
{
TColor& oColor1 = m_oBrush.GetTColor1();
TColor oColor1 = m_oBrush.GetTColor1();
m_pPage->SetFillColor(oColor1.r, oColor1.g, oColor1.b);
m_pPage->SetFillAlpha((unsigned char)m_oBrush.GetAlpha1());
}
......@@ -1895,4 +1895,4 @@ void CPdfRenderer::CBrushState::Reset()
m_pShadingColors = NULL;
m_pShadingPoints = NULL;
m_lShadingPointsCount = 0;
}
\ No newline at end of file
}
......@@ -313,7 +313,7 @@ private:
}
inline void SetAlpha(const LONG& lAlpha)
{
m_nAlpha = (BYTE)max(0, min(255, (int)lAlpha));
m_nAlpha = (BYTE)std::max(0, std::min(255, (int)lAlpha));
}
inline double GetSize()
{
......@@ -543,7 +543,7 @@ private:
}
inline void SetAlpha1(const LONG& lAlpha)
{
m_nAlpha1 = (BYTE)max(0, min(255, (int)lAlpha));
m_nAlpha1 = (BYTE)std::max(0, std::min(255, (int)lAlpha));
}
inline LONG GetAlpha2()
{
......@@ -551,7 +551,7 @@ private:
}
inline void SetAlpha2(const LONG& lAlpha)
{
m_nAlpha2 = (BYTE)max(0, min(255, (int)lAlpha));
m_nAlpha2 = (BYTE)std::max(0, std::min(255, (int)lAlpha));
}
inline std::wstring GetTexturePath()
{
......@@ -575,7 +575,7 @@ private:
}
inline void SetTextureAlpha(const LONG& lAlpha)
{
m_nTextureAlpha = (BYTE)max(0, min(255, (int)lAlpha));
m_nTextureAlpha = (BYTE)std::max(0, std::min(255, (int)lAlpha));
}
inline double GetLinearAngle()
{
......@@ -870,10 +870,10 @@ private:
TColor oColor1 = lColor1;
TColor oColor2 = lColor2;
BYTE r = (BYTE)max(0, min(255, (int)(oColor1.r + (oColor2.r - oColor1.r) / dDiff * (dDstPoint - dPoint1))));
BYTE g = (BYTE)max(0, min(255, (int)(oColor1.g + (oColor2.g - oColor1.g) / dDiff * (dDstPoint - dPoint1))));
BYTE b = (BYTE)max(0, min(255, (int)(oColor1.b + (oColor2.b - oColor1.b) / dDiff * (dDstPoint - dPoint1))));
BYTE a = (BYTE)max(0, min(255, (int)(oColor1.a + (oColor2.a - oColor1.a) / dDiff * (dDstPoint - dPoint1))));
BYTE r = (BYTE)std::max(0, std::min(255, (int)(oColor1.r + (oColor2.r - oColor1.r) / dDiff * (dDstPoint - dPoint1))));
BYTE g = (BYTE)std::max(0, std::min(255, (int)(oColor1.g + (oColor2.g - oColor1.g) / dDiff * (dDstPoint - dPoint1))));
BYTE b = (BYTE)std::max(0, std::min(255, (int)(oColor1.b + (oColor2.b - oColor1.b) / dDiff * (dDstPoint - dPoint1))));
BYTE a = (BYTE)std::max(0, std::min(255, (int)(oColor1.a + (oColor2.a - oColor1.a) / dDiff * (dDstPoint - dPoint1))));
TColor oResColor;
oResColor.Set(r, g, b, a);
......
......@@ -94,7 +94,8 @@ DEFINES += \
win32 {
DEFINES += \
JAS_WIN_MSVC_BUILD \
WIN32
WIN32 \
NOMINMAX
message(windows)
}
......
......@@ -107,7 +107,7 @@ namespace PdfWriter
}
void CLinkAnnotation::SetBorderStyle(float fWidth, unsigned short nDashOn, unsigned short nDashOff)
{
fWidth = max(fWidth, 0);
fWidth = std::max(fWidth, 0.f);
CArrayObject* pArray = new CArrayObject();
if (!pArray)
......@@ -152,7 +152,7 @@ namespace PdfWriter
void SetOpened(bool bOpened);
void CTextAnnotation::SetIcon(EAnnotIcon eIcon)
{
eIcon = (EAnnotIcon)min(max(AnnotIconMin, eIcon), AnnotIconMax);
eIcon = (EAnnotIcon)std::min(std::max(AnnotIconMin, eIcon), AnnotIconMax);
Add("Name", c_sAnnotIconNames[(int)eIcon]);
}
void CTextAnnotation::SetOpened(bool bOpened)
......@@ -173,4 +173,4 @@ namespace PdfWriter
pAction->Add("S", "URI");
pAction->Add("URI", new CStringObject(sUri));
}
}
\ No newline at end of file
}
#ifndef _PDF_WRITER_SRC_CONSTS_H
#define _PDF_WRITER_SRC_CONSTS_H
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#define OK 0
#define NOERROR 0
......
......@@ -44,8 +44,8 @@ namespace PdfWriter
if (fZoom < 0.08 || fZoom > 32)
fZoom = 0;
fLeft = max(fLeft, 0);
fTop = max(fTop, 0);
fLeft = std::max(fLeft, 0.f);
fTop = std::max(fTop, 0.f);
PrepareArray();
Add("XYZ");
......
......@@ -249,7 +249,7 @@ namespace PdfWriter
if (!pLabel)
return NULL;
eStyle = min(max(eStyle, pagenumstyle_Min), pagenumstyle_Max);
eStyle = std::min(std::max(eStyle, pagenumstyle_Min), pagenumstyle_Max);
switch (eStyle)
{
case pagenumstyle_UpperRoman: pLabel->Add("S", "R"); break;
......
......@@ -88,19 +88,19 @@ namespace PdfWriter
}
void CExtGrState::SetAlphaStroke (double dValue)
{
dValue = min(1, max(0, dValue));
dValue = std::min(1.0, std::max(0.0, dValue));
Add("CA", dValue);
m_dAlphaStroke = dValue;
}
void CExtGrState::SetAlphaFill (double dValue)
{
dValue = min(1, max(0, dValue));
dValue = std::min(1.0, std::max(0.0, dValue));
Add("ca", dValue);
m_dAlphaFill = dValue;
}
void CExtGrState::SetBlendMode (EBlendMode eBlendMode)
{
eBlendMode = min(blendmode_Max, max(blendmode_Min, eBlendMode));
eBlendMode = std::min(blendmode_Max, std::max(blendmode_Min, eBlendMode));
Add("BM", c_sBlendModeNames[(int)eBlendMode]);
m_eBlendMode = eBlendMode;
}
......
......@@ -144,7 +144,7 @@ namespace PdfWriter
}
void CBinaryObject::Set(const BYTE* pValue, unsigned int unLen)
{
unLen = min(LIMIT_MAX_STRING_LEN, unLen);
unLen = std::min((unsigned int)LIMIT_MAX_STRING_LEN, unLen);
if (m_pValue)
{
delete[] m_pValue;
......
......@@ -161,11 +161,11 @@ namespace PdfWriter
}
void Set(float fValue)
{
m_fValue = min(max(fValue, LIMIT_MIN_REAL), LIMIT_MAX_REAL);
m_fValue = std::min(std::max(fValue, LIMIT_MIN_REAL), LIMIT_MAX_REAL);
}
void Set(double dValue)
void Set(double dValue)
{
m_fValue = (float)min(max(dValue, LIMIT_MIN_REAL), LIMIT_MAX_REAL);
m_fValue = (float)std::min(std::max((float)dValue, LIMIT_MIN_REAL), LIMIT_MAX_REAL);
}
float Get() const
{
......
......@@ -209,7 +209,7 @@ namespace PdfWriter
}
void CPage::SetWidth(double dValue)
{
dValue = min(max(dValue, 1), 14400);
dValue = std::min(std::max(dValue, 1.0), 14400.0);
SetMediaBoxValue(2, dValue);
}
double CPage::GetWidth()
......@@ -218,7 +218,7 @@ namespace PdfWriter
}
void CPage::SetHeight(double dValue)
{
dValue = min(max(dValue, 1), 14400);
dValue = std::min(std::max(dValue, 1.0), 14400.0);
SetMediaBoxValue(3, dValue);
}
double CPage::GetHeight()
......@@ -421,8 +421,8 @@ namespace PdfWriter
int nFirstPointQuard = int(_dAngle1) / 90 + 1;
int nSecondPointQuard = int(_dAngle2) / 90 + 1;
nSecondPointQuard = min(4, max(1, nSecondPointQuard));
nFirstPointQuard = min(4, max(1, nFirstPointQuard));
nSecondPointQuard = std::min(4, std::max(1, nSecondPointQuard));
nFirstPointQuard = std::min(4, std::max(1, nFirstPointQuard));
// Проведем линию в начальную точку дуги
double dStartX = 0.0, dStartY = 0.0, dEndX = 0.0, dEndY = 0.0;
......@@ -603,7 +603,7 @@ namespace PdfWriter
// Operator : w
// Descriprion: устанавливаем толщину линии
dLineWidth = max(dLineWidth, 0);
dLineWidth = std::max(dLineWidth, 0.0);
m_pStream->WriteReal(dLineWidth);
m_pStream->WriteStr(" w\012");
m_pGrState->m_dLineWidth = dLineWidth;
......@@ -613,7 +613,7 @@ namespace PdfWriter
// Operator : J
// Descriprion: устанавливаем вид окончания линии (LineCapStyle)
eLineCap = max(linecap_Min, min(linecap_Max, eLineCap));
eLineCap = std::max(linecap_Min, std::min(linecap_Max, eLineCap));
m_pStream->WriteInt((unsigned int)eLineCap);
m_pStream->WriteStr(" J\012");
m_pGrState->m_eLineCap = eLineCap;
......@@ -622,7 +622,7 @@ namespace PdfWriter
{
// Operator : j
// Descriprion: устанавливаем вид соединения линий (LineJoinStyle)
eLineJoin = max(linejoin_Min, min(linejoin_Max, eLineJoin));
eLineJoin = std::max(linejoin_Min, std::min(linejoin_Max, eLineJoin));
m_pStream->WriteInt((unsigned int)eLineJoin);
m_pStream->WriteStr(" j\012");
m_pGrState->m_eLineJoin = eLineJoin;
......@@ -631,7 +631,7 @@ namespace PdfWriter
{
// Operator : M
// Descriprion: устанавливаем MiterLimit - константа, относящаяся к виду соединения линий
dMiterLimit = max(1, dMiterLimit);
dMiterLimit = std::max(1.0, dMiterLimit);
m_pStream->WriteReal(dMiterLimit);
m_pStream->WriteStr(" M\012");
m_pGrState->m_dMiterLimit = dMiterLimit;
......@@ -673,7 +673,7 @@ namespace PdfWriter
{
// Operator : i
// Descriprion: устанавливаем порог ошибки линии (Flatness tolerance)
dFlatness = min(100, max(0, dFlatness));
dFlatness = std::min(100.0, std::max(0.0, dFlatness));
m_pStream->WriteReal(dFlatness);
m_pStream->WriteStr(" i\012");
m_pGrState->m_dFlatness = dFlatness;
......@@ -1000,7 +1000,7 @@ namespace PdfWriter
// Description: Устанавливаем расстояние между буквами
CheckGrMode(grmode_TEXT);
dValue = min(MAX_CHARSPACE, max(MIN_CHARSPACE, dValue));
dValue = std::min((double)MAX_CHARSPACE, std::max((double)MIN_CHARSPACE, dValue));
m_pStream->WriteReal(dValue);
m_pStream->WriteStr(" Tc\012");
}
......@@ -1010,7 +1010,7 @@ namespace PdfWriter
// Description: Устанавливаем горизонтальное растяжение/сжатие
CheckGrMode(grmode_TEXT);
dValue = min(MAX_HORIZONTALSCALING, max(MIN_HORIZONTALSCALING, dValue));
dValue = std::min((double)MAX_HORIZONTALSCALING, std::max((double)MIN_HORIZONTALSCALING, dValue));
m_pStream->WriteReal(dValue);
m_pStream->WriteStr(" Tz\012");
}
......@@ -1019,7 +1019,7 @@ namespace PdfWriter
// Operator : Tf
// Description: Устанавливаем фонт и размер фонта
dSize = min(MAX_FONTSIZE, max(0, dSize));
dSize = std::min((double)MAX_FONTSIZE, std::max(0.0, dSize));
const char* sFontName = GetLocalFontName(pFont);
if (!sFontName)
return;
......@@ -1369,4 +1369,4 @@ namespace PdfWriter
m_vWords.clear();
m_vShifts.clear();
}
}
\ No newline at end of file
}
......@@ -656,17 +656,17 @@ namespace PdfWriter
unsigned int unRemainBytes = m_nBufferSize - Tell();
if (unRemainBytes < unSize)
{
unsigned int unShrinkSize = max(unSize, STREAM_BUF_SIZ);
unsigned int unShrinkSize = std::max(unSize, (unsigned int)STREAM_BUF_SIZ);
Shrink(unShrinkSize);
}
MemCpy(m_pCur, pBuffer, unSize);
m_pCur += unSize;
m_unSize = (unsigned int)max(m_unSize, m_pCur - m_pBuffer);
m_unSize = (unsigned int)std::max(m_unSize, (unsigned int)(m_pCur - m_pBuffer));
}
void CMemoryStream::Read(BYTE* pBuffer, unsigned int* punSize)
{
unsigned int unRemainBytes = m_unSize - Tell();
unsigned int unReadedBytes = (punSize ? min(*punSize, unRemainBytes) : unRemainBytes);
unsigned int unReadedBytes = (punSize ? std::min(*punSize, unRemainBytes) : unRemainBytes);
MemCpy(pBuffer, m_pCur, unReadedBytes);
m_pCur += unReadedBytes;
if (punSize)
......@@ -841,7 +841,7 @@ namespace PdfWriter
switch (eMode)
{
case SeekCur: m_nFilePos += nPos; break;
case SeekEnd: m_nFilePos = max(0, (m_nFileSize - nPos)); break;
case SeekEnd: m_nFilePos = std::max(0, (m_nFileSize - nPos)); break;
case SeekSet: m_nFilePos = nPos; break;
}
}
......
......@@ -3,7 +3,20 @@
#include "Consts.h"
#include "../../DesktopEditor/common/Types.h"
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#include <string>
#include <algorithm>
#ifdef __linux__
#include <string.h>
#endif
namespace PdfWriter
{
......@@ -370,21 +383,21 @@ namespace PdfWriter
};
enum EFontType
{
fontUnknownType,
//----- Gr8BitFont
fontType1,
fontType1C,
fontType1COT,
fontType3,
fontTrueType,
fontTrueTypeOT,
//----- GrCIDFont
fontCIDType0,
fontCIDType0C,
fontCIDType0COT,
fontCIDType2,
fontUnknownType,
//----- Gr8BitFont
fontType1,
fontType1C,
fontType1COT,
fontType3,
fontTrueType,
fontTrueTypeOT,
//----- GrCIDFont
fontCIDType0,
fontCIDType0C,
fontCIDType0COT,
fontCIDType2,
fontCIDType2OT
};
}
#endif // _PDF_WRITER_SRC_TYPES_H
\ No newline at end of file
#endif // _PDF_WRITER_SRC_TYPES_H
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