Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
1e35ce87
Commit
1e35ce87
authored
Apr 20, 2016
by
Oleg Korshul
Committed by
Alexander Trofimov
May 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
сделал общий интерфейс для открытия PdfReader, Djvu, Xps
parent
7fa8727e
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
285 additions
and
294 deletions
+285
-294
DjVuFile/DjVu.cpp
DjVuFile/DjVu.cpp
+22
-22
DjVuFile/DjVu.h
DjVuFile/DjVu.h
+21
-19
DjVuFile/DjVuFileImplementation.cpp
DjVuFile/DjVuFileImplementation.cpp
+11
-6
DjVuFile/DjVuFileImplementation.h
DjVuFile/DjVuFileImplementation.h
+4
-3
PdfReader/PdfReader.cpp
PdfReader/PdfReader.cpp
+114
-133
PdfReader/PdfReader.h
PdfReader/PdfReader.h
+25
-35
XpsFile/XpsFile.cpp
XpsFile/XpsFile.cpp
+69
-50
XpsFile/XpsFile.h
XpsFile/XpsFile.h
+19
-26
No files found.
DjVuFile/DjVu.cpp
View file @
1e35ce87
#
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
,
wsXMLO
ptions
);
if
(
m_pImplementation
)
return
m_pImplementation
->
LoadFromFile
(
file
,
o
ptions
);
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
);
}
DjVuFile/DjVu.h
View file @
1e35ce87
#
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-файл, ничего лишнего не инклюдилось
#include "../DesktopEditor/common/officedrawingfile.h"
// работаем через класс CDjVuFileImplementation, чтобы когда цеплялся данный h-файл, ничего лишнего не инклюдилось
class
CDjVuFileImplementation
;
class
CApplicationFonts
;
class
DJVU_DECL_EXPORT
CDjVuFile
class
DJVU_DECL_EXPORT
CDjVuFile
:
public
IOfficeDrawingFile
{
private:
CDjVuFileImplementation
*
m_pImplementation
;
public:
CDjVuFile
();
~
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
);
CDjVuFile
(
CApplicationFonts
*
fonts
);
virtual
~
CDjVuFile
();
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
);
};
DjVuFile/DjVuFileImplementation.cpp
View file @
1e35ce87
...
...
@@ -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
(
pApp
Fonts
->
GetStreams
());
pFontCache
->
SetStreams
(
m_pApplication
Fonts
->
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
(
pApp
Fonts
);
CPdfRenderer
oPdf
(
m_pApplication
Fonts
);
bool
bBreak
=
false
;
for
(
int
nPageIndex
=
0
,
nPagesCount
=
GetPagesCount
();
nPageIndex
<
nPagesCount
;
nPageIndex
++
)
...
...
DjVuFile/DjVuFileImplementation.h
View file @
1e35ce87
...
...
@@ -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:
...
...
PdfReader/PdfReader.cpp
View file @
1e35ce87
This diff is collapsed.
Click to expand it.
PdfReader/PdfReader.h
View file @
1e35ce87
#
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
*
pAppF
onts
);
CPdfReader
(
CApplicationFonts
*
f
onts
);
~
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
);
bool
ExtractAllImages
(
const
wchar_t
*
wsDstPath
,
const
wchar_t
*
wsPrefix
=
0
);
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
);
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
;
};
}
...
...
XpsFile/XpsFile.cpp
View file @
1e35ce87
...
...
@@ -12,106 +12,125 @@
using
namespace
XPS
;
CXpsFile
::
CXpsFile
(
CApplicationFonts
*
pAppFonts
)
class
CXpsFile_Private
{
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
);
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
()
{
}
};
m_wsTempFolder
=
L""
;
SetTempFolder
(
NSFile
::
CFileBinary
::
GetTempPath
());
CXpsFile
::
CXpsFile
(
CApplicationFonts
*
pAppFonts
)
{
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
::
GetTemp
Folder
()
const
std
::
wstring
CXpsFile
::
GetTemp
Directory
()
{
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
();
...
...
XpsFile/XpsFile.h
View file @
1e35ce87
#
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
();
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
);
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
);
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment