mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
сделал общий интерфейс для открытия PdfReader, Djvu, Xps
This commit is contained in:
committed by
Alexander Trofimov
parent
7fa8727ed1
commit
1e35ce87cd
@ -1,64 +1,64 @@
|
||||
#include "DjVu.h"
|
||||
#include "DjVuFileImplementation.h"
|
||||
#include "../DesktopEditor/fontengine/ApplicationFonts.h"
|
||||
|
||||
class CApplicationFonts;
|
||||
|
||||
CDjVuFile::CDjVuFile()
|
||||
CDjVuFile::CDjVuFile(CApplicationFonts* pFonts)
|
||||
{
|
||||
m_pImplementation = new CDjVuFileImplementation();
|
||||
m_pImplementation = new CDjVuFileImplementation(pFonts);
|
||||
}
|
||||
CDjVuFile::~CDjVuFile()
|
||||
{
|
||||
if (m_pImplementation)
|
||||
delete m_pImplementation;
|
||||
}
|
||||
bool CDjVuFile::LoadFromFile(const std::wstring& wsSrcFileName, const std::wstring& wsXMLOptions)
|
||||
bool CDjVuFile::LoadFromFile(const std::wstring& file, const std::wstring& options,
|
||||
const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->LoadFromFile(wsSrcFileName, wsXMLOptions);
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->LoadFromFile(file, options);
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
void CDjVuFile::Close()
|
||||
|
||||
void CDjVuFile::Close()
|
||||
{
|
||||
if (m_pImplementation)
|
||||
m_pImplementation->Close();
|
||||
}
|
||||
std::wstring CDjVuFile::GetTempDirectory() const
|
||||
{
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->GetTempDirectory();
|
||||
|
||||
return L"";
|
||||
std::wstring CDjVuFile::GetTempDirectory()
|
||||
{
|
||||
return m_pImplementation ? m_pImplementation->GetTempDirectory() : L"";
|
||||
}
|
||||
void CDjVuFile::SetTempDirectory(const std::wstring& wsDirectory)
|
||||
void CDjVuFile::SetTempDirectory(const std::wstring& wsDirectory)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
m_pImplementation->SetTempDirectory(wsDirectory);
|
||||
}
|
||||
int CDjVuFile::GetPagesCount() const
|
||||
|
||||
int CDjVuFile::GetPagesCount()
|
||||
{
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->GetPagesCount();
|
||||
return 0;
|
||||
}
|
||||
void CDjVuFile::GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const
|
||||
void CDjVuFile::GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
m_pImplementation->GetPageInfo(nPageIndex, pdWidth, pdHeight, pdDpiX, pdDpiY);
|
||||
}
|
||||
void CDjVuFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak)
|
||||
void CDjVuFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak);
|
||||
}
|
||||
void CDjVuFile::ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType)
|
||||
void CDjVuFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
m_pImplementation->ConvertToRaster(pAppFonts, nPageIndex, wsDstPath, nImageType);
|
||||
m_pImplementation->ConvertToRaster(nPageIndex, wsDstPath, nImageType);
|
||||
}
|
||||
void CDjVuFile::ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath)
|
||||
void CDjVuFile::ConvertToPdf(const std::wstring& wsDstPath)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
m_pImplementation->ConvertToPdf(pAppFonts, wsDstPath);
|
||||
m_pImplementation->ConvertToPdf(wsDstPath);
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "../DesktopEditor/graphics/IRenderer.h"
|
||||
|
||||
#ifndef DJVU_USE_DYNAMIC_LIBRARY
|
||||
#define DJVU_DECL_EXPORT
|
||||
#else
|
||||
@ -10,28 +7,33 @@
|
||||
#define DJVU_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
// –аботаем через класс CDjVuFileImplementation, чтобы когда цепл¤лс¤ данный h-файл, ничего лишнего не инклюдилось
|
||||
class CDjVuFileImplementation;
|
||||
class CApplicationFonts;
|
||||
#include "../DesktopEditor/common/officedrawingfile.h"
|
||||
|
||||
class DJVU_DECL_EXPORT CDjVuFile
|
||||
// работаем через класс CDjVuFileImplementation, чтобы когда цеплялся данный h-файл, ничего лишнего не инклюдилось
|
||||
class CDjVuFileImplementation;
|
||||
|
||||
class DJVU_DECL_EXPORT CDjVuFile : public IOfficeDrawingFile
|
||||
{
|
||||
private:
|
||||
|
||||
CDjVuFileImplementation* m_pImplementation;
|
||||
|
||||
public:
|
||||
|
||||
CDjVuFile();
|
||||
~CDjVuFile();
|
||||
CDjVuFile(CApplicationFonts* fonts);
|
||||
virtual ~CDjVuFile();
|
||||
|
||||
bool LoadFromFile(const std::wstring& wsSrcFileName, const std::wstring& wsXmlOptions = L"");
|
||||
void Close();
|
||||
std::wstring GetTempDirectory() const;
|
||||
void SetTempDirectory(const std::wstring& wsDirectory);
|
||||
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(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType);
|
||||
void ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath);
|
||||
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
|
||||
|
||||
virtual void Close();
|
||||
|
||||
virtual std::wstring GetTempDirectory();
|
||||
virtual void SetTempDirectory(const std::wstring& directory);
|
||||
|
||||
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);
|
||||
|
||||
void ConvertToPdf(const std::wstring& path);
|
||||
};
|
||||
|
||||
@ -58,13 +58,15 @@ namespace NSDjvu
|
||||
}
|
||||
}
|
||||
|
||||
CDjVuFileImplementation::CDjVuFileImplementation()
|
||||
CDjVuFileImplementation::CDjVuFileImplementation(CApplicationFonts* pFonts)
|
||||
{
|
||||
m_pDoc = NULL;
|
||||
std::wstring wsTempPath = NSFile::CFileBinary::GetTempPath();
|
||||
wsTempPath += L"DJVU\\";
|
||||
m_wsTempDirectory = wsTempPath;
|
||||
NSDirectory::CreateDirectory(m_wsTempDirectory);
|
||||
|
||||
m_pApplicationFonts = pFonts;
|
||||
}
|
||||
CDjVuFileImplementation::~CDjVuFileImplementation()
|
||||
{
|
||||
@ -164,11 +166,14 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRende
|
||||
// белая страница
|
||||
}
|
||||
}
|
||||
void CDjVuFileImplementation::ConvertToRaster(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType)
|
||||
void CDjVuFileImplementation::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType)
|
||||
{
|
||||
CFontManager *pFontManager = pAppFonts->GenerateFontManager();
|
||||
if (!m_pApplicationFonts)
|
||||
return;
|
||||
|
||||
CFontManager *pFontManager = m_pApplicationFonts->GenerateFontManager();
|
||||
CFontsCache* pFontCache = new CFontsCache();
|
||||
pFontCache->SetStreams(pAppFonts->GetStreams());
|
||||
pFontCache->SetStreams(m_pApplicationFonts->GetStreams());
|
||||
pFontManager->SetOwnerCache(pFontCache);
|
||||
|
||||
CGraphicsRenderer oRenderer;
|
||||
@ -203,9 +208,9 @@ void CDjVuFileImplementation::ConvertToRaster(CApplicationFonts* p
|
||||
oFrame.SaveFile(wsDstPath, nImageType);
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
}
|
||||
void CDjVuFileImplementation::ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath)
|
||||
void CDjVuFileImplementation::ConvertToPdf(const std::wstring& wsDstPath)
|
||||
{
|
||||
CPdfRenderer oPdf(pAppFonts);
|
||||
CPdfRenderer oPdf(m_pApplicationFonts);
|
||||
|
||||
bool bBreak = false;
|
||||
for (int nPageIndex = 0, nPagesCount = GetPagesCount(); nPageIndex < nPagesCount; nPageIndex++)
|
||||
|
||||
@ -32,10 +32,11 @@ private:
|
||||
|
||||
std::wstring m_wsTempDirectory;
|
||||
GP<DjVuDocument> m_pDoc;
|
||||
CApplicationFonts* m_pApplicationFonts;
|
||||
|
||||
public:
|
||||
|
||||
CDjVuFileImplementation();
|
||||
CDjVuFileImplementation(CApplicationFonts* pFonts);
|
||||
~CDjVuFileImplementation();
|
||||
|
||||
bool LoadFromFile(const std::wstring& wsSrcFileName, const std::wstring& wsXmlOptions = L"");
|
||||
@ -45,8 +46,8 @@ 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(CApplicationFonts* pAppFonts, int nPageIndex, const std::wstring& wsDstPath, int nImageType);
|
||||
void ConvertToPdf(CApplicationFonts* pAppFonts, const std::wstring& wsDstPath);
|
||||
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType);
|
||||
void ConvertToPdf(const std::wstring& wsDstPath);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -18,72 +18,86 @@
|
||||
|
||||
namespace PdfReader
|
||||
{
|
||||
class CPdfReader_Private
|
||||
{
|
||||
public:
|
||||
PDFDoc* m_pPDFDocument;
|
||||
GlobalParams* m_pGlobalParams;
|
||||
std::wstring m_wsTempFolder;
|
||||
std::wstring m_wsCMapFolder;
|
||||
CApplicationFonts* m_pAppFonts;
|
||||
CFontManager* m_pFontManager;
|
||||
CFontList* m_pFontList;
|
||||
};
|
||||
|
||||
CPdfReader::CPdfReader(CApplicationFonts* pAppFonts)
|
||||
{
|
||||
m_wsTempFolder = NULL;
|
||||
m_wsCMapFolder = NULL;
|
||||
m_pInternal = new CPdfReader_Private();
|
||||
|
||||
m_pPDFDocument = NULL;
|
||||
m_pFontManager = NULL;
|
||||
m_pInternal->m_wsTempFolder = L"";
|
||||
m_pInternal->m_wsCMapFolder = L"";
|
||||
|
||||
m_pGlobalParams = new GlobalParams();
|
||||
m_pFontList = new CFontList();
|
||||
m_pInternal->m_pPDFDocument = NULL;
|
||||
m_pInternal->m_pFontManager = NULL;
|
||||
|
||||
m_pAppFonts = pAppFonts;
|
||||
m_pInternal->m_pGlobalParams = new GlobalParams();
|
||||
m_pInternal->m_pFontList = new CFontList();
|
||||
|
||||
m_pInternal->m_pAppFonts = pAppFonts;
|
||||
|
||||
// Создаем менеджер шрифтов с собственным кэшем
|
||||
m_pFontManager = pAppFonts->GenerateFontManager();
|
||||
m_pInternal->m_pFontManager = pAppFonts->GenerateFontManager();
|
||||
CFontsCache* pMeasurerCache = new CFontsCache();
|
||||
pMeasurerCache->SetStreams(pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
m_pInternal->m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
pMeasurerCache->SetCacheSize(1);
|
||||
m_pGlobalParams->SetFontManager(m_pFontManager);
|
||||
m_pInternal->m_pGlobalParams->SetFontManager(m_pInternal->m_pFontManager);
|
||||
}
|
||||
CPdfReader::~CPdfReader()
|
||||
{
|
||||
if (m_pFontList)
|
||||
if (m_pInternal->m_pFontList)
|
||||
{
|
||||
m_pFontList->Clear();
|
||||
delete m_pFontList;
|
||||
m_pInternal->m_pFontList->Clear();
|
||||
delete m_pInternal->m_pFontList;
|
||||
}
|
||||
|
||||
if (m_wsCMapFolder)
|
||||
FreeWString(m_wsCMapFolder);
|
||||
m_pInternal->m_wsCMapFolder = L"";
|
||||
|
||||
if (m_wsTempFolder)
|
||||
if (!m_pInternal->m_wsTempFolder.empty())
|
||||
{
|
||||
NSDirectory::DeleteDirectory(m_wsTempFolder);
|
||||
FreeWString(m_wsTempFolder);
|
||||
NSDirectory::DeleteDirectory(m_pInternal->m_wsTempFolder);
|
||||
m_pInternal->m_wsTempFolder = L"";
|
||||
}
|
||||
|
||||
RELEASEOBJECT(m_pPDFDocument);
|
||||
RELEASEOBJECT(m_pGlobalParams);
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
RELEASEOBJECT((m_pInternal->m_pPDFDocument));
|
||||
RELEASEOBJECT((m_pInternal->m_pGlobalParams));
|
||||
RELEASEINTERFACE((m_pInternal->m_pFontManager));
|
||||
}
|
||||
bool CPdfReader::LoadFromFile(const wchar_t* wsSrcPath, const wchar_t* wsOwnerPassword, const wchar_t* wsUserPassword, const wchar_t* wsOptions)
|
||||
bool CPdfReader::LoadFromFile(const std::wstring& wsSrcPath, const std::wstring& wsOptions,
|
||||
const std::wstring& wsOwnerPassword, const std::wstring& wsUserPassword)
|
||||
{
|
||||
// TODO: Сейчас при загрузке каждой новой картинки мы пересоздаем
|
||||
// FontManager, потому что сейчас в нем кэш без ограничения.
|
||||
//------------------------------------------------------
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
RELEASEINTERFACE((m_pInternal->m_pFontManager));
|
||||
m_pInternal->m_pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
||||
CFontsCache* pMeasurerCache = new CFontsCache();
|
||||
pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
pMeasurerCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
|
||||
m_pInternal->m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
pMeasurerCache->SetCacheSize(1);
|
||||
m_pGlobalParams->SetFontManager(m_pFontManager);
|
||||
m_pInternal->m_pGlobalParams->SetFontManager(m_pInternal->m_pFontManager);
|
||||
//------------------------------------------------------
|
||||
|
||||
if (m_pPDFDocument)
|
||||
delete m_pPDFDocument;
|
||||
if (m_pInternal->m_pPDFDocument)
|
||||
delete m_pInternal->m_pPDFDocument;
|
||||
|
||||
StringExt *seOwner = NULL, *seUser = NULL;
|
||||
if (NULL != wsOwnerPassword)
|
||||
seOwner = new StringExt(wsOwnerPassword);
|
||||
if (NULL != wsUserPassword)
|
||||
seUser = new StringExt(wsUserPassword);
|
||||
if (!wsOwnerPassword.empty())
|
||||
seOwner = new StringExt(wsOwnerPassword.c_str());
|
||||
if (!wsUserPassword.empty())
|
||||
seUser = new StringExt(wsUserPassword.c_str());
|
||||
|
||||
m_pPDFDocument = new PDFDoc(m_pGlobalParams, wsSrcPath, seOwner, seUser);
|
||||
m_pInternal->m_pPDFDocument = new PDFDoc(m_pInternal->m_pGlobalParams, wsSrcPath.c_str(), seOwner, seUser);
|
||||
|
||||
if (seUser)
|
||||
delete seUser;
|
||||
@ -91,78 +105,79 @@ namespace PdfReader
|
||||
if (seOwner)
|
||||
delete seOwner;
|
||||
|
||||
if (!m_pPDFDocument || !m_pPDFDocument->CheckValidation())
|
||||
if (!m_pInternal->m_pPDFDocument || !m_pInternal->m_pPDFDocument->CheckValidation())
|
||||
{
|
||||
RELEASEOBJECT(m_pPDFDocument);
|
||||
RELEASEOBJECT(m_pInternal->m_pPDFDocument);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pFontList->Clear();
|
||||
m_pInternal->m_pFontList->Clear();
|
||||
|
||||
return (errorNone == m_pPDFDocument->GetErrorCode());
|
||||
return (errorNone == m_pInternal->m_pPDFDocument->GetErrorCode());
|
||||
}
|
||||
void CPdfReader::Close()
|
||||
void CPdfReader::Close()
|
||||
{
|
||||
RELEASEOBJECT(m_pPDFDocument);
|
||||
RELEASEOBJECT((m_pInternal->m_pPDFDocument));
|
||||
}
|
||||
EError CPdfReader::GetError()
|
||||
EError CPdfReader::GetError()
|
||||
{
|
||||
if (!m_pPDFDocument)
|
||||
if (!m_pInternal->m_pPDFDocument)
|
||||
return errorOpenFile;
|
||||
|
||||
return m_pPDFDocument->GetErrorCode();
|
||||
return m_pInternal->m_pPDFDocument->GetErrorCode();
|
||||
}
|
||||
int CPdfReader::GetPagesCount()
|
||||
int CPdfReader::GetPagesCount()
|
||||
{
|
||||
if (!m_pPDFDocument)
|
||||
if (!m_pInternal->m_pPDFDocument)
|
||||
return 0;
|
||||
|
||||
return m_pPDFDocument->GetPagesCount();
|
||||
return m_pInternal->m_pPDFDocument->GetPagesCount();
|
||||
}
|
||||
double CPdfReader::GetVersion()
|
||||
double CPdfReader::GetVersion()
|
||||
{
|
||||
if (!m_pPDFDocument)
|
||||
if (!m_pInternal->m_pPDFDocument)
|
||||
return 0;
|
||||
|
||||
return m_pPDFDocument->GetPDFVersion();
|
||||
return m_pInternal->m_pPDFDocument->GetPDFVersion();
|
||||
}
|
||||
int CPdfReader::GetPermissions()
|
||||
int CPdfReader::GetPermissions()
|
||||
{
|
||||
if (!m_pPDFDocument)
|
||||
if (!m_pInternal->m_pPDFDocument)
|
||||
return 0;
|
||||
|
||||
int nPermissions = 0;
|
||||
|
||||
if (m_pPDFDocument->CheckPrint())
|
||||
if (m_pInternal->m_pPDFDocument->CheckPrint())
|
||||
nPermissions += PERMISSION_PRINT;
|
||||
if (m_pPDFDocument->CheckCopy())
|
||||
if (m_pInternal->m_pPDFDocument->CheckCopy())
|
||||
nPermissions += PERMISSION_COPY;
|
||||
if (m_pPDFDocument->CheckChange())
|
||||
if (m_pInternal->m_pPDFDocument->CheckChange())
|
||||
nPermissions += PERMISSION_CHANGE;
|
||||
|
||||
return nPermissions;
|
||||
}
|
||||
bool CPdfReader::ExtractAllImages(const wchar_t* wsDstPath, const wchar_t* wsPrefix)
|
||||
bool CPdfReader::ExtractAllImages(const wchar_t* wsDstPath, const wchar_t* wsPrefix)
|
||||
{
|
||||
StringExt seString(wsDstPath);
|
||||
ExtractImageOutputDev *pOutputDev = new ExtractImageOutputDev(m_pGlobalParams, seString.GetBuffer(), true);
|
||||
ExtractImageOutputDev *pOutputDev = new ExtractImageOutputDev(m_pInternal->m_pGlobalParams, seString.GetBuffer(), true);
|
||||
if (!pOutputDev)
|
||||
return false;
|
||||
|
||||
for (int nIndex = 1; nIndex <= m_pPDFDocument->GetPagesCount(); nIndex++)
|
||||
int nPagesCount = GetPagesCount();
|
||||
for (int nIndex = 1; nIndex <= nPagesCount; nIndex++)
|
||||
{
|
||||
m_pPDFDocument->DisplayPage(pOutputDev, nIndex, 72, 72, 0, false, false, false);
|
||||
m_pInternal->m_pPDFDocument->DisplayPage(pOutputDev, nIndex, 72, 72, 0, false, false, false);
|
||||
}
|
||||
|
||||
delete pOutputDev;
|
||||
|
||||
return true;
|
||||
}
|
||||
void CPdfReader::GetPageSize(int _nPageIndex, double* pdWidth, double* pdHeight)
|
||||
void CPdfReader::GetPageInfo(int _nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY)
|
||||
{
|
||||
int nPageIndex = _nPageIndex + 1;
|
||||
|
||||
if (!m_pPDFDocument)
|
||||
if (!m_pInternal->m_pPDFDocument)
|
||||
return;
|
||||
|
||||
const double c_dInch = 25.399; // Миллиметров в дюйме
|
||||
@ -172,7 +187,7 @@ namespace PdfReader
|
||||
double dKoefX = c_dInch / c_dXResolution;
|
||||
double dKoefY = c_dInch / c_dYResolution;
|
||||
|
||||
int nRotate = m_pPDFDocument->GetPageRotate(nPageIndex);
|
||||
int nRotate = m_pInternal->m_pPDFDocument->GetPageRotate(nPageIndex);
|
||||
|
||||
while (nRotate >= 360)
|
||||
nRotate -= 360;
|
||||
@ -182,75 +197,43 @@ namespace PdfReader
|
||||
|
||||
if (0 != nRotate && 180 != nRotate)
|
||||
{
|
||||
*pdHeight = PDFCoordsToMM(m_pPDFDocument->GetPageCropWidth(nPageIndex));
|
||||
*pdWidth = PDFCoordsToMM(m_pPDFDocument->GetPageCropHeight(nPageIndex));
|
||||
*pdHeight = m_pInternal->m_pPDFDocument->GetPageCropWidth(nPageIndex);
|
||||
*pdWidth = m_pInternal->m_pPDFDocument->GetPageCropHeight(nPageIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
*pdWidth = PDFCoordsToMM(m_pPDFDocument->GetPageCropWidth(nPageIndex));
|
||||
*pdHeight = PDFCoordsToMM(m_pPDFDocument->GetPageCropHeight(nPageIndex));
|
||||
}
|
||||
}
|
||||
void CPdfReader::GetPageInfo(int _nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY)
|
||||
{
|
||||
int nPageIndex = _nPageIndex + 1;
|
||||
|
||||
if (!m_pPDFDocument)
|
||||
return;
|
||||
|
||||
const double c_dInch = 25.399; // Миллиметров в дюйме
|
||||
const double c_dXResolution = 154.0;
|
||||
const double c_dYResolution = 154.0;
|
||||
|
||||
double dKoefX = c_dInch / c_dXResolution;
|
||||
double dKoefY = c_dInch / c_dYResolution;
|
||||
|
||||
int nRotate = m_pPDFDocument->GetPageRotate(nPageIndex);
|
||||
|
||||
while (nRotate >= 360)
|
||||
nRotate -= 360;
|
||||
|
||||
while (nRotate < 0)
|
||||
nRotate += 360;
|
||||
|
||||
if (0 != nRotate && 180 != nRotate)
|
||||
{
|
||||
*pdHeight = m_pPDFDocument->GetPageCropWidth(nPageIndex);
|
||||
*pdWidth = m_pPDFDocument->GetPageCropHeight(nPageIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
*pdWidth = m_pPDFDocument->GetPageCropWidth(nPageIndex);
|
||||
*pdHeight = m_pPDFDocument->GetPageCropHeight(nPageIndex);
|
||||
*pdWidth = m_pInternal->m_pPDFDocument->GetPageCropWidth(nPageIndex);
|
||||
*pdHeight = m_pInternal->m_pPDFDocument->GetPageCropHeight(nPageIndex);
|
||||
}
|
||||
|
||||
*pdDpiX = 72;
|
||||
*pdDpiY = 72;
|
||||
}
|
||||
void CPdfReader::DrawPageOnRenderer(IRenderer* pRenderer, int _nPageIndex, bool* pbBreak)
|
||||
void CPdfReader::DrawPageOnRenderer(IRenderer* pRenderer, int _nPageIndex, bool* pbBreak)
|
||||
{
|
||||
int nPageIndex = _nPageIndex + 1;
|
||||
|
||||
if (m_pPDFDocument && pRenderer)
|
||||
if (m_pInternal->m_pPDFDocument && pRenderer)
|
||||
{
|
||||
RendererOutputDev oRendererOut(m_pGlobalParams, pRenderer, m_pFontManager, m_pFontList);
|
||||
oRendererOut.NewPDF(m_pPDFDocument->GetXRef());
|
||||
RendererOutputDev oRendererOut(m_pInternal->m_pGlobalParams, pRenderer, m_pInternal->m_pFontManager, m_pInternal->m_pFontList);
|
||||
oRendererOut.NewPDF(m_pInternal->m_pPDFDocument->GetXRef());
|
||||
oRendererOut.SetBreak(pbBreak);
|
||||
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 wchar_t* wsDstPath, int nImageType)
|
||||
void CPdfReader::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType)
|
||||
{
|
||||
CFontManager *pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
CFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
||||
CFontsCache* pFontCache = new CFontsCache();
|
||||
pFontCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
pFontCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
|
||||
pFontManager->SetOwnerCache(pFontCache);
|
||||
|
||||
CGraphicsRenderer oRenderer;
|
||||
oRenderer.SetFontManager(pFontManager);
|
||||
|
||||
double dWidth, dHeight;
|
||||
GetPageSize(nPageIndex, &dWidth, &dHeight);
|
||||
double dDpiX, dDpiY;
|
||||
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dDpiX, &dDpiY);
|
||||
|
||||
int nWidth = (int)dWidth * 72 / 25.4;
|
||||
int nHeight = (int)dHeight * 72 / 25.4;
|
||||
@ -277,28 +260,28 @@ namespace PdfReader
|
||||
oFrame.SaveFile(wsDstPath, nImageType);
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
}
|
||||
int CPdfReader::GetImagesCount()
|
||||
int CPdfReader::GetImagesCount()
|
||||
{
|
||||
ExtractImageOutputDev *pOutputDev = new ExtractImageOutputDev(m_pGlobalParams, NULL, true, true);
|
||||
ExtractImageOutputDev *pOutputDev = new ExtractImageOutputDev(m_pInternal->m_pGlobalParams, NULL, true, true);
|
||||
if (!pOutputDev)
|
||||
return 0;
|
||||
|
||||
for (int nIndex = 1; nIndex <= m_pPDFDocument->GetPagesCount(); nIndex++)
|
||||
for (int nIndex = 1; nIndex <= m_pInternal->m_pPDFDocument->GetPagesCount(); nIndex++)
|
||||
{
|
||||
m_pPDFDocument->DisplayPage(pOutputDev, nIndex, 72, 72, 0, false, false, false);
|
||||
m_pInternal->m_pPDFDocument->DisplayPage(pOutputDev, nIndex, 72, 72, 0, false, false, false);
|
||||
}
|
||||
|
||||
return pOutputDev->GetImagesCount();
|
||||
}
|
||||
void CPdfReader::SetTempFolder(const wchar_t* wsTempFolder)
|
||||
void CPdfReader::SetTempDirectory(const std::wstring& wsTempFolder)
|
||||
{
|
||||
if (m_wsTempFolder)
|
||||
if (!m_pInternal->m_wsTempFolder.empty())
|
||||
{
|
||||
NSDirectory::DeleteDirectory(m_wsTempFolder);
|
||||
FreeWString(m_wsTempFolder);
|
||||
NSDirectory::DeleteDirectory(m_pInternal->m_wsTempFolder);
|
||||
m_pInternal->m_wsTempFolder = wsTempFolder;
|
||||
}
|
||||
|
||||
if (NULL != wsTempFolder)
|
||||
if (!wsTempFolder.empty())
|
||||
{
|
||||
std::wstring wsFolderName = std::wstring(wsTempFolder) + L"//pdftemp";
|
||||
std::wstring wsFolder = wsFolderName;
|
||||
@ -309,30 +292,28 @@ namespace PdfReader
|
||||
wsFolder = wsFolderName + L"_" + std::to_wstring(nCounter);
|
||||
}
|
||||
NSDirectory::CreateDirectory(wsFolder);
|
||||
m_wsTempFolder = AllocWString(wsFolder);
|
||||
m_pInternal->m_wsTempFolder = wsFolder;
|
||||
}
|
||||
else
|
||||
m_wsTempFolder = NULL;
|
||||
m_pInternal->m_wsTempFolder = L"";
|
||||
|
||||
if (m_pGlobalParams)
|
||||
m_pGlobalParams->SetTempFolder(m_wsTempFolder);
|
||||
if (m_pInternal->m_pGlobalParams)
|
||||
m_pInternal->m_pGlobalParams->SetTempFolder(m_pInternal->m_wsTempFolder.c_str());
|
||||
}
|
||||
void CPdfReader::SetCMapFolder(const wchar_t* wsCMapFolder)
|
||||
std::wstring CPdfReader::GetTempDirectory()
|
||||
{
|
||||
return m_pInternal->m_wsTempFolder;
|
||||
}
|
||||
|
||||
void CPdfReader::SetCMapFolder(const wchar_t* wsCMapFolder)
|
||||
{
|
||||
if (m_wsCMapFolder)
|
||||
FreeWString(m_wsCMapFolder);
|
||||
m_pInternal->m_wsCMapFolder = std::wstring(wsCMapFolder);
|
||||
|
||||
if (NULL != wsCMapFolder)
|
||||
m_wsCMapFolder = AllocWString(wsCMapFolder);
|
||||
else
|
||||
m_wsCMapFolder = NULL;
|
||||
|
||||
|
||||
if (m_pGlobalParams)
|
||||
m_pGlobalParams->SetCMapFolder(m_wsCMapFolder);
|
||||
if (m_pInternal->m_pGlobalParams)
|
||||
m_pInternal->m_pGlobalParams->SetCMapFolder(m_pInternal->m_wsCMapFolder.c_str());
|
||||
}
|
||||
CFontManager*CPdfReader::GetFontManager()
|
||||
CFontManager* CPdfReader::GetFontManager()
|
||||
{
|
||||
return m_pFontManager;
|
||||
return m_pInternal->m_pFontManager;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
#ifndef _PDF_READER_H
|
||||
#define _PDF_READER_H
|
||||
|
||||
#include "Src/ErrorConstants.h"
|
||||
|
||||
class IRenderer;
|
||||
class CFontManager;
|
||||
class CApplicationFonts;
|
||||
|
||||
#ifndef PDFREADER_USE_DYNAMIC_LIBRARY
|
||||
#define PDFREADER_DECL_EXPORT
|
||||
#else
|
||||
@ -14,48 +8,44 @@ class CApplicationFonts;
|
||||
#define PDFREADER_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
#include "Src/ErrorConstants.h"
|
||||
#include "../DesktopEditor/common/officedrawingfile.h"
|
||||
|
||||
namespace PdfReader
|
||||
{
|
||||
class PDFDoc;
|
||||
class GlobalParams;
|
||||
class CFontList;
|
||||
|
||||
class CPdfReader_Private;
|
||||
class PDFREADER_DECL_EXPORT CPdfReader
|
||||
{
|
||||
public:
|
||||
|
||||
CPdfReader(CApplicationFonts* pAppFonts);
|
||||
CPdfReader(CApplicationFonts* fonts);
|
||||
~CPdfReader();
|
||||
|
||||
bool LoadFromFile(const wchar_t* wsSrcPath, const wchar_t* wsOwnerPassword = 0, const wchar_t* wsUserPassword = 0, const wchar_t* wsOptions = 0);
|
||||
void Close();
|
||||
|
||||
EError GetError();
|
||||
double GetVersion();
|
||||
int GetPermissions();
|
||||
|
||||
int GetPagesCount();
|
||||
void GetPageSize(int nPageIndex, double* pdWidth, double* pdHeight);
|
||||
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
||||
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pbBreak);
|
||||
void ConvertToRaster(int nPageIndex, const wchar_t* wsDstPath, int nImageType);
|
||||
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
|
||||
|
||||
bool ExtractAllImages(const wchar_t* wsDstPath, const wchar_t* wsPrefix = 0);
|
||||
virtual void Close();
|
||||
|
||||
virtual std::wstring GetTempDirectory();
|
||||
virtual void SetTempDirectory(const std::wstring& directory);
|
||||
|
||||
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);
|
||||
|
||||
EError GetError();
|
||||
double GetVersion();
|
||||
int GetPermissions();
|
||||
|
||||
bool ExtractAllImages(const wchar_t* wsDstPath, const wchar_t* wsPrefix = 0);
|
||||
int GetImagesCount();
|
||||
|
||||
void SetTempFolder(const wchar_t* wsTempFolder);
|
||||
void SetCMapFolder(const wchar_t* wsCMapFolder);
|
||||
void SetCMapFolder(const wchar_t* wsCMapFolder);
|
||||
CFontManager*GetFontManager();
|
||||
|
||||
private:
|
||||
|
||||
PDFDoc* m_pPDFDocument;
|
||||
GlobalParams* m_pGlobalParams;
|
||||
wchar_t* m_wsTempFolder;
|
||||
wchar_t* m_wsCMapFolder;
|
||||
CApplicationFonts* m_pAppFonts;
|
||||
CFontManager* m_pFontManager;
|
||||
CFontList* m_pFontList;
|
||||
CPdfReader_Private* m_pInternal;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -12,106 +12,125 @@
|
||||
|
||||
using namespace XPS;
|
||||
|
||||
class CXpsFile_Private
|
||||
{
|
||||
public:
|
||||
CApplicationFonts* m_pAppFonts;
|
||||
CFontManager* m_pFontManager;
|
||||
std::wstring m_wsTempFolder;
|
||||
XPS::CDocument* m_pDocument;
|
||||
|
||||
public:
|
||||
CXpsFile_Private(CApplicationFonts* pAppFonts)
|
||||
{
|
||||
m_pDocument = NULL;
|
||||
|
||||
m_pAppFonts = pAppFonts;
|
||||
|
||||
// Создаем менеджер шрифтов с собственным кэшем
|
||||
m_pFontManager = pAppFonts->GenerateFontManager();
|
||||
CFontsCache* pMeasurerCache = new CFontsCache();
|
||||
pMeasurerCache->SetStreams(pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
pMeasurerCache->SetCacheSize(16);
|
||||
|
||||
m_wsTempFolder = L"";
|
||||
}
|
||||
~CXpsFile_Private()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
CXpsFile::CXpsFile(CApplicationFonts* pAppFonts)
|
||||
{
|
||||
m_pDocument = NULL;
|
||||
|
||||
m_pAppFonts = pAppFonts;
|
||||
|
||||
// Создаем менеджер шрифтов с собственным кэшем
|
||||
m_pFontManager = pAppFonts->GenerateFontManager();
|
||||
CFontsCache* pMeasurerCache = new CFontsCache();
|
||||
pMeasurerCache->SetStreams(pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
pMeasurerCache->SetCacheSize(16);
|
||||
|
||||
m_wsTempFolder = L"";
|
||||
SetTempFolder(NSFile::CFileBinary::GetTempPath());
|
||||
m_pInternal = new CXpsFile_Private(pAppFonts);
|
||||
SetTempDirectory(NSFile::CFileBinary::GetTempPath());
|
||||
}
|
||||
CXpsFile::~CXpsFile()
|
||||
{
|
||||
if (L"" != m_wsTempFolder)
|
||||
NSDirectory::DeleteDirectory(m_wsTempFolder);
|
||||
if (L"" != m_pInternal->m_wsTempFolder)
|
||||
NSDirectory::DeleteDirectory(m_pInternal->m_wsTempFolder);
|
||||
|
||||
Close();
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
RELEASEINTERFACE((m_pInternal->m_pFontManager));
|
||||
}
|
||||
std::wstring CXpsFile::GetTempFolder() const
|
||||
std::wstring CXpsFile::GetTempDirectory()
|
||||
{
|
||||
return m_wsTempFolder;
|
||||
return m_pInternal->m_wsTempFolder;
|
||||
}
|
||||
void CXpsFile::SetTempFolder(const std::wstring& wsPath)
|
||||
void CXpsFile::SetTempDirectory(const std::wstring& wsPath)
|
||||
{
|
||||
if (L"" != m_wsTempFolder)
|
||||
NSDirectory::DeleteDirectory(m_wsTempFolder);
|
||||
if (L"" != m_pInternal->m_wsTempFolder)
|
||||
NSDirectory::DeleteDirectory(m_pInternal->m_wsTempFolder);
|
||||
|
||||
int nCounter = 0;
|
||||
m_wsTempFolder = wsPath + L"/XPS/";
|
||||
while (NSDirectory::Exists(m_wsTempFolder))
|
||||
m_pInternal->m_wsTempFolder = wsPath + L"/XPS/";
|
||||
while (NSDirectory::Exists(m_pInternal->m_wsTempFolder))
|
||||
{
|
||||
m_wsTempFolder = wsPath + L"/XPS" + std::to_wstring(nCounter) + L"/";
|
||||
m_pInternal->m_wsTempFolder = wsPath + L"/XPS" + std::to_wstring(nCounter) + L"/";
|
||||
nCounter++;
|
||||
}
|
||||
NSDirectory::CreateDirectory(m_wsTempFolder);
|
||||
NSDirectory::CreateDirectory(m_pInternal->m_wsTempFolder);
|
||||
}
|
||||
bool CXpsFile::LoadFromFile(const std::wstring& wsSrcFileName, const std::wstring& wsXmlOptions)
|
||||
bool CXpsFile::LoadFromFile(const std::wstring& wsSrcFileName, const std::wstring& wsXmlOptions,
|
||||
const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
Close();
|
||||
|
||||
// Распаковываем Zip-архив в темповую папку
|
||||
COfficeUtils oUtils(NULL);
|
||||
if (S_OK != oUtils.ExtractToDirectory(wsSrcFileName, m_wsTempFolder, NULL, 0))
|
||||
if (S_OK != oUtils.ExtractToDirectory(wsSrcFileName, m_pInternal->m_wsTempFolder, NULL, 0))
|
||||
return false;
|
||||
|
||||
m_pDocument = new XPS::CDocument(m_pFontManager);
|
||||
if (!m_pDocument)
|
||||
m_pInternal->m_pDocument = new XPS::CDocument(m_pInternal->m_pFontManager);
|
||||
if (!m_pInternal->m_pDocument)
|
||||
return false;
|
||||
|
||||
std::wstring wsPath = m_wsTempFolder + L"/";
|
||||
m_pDocument->ReadFromPath(wsPath);
|
||||
std::wstring wsPath = m_pInternal->m_wsTempFolder + L"/";
|
||||
m_pInternal->m_pDocument->ReadFromPath(wsPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
void CXpsFile::Close()
|
||||
void CXpsFile::Close()
|
||||
{
|
||||
if (m_pDocument)
|
||||
if (m_pInternal->m_pDocument)
|
||||
{
|
||||
m_pDocument->Close();
|
||||
delete m_pDocument;
|
||||
m_pDocument = NULL;
|
||||
m_pInternal->m_pDocument->Close();
|
||||
delete m_pInternal->m_pDocument;
|
||||
m_pInternal->m_pDocument = NULL;
|
||||
}
|
||||
}
|
||||
int CXpsFile::GetPagesCount()
|
||||
int CXpsFile::GetPagesCount()
|
||||
{
|
||||
if (!m_pDocument)
|
||||
if (!m_pInternal->m_pDocument)
|
||||
return 0;
|
||||
|
||||
return m_pDocument->GetPageCount();
|
||||
return m_pInternal->m_pDocument->GetPageCount();
|
||||
}
|
||||
void CXpsFile::GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY)
|
||||
void CXpsFile::GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY)
|
||||
{
|
||||
int nW = 0, nH = 0;
|
||||
|
||||
if (m_pDocument)
|
||||
m_pDocument->GetPageSize(nPageIndex, nW, nH);
|
||||
if (m_pInternal->m_pDocument)
|
||||
m_pInternal->m_pDocument->GetPageSize(nPageIndex, nW, nH);
|
||||
|
||||
*pdWidth = nW * 25.4 / 96;
|
||||
*pdHeight = nH * 25.4 / 96;
|
||||
*pdDpiX = 25.4;
|
||||
*pdDpiY = 25.4;
|
||||
}
|
||||
void CXpsFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak)
|
||||
void CXpsFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak)
|
||||
{
|
||||
if (!m_pDocument)
|
||||
if (!m_pInternal->m_pDocument)
|
||||
return;
|
||||
|
||||
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)
|
||||
{
|
||||
CFontManager *pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
CFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
||||
CFontsCache* pFontCache = new CFontsCache();
|
||||
pFontCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
pFontCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
|
||||
pFontManager->SetOwnerCache(pFontCache);
|
||||
|
||||
CGraphicsRenderer oRenderer;
|
||||
@ -146,9 +165,9 @@ void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDst
|
||||
oFrame.SaveFile(wsDstPath, nImageType);
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
}
|
||||
void CXpsFile::ConvertToPdf(const std::wstring& wsPath)
|
||||
void CXpsFile::ConvertToPdf(const std::wstring& wsPath)
|
||||
{
|
||||
CPdfRenderer oPdf(m_pAppFonts);
|
||||
CPdfRenderer oPdf(m_pInternal->m_pAppFonts);
|
||||
bool bBreak = false;
|
||||
|
||||
int nPagesCount = GetPagesCount();
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
#ifndef _XPS_FILE_H
|
||||
#define _XPS_FILE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef XPS_USE_DYNAMIC_LIBRARY
|
||||
#define XPS_DECL_EXPORT
|
||||
#else
|
||||
@ -10,37 +8,32 @@
|
||||
#define XPS_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace XPS
|
||||
{
|
||||
class CDocument;
|
||||
}
|
||||
|
||||
class IRenderer;
|
||||
class CApplicationFonts;
|
||||
class CFontManager;
|
||||
#include "../DesktopEditor/common/officedrawingfile.h"
|
||||
|
||||
class CXpsFile_Private;
|
||||
class XPS_DECL_EXPORT CXpsFile
|
||||
{
|
||||
public:
|
||||
CXpsFile(CApplicationFonts* pAppFonts);
|
||||
~CXpsFile();
|
||||
CXpsFile(CApplicationFonts* fonts);
|
||||
virtual ~CXpsFile();
|
||||
|
||||
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
|
||||
|
||||
virtual void Close();
|
||||
|
||||
virtual std::wstring GetTempDirectory();
|
||||
virtual void SetTempDirectory(const std::wstring& directory);
|
||||
|
||||
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);
|
||||
|
||||
bool LoadFromFile(const std::wstring& wsSrcFileName, const std::wstring& wsXmlOptions = L"");
|
||||
void Close();
|
||||
std::wstring GetTempFolder() const;
|
||||
void SetTempFolder(const std::wstring& wsPath);
|
||||
int GetPagesCount();
|
||||
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
|
||||
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
||||
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType);
|
||||
void ConvertToPdf(const std::wstring& wsDstPath);
|
||||
|
||||
private:
|
||||
|
||||
CApplicationFonts* m_pAppFonts;
|
||||
CFontManager* m_pFontManager;
|
||||
std::wstring m_wsTempFolder;
|
||||
XPS::CDocument* m_pDocument;
|
||||
CXpsFile_Private* m_pInternal;
|
||||
};
|
||||
|
||||
#endif // _XPS_FILE_H
|
||||
|
||||
Reference in New Issue
Block a user