Commit a66cd47c authored by Oleg Korshul's avatar Oleg Korshul

1) docbuilder : save to image support

2) docbuilder : add save params
3) IOfficeDrawingFile : set sizes for save to raster
parent 2c46ec31
......@@ -52,7 +52,7 @@ public:
virtual int GetPagesCount() = 0;
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) = 0;
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak) = 0;
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType) = 0;
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1) = 0;
};
#endif // _OFFICE_DRAWING_FILE_H
......@@ -50,9 +50,9 @@ namespace NSDoctRenderer
return m_pInternal->OpenFile(path, params);
}
bool CDocBuilder::SaveFile(const int& type, const wchar_t* path)
bool CDocBuilder::SaveFile(const int& type, const wchar_t* path, const wchar_t* params)
{
return m_pInternal->SaveFile(type, path);
return m_pInternal->SaveFile(type, path, params);
}
bool CDocBuilder::ExecuteCommand(const wchar_t* command)
{
......
......@@ -47,7 +47,7 @@ namespace NSDoctRenderer
bool OpenFile(const wchar_t* path, const wchar_t* params);
bool CreateFile(const int& type);
void SetTmpFolder(const wchar_t* folder);
bool SaveFile(const int& type, const wchar_t* path);
bool SaveFile(const int& type, const wchar_t* path, const wchar_t* params = 0);
void CloseFile();
bool ExecuteCommand(const wchar_t* command);
......
......@@ -898,7 +898,7 @@ namespace NSDoctRenderer
RELEASEOBJECT(m_pWorker);
}
bool SaveFile(const int& type, const std::wstring& path)
bool SaveFile(const int& type, const std::wstring& path, const wchar_t* params = NULL)
{
Init();
......@@ -950,6 +950,12 @@ namespace NSDoctRenderer
oBuilder.WriteString(std::to_wstring(nDoctRendererParam));
oBuilder.WriteString(L"</m_nDoctParams>");
if (NULL != params)
{
std::wstring sConvertionParams(params);
oBuilder.WriteString(sConvertionParams);
}
oBuilder.WriteString(L"</TaskQueueDataConvert>");
std::wstring sXmlConvert = oBuilder.GetData();
......@@ -1177,7 +1183,7 @@ namespace NSDoctRenderer
namespace NSDoctRenderer
{
void ParceParameters(const std::string& command, std::wstring* params)
void ParceParameters(const std::string& command, std::wstring* params, int& nCount)
{
const char* _commandsPtr = command.c_str();
size_t _commandsLen = command.length();
......@@ -1209,6 +1215,8 @@ namespace NSDoctRenderer
if (_currentPos >= _commandsLen)
break;
}
nCount = nIndex;
}
bool CDocBuilder::CreateFile(const int& type)
......@@ -1327,7 +1335,8 @@ namespace NSDoctRenderer
++_pos;
std::string sFuncNum(_data + 8, _pos - 8);
ParceParameters(command, _builder_params);
int nCountParameters = 0;
ParceParameters(command, _builder_params, nCountParameters);
if ("OpenFile" == sFuncNum)
bIsNoError = this->OpenFile(_builder_params[0].c_str(), _builder_params[1].c_str());
......@@ -1370,6 +1379,10 @@ namespace NSDoctRenderer
nFormat = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
else if (L"pdf" == _builder_params[0])
nFormat = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
else if (L"jpg" == _builder_params[0])
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_JPG;
else if (L"png" == _builder_params[0])
nFormat = AVS_OFFICESTUDIO_FILE_IMAGE_PNG;
if (m_pInternal->m_oParams.m_bSaveWithDoctrendererMode)
{
......@@ -1377,7 +1390,11 @@ namespace NSDoctRenderer
this->ExecuteCommand(L"_api.asc_Save();");
}
this->SaveFile(nFormat, _builder_params[1].c_str());
const wchar_t* sParams = NULL;
if (nCountParameters > 2)
sParams = _builder_params[2].c_str();
this->SaveFile(nFormat, _builder_params[1].c_str(), sParams);
}
}
else
......
......@@ -33,7 +33,7 @@
#define _BUILD_MEMORYSTREAM_H_
#include "../common/File.h"
#include "IRenderer.h"
#include "../graphics/IRenderer.h"
#ifdef _DEBUG
#define _LOGGING_NATIVE_
......
......@@ -83,10 +83,10 @@ void CDjVuFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* p
if (m_pImplementation)
m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak);
}
void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType)
void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW, const int& nRasterH)
{
if (m_pImplementation)
m_pImplementation->ConvertToRaster(nPageIndex, wsDstPath, nImageType);
m_pImplementation->ConvertToRaster(nPageIndex, wsDstPath, nImageType, nRasterW, nRasterH);
}
void CDjVuFile::ConvertToPdf(const std::wstring& wsDstPath)
{
......
......@@ -64,7 +64,7 @@ public:
virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
void ConvertToPdf(const std::wstring& path);
};
......@@ -207,7 +207,7 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRende
// белая страница
}
}
void CDjVuFileImplementation::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType)
void CDjVuFileImplementation::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW, const int& nRasterH)
{
if (!m_pApplicationFonts)
return;
......@@ -224,8 +224,8 @@ void CDjVuFileImplementation::ConvertToRaster(int nPageIndex, cons
double dWidth, dHeight;
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiX);
int nWidth = (int)dWidth * 96 / dPageDpiX;
int nHeight = (int)dHeight * 96 / dPageDpiX;
int nWidth = (nRasterW > 0) ? nRasterW : ((int)dWidth * 96 / dPageDpiX);
int nHeight = (nRasterH > 0) ? nRasterH : ((int)dHeight * 96 / dPageDpiX);
BYTE* pBgraData = new BYTE[nWidth * nHeight * 4];
if (!pBgraData)
......
......@@ -77,7 +77,7 @@ public:
int GetPagesCount() const;
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType);
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
void ConvertToPdf(const std::wstring& wsDstPath);
private:
......
......@@ -260,7 +260,7 @@ namespace PdfReader
m_pInternal->m_pPDFDocument->DisplayPage(&oRendererOut, nPageIndex, 72.0, 72.0, 0, false, true, false);
}
}
void CPdfReader::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType)
void CPdfReader::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW, const int& nRasterH)
{
CFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
CFontsCache* pFontCache = new CFontsCache();
......@@ -274,8 +274,8 @@ namespace PdfReader
double dDpiX, dDpiY;
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dDpiX, &dDpiY);
int nWidth = (int)dWidth * 72 / 25.4;
int nHeight = (int)dHeight * 72 / 25.4;
int nWidth = (nRasterW > 0) ? nRasterW : ((int)dWidth * 72 / 25.4);
int nHeight = (nRasterH > 0) ? nRasterH : ((int)dHeight * 72 / 25.4);
BYTE* pBgraData = new BYTE[nWidth * nHeight * 4];
if (!pBgraData)
......
......@@ -63,7 +63,7 @@ namespace PdfReader
virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
EError GetError();
double GetVersion();
......
......@@ -157,7 +157,7 @@ void CXpsFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pB
m_pInternal->m_pDocument->DrawPage(nPageIndex, pRenderer, pBreak);
}
void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType)
void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW, const int& nRasterH)
{
CFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
CFontsCache* pFontCache = new CFontsCache();
......@@ -171,8 +171,8 @@ void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, in
double dWidth, dHeight;
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
int nWidth = (int)dWidth * 96 / dPageDpiX;
int nHeight = (int)dHeight * 96 / dPageDpiX;
int nWidth = (nRasterW > 0) ? nRasterW : ((int)dWidth * 96 / dPageDpiX);
int nHeight = (nRasterH > 0) ? nRasterH : ((int)dHeight * 96 / dPageDpiX);
BYTE* pBgraData = new BYTE[nWidth * nHeight * 4];
if (!pBgraData)
......
......@@ -59,7 +59,7 @@ public:
virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
void ConvertToPdf(const std::wstring& wsDstPath);
......
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