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