Compare commits

..

20 Commits

Author SHA1 Message Date
4ca1ea0595 Fix build 2022-03-14 10:35:34 +03:00
5b4d1d0bae Merge pull request #871 from ONLYOFFICE/fix/drawingfile-info
fix drawingfile info
2022-03-13 09:29:02 +03:00
ac94da49fd fix replace_all to NSStringExt::Replace 2022-03-11 20:35:09 +03:00
6ac102569e fix xps 2022-03-11 20:09:05 +03:00
8bb58c35cb fix quotes 2022-03-11 18:29:47 +03:00
1137a38594 Fix bug 55845 2022-03-11 17:42:55 +03:00
1ef9329036 Merge pull request #869 from ONLYOFFICE/fix/drawingfile-info
Fix/drawingfile info
2022-03-11 16:59:32 +03:00
c8b91b8e61 Merge pull request #870 from ONLYOFFICE/fix/v7.1.0-fix-bugs2
Fix/v7.1.0 fix bugs2
2022-03-11 15:39:15 +03:00
c23a0ee4a8 fix bug #55940 2022-03-11 15:38:06 +03:00
a90b578e9c Fix bug 55987 2022-03-11 14:48:27 +03:00
328395dfea fix GetInfo 2022-03-11 12:32:46 +03:00
a18d19b6f7 optimize 2022-03-10 17:55:58 +03:00
8ef62fd670 djvu GetInfo 2022-03-10 17:40:05 +03:00
0852fc134e xps GetInfo 2022-03-10 15:16:54 +03:00
22b00f4354 for bug #55803 2022-03-10 11:48:00 +03:00
5b3860103e fix bug #55894 2022-03-10 11:20:34 +03:00
2604226810 pdf GetInfo 2022-03-10 11:12:11 +03:00
6c25c52a50 create GetInfo 2022-03-09 19:01:22 +03:00
c4a767e038 Merge pull request #867 from ONLYOFFICE/fix/v7.1.0-fix-bugs2
fix bug #55919
2022-03-09 16:15:21 +03:00
fa40db9ce2 fix bug #55919 2022-03-09 16:14:14 +03:00
22 changed files with 372 additions and 79 deletions

View File

@ -1452,6 +1452,11 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
convert(dynamic_cast<SimpleTypes::CUniversalMeasure *>(oox_paragraph_pr->m_oSpacing->m_oLine.GetPointer()), length_);
paragraph_properties->content_.fo_line_height_ = odf_types::line_width(*length_);
}
else if (rule == SimpleTypes::linespacingruleAtLeast)
{
convert(dynamic_cast<SimpleTypes::CUniversalMeasure *>(oox_paragraph_pr->m_oSpacing->m_oLine.GetPointer()),
paragraph_properties->content_.style_line_height_at_least_);
}
else
{
double val = oox_paragraph_pr->m_oSpacing->m_oLine->ToPoints() * 20;

View File

@ -473,7 +473,7 @@ namespace NSShapeImageGen
if (bVector)
{
//copy source vector image
//copy source vector image
OOX::CPath pathSaveItem = strSaveDir + oInfo.GetPath2();
CDirectory::CopyFile(strFileName, pathSaveItem.GetPath());
@ -493,26 +493,37 @@ namespace NSShapeImageGen
oWriterSVG.SetFontManager(m_pFontManager);
oWriterSVG.put_Width(WW);
oWriterSVG.put_Height(HH);
pMetafile->DrawOnRenderer(&oWriterSVG, 0, 0, WW, HH);
HRESULT hRes = S_OK;
bool bIsBigestSVG = false;
bool bIsRaster = true;
oWriterSVG.IsRaster(&bIsRaster);
LONG lSvgDataSize = 0;
oWriterSVG.GetSVGDataSize(&lSvgDataSize);
bool bIsBigestSVG = (lSvgDataSize > 5 * 1024 *1024);
if(bIsRaster || bIsBigestSVG)
try
{
//случай растрового wmf/emf
hRes = pMetafile->DrawOnRenderer(&oWriterSVG, 0, 0, WW, HH);
}
catch (...)
{
hRes = S_FALSE;
}
if (hRes == S_OK)
{
oWriterSVG.IsRaster(&bIsRaster);
LONG lSvgDataSize = 0;
oWriterSVG.GetSVGDataSize(&lSvgDataSize);
bIsBigestSVG = (lSvgDataSize > 5 * 1024 * 1024);
}
if(bIsRaster || bIsBigestSVG || hRes != S_OK)
{
//случай растрового wmf/emf или г...
if (lWidth <= 0 || lHeight <= 0)
{
int nMaxPixSize = 1000;
int nMinPixSize = 10;
//usually bound of raster wmf from 0 to 1
//usually bound of raster wmf from 0 to 1
if ((nMinPixSize <= w && w <= nMaxPixSize) && (nMinPixSize <= h && h <= nMaxPixSize))
{
lWidth = -1;

View File

@ -626,6 +626,10 @@ int XF::serialize(std::wostream & stream)
CP_XML_ATTR(L"applyNumberFormat", fAtrNum);
CP_XML_ATTR(L"applyFont" , fAtrFnt);
CP_XML_ATTR(L"applyAlignment" , fAtrAlc);
if (fAtrProt)
CP_XML_ATTR(L"applyProtection", fAtrProt);
if ((alc >= 0 && alc < 8) || (alcV >= 0 && alcV < 5) || (fShrinkToFit) ||
(cIndent > 0) || (trot > 0 && trot < 0xff) || (fWrap))
@ -642,6 +646,13 @@ int XF::serialize(std::wostream & stream)
if (trot > 0 && trot < 0xff) CP_XML_ATTR(L"textRotation", trot);
}
}
if (fAtrProt && !fLocked)
{
CP_XML_NODE(L"protection")
{
CP_XML_ATTR(L"locked", false);
}
}
}
}
}

View File

@ -122,8 +122,10 @@ int PROTECTION_COMMON::serialize (std::wostream & _stream)
{
CP_XML_ATTR(L"scenarios", (scenario->fScenProtect ? 1 : 0));
}
CP_XML_ATTR(L"formatCells", 0);
CP_XML_ATTR(L"selectLockedCells", 1);
CP_XML_ATTR(L"selectUnlockedCells", 1);
CP_XML_ATTR(L"autoFilter", 0);
//CP_XML_ATTR(L"selectUnlockedCells", 1);
}
}

View File

@ -32,6 +32,8 @@ def exec_wasm(data, work, compiler_flags, wasm):
compiler_flags.append("-DBUILDING_ASMJS_MODULE")
compiler_flags.append("-D_ARM_ALIGN_")
compiler_flags.append("-Wno-deprecated-register")
# arguments
arguments = ""
for item in compiler_flags:

View File

@ -1593,14 +1593,14 @@ namespace Aggplus
PatRendBuff.attach((BYTE*)pImgBuff, dwImgWidth, dwImgHeight, nImgStride);
}
int nCurrentMode = 0;
int nCurrentMode = 255;
if (!m_bSwapRGB)
{
typedef agg::pixfmt_bgra32 pixfmt;
typedef agg::image_accessor_clip<pixfmt> img_source_type;
typedef agg::image_accessor_clone<pixfmt> img_source_type;
pixfmt img_pixf(PatRendBuff);
img_source_type img_src(img_pixf, agg::rgba(0, 0, 0, 0));
img_source_type img_src(img_pixf);
switch (nCurrentMode)
{
@ -1655,6 +1655,17 @@ namespace Aggplus
render_scanlines_alpha(ri, Alpha);
break;
}
case 255:
{
typedef agg::span_image_resample_rgba_affine<img_source_type> span_gen_type;
typedef agg::renderer_scanline_aa<base_renderer_type, span_alloc_type, span_gen_type> renderer_type;
agg::image_filter_lut filter;
filter.calculate(agg::image_filter_bilinear(), false);
span_gen_type sg(img_src, interpolator, filter);
renderer_type ri(m_frame_buffer.ren_base(), span_allocator, sg);
render_scanlines_alpha(ri, Alpha);
break;
}
default:
break;
}
@ -1662,10 +1673,10 @@ namespace Aggplus
else
{
typedef agg::pixfmt_rgba32 pixfmt;
typedef agg::image_accessor_clip<pixfmt> img_source_type;
typedef agg::image_accessor_clone<pixfmt> img_source_type;
pixfmt img_pixf(PatRendBuff);
img_source_type img_src(img_pixf, agg::rgba(0, 0, 0, 0));
img_source_type img_src(img_pixf);
switch (nCurrentMode)
{
@ -1720,6 +1731,17 @@ namespace Aggplus
render_scanlines_alpha(ri, Alpha);
break;
}
case 255:
{
typedef agg::span_image_resample_rgba_affine<img_source_type> span_gen_type;
typedef agg::renderer_scanline_aa<base_renderer_type, span_alloc_type, span_gen_type> renderer_type;
agg::image_filter_lut filter;
filter.calculate(agg::image_filter_bilinear(), false);
span_gen_type sg(img_src, interpolator, filter);
renderer_type ri(m_frame_buffer.ren_base(), span_allocator, sg);
render_scanlines_alpha(ri, Alpha);
break;
}
default:
break;
}

View File

@ -119,7 +119,7 @@
{
"name": "a",
"folder": "../../../agg-2.4/src/",
"files": ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp"]
"files": ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp", "agg_image_filters.cpp"]
},
{
"name": "co",

View File

@ -38,10 +38,10 @@
return self["AscViewer"]["baseUrl"] + name;
return name;
}
var FS = undefined;
//desktop_fetch
var FS = undefined;
//desktop_fetch
//polyfill
@ -88,6 +88,7 @@
this.stream_size = 0;
this.type = -1;
this.pages = [];
this.info = null;
this._isNeedPassword = false;
}
@ -141,25 +142,39 @@
return false;
var _info = Module["_GetInfo"](this.nativeFile);
if (!_info)
if (_info == 0)
return false;
var _pages = Module["HEAP32"][_info >> 2];
var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages);
var lenArray = new Int32Array(Module["HEAP8"].buffer, _info, 4);
if (lenArray == null)
return false;
var _cur = 1;
var len = lenArray[0];
len -= 4;
if (len <= 0)
return false;
var buffer = new Uint8Array(Module["HEAP8"].buffer, _info + 4, len);
var reader = new CBinaryReader(buffer, 0, len);
var _pages = reader.readInt();
for (var i = 0; i < _pages; i++)
{
this.pages.push({
"W" : _buffer[_cur++],
"H" : _buffer[_cur++],
"Dpi" : _buffer[_cur++],
fonts : [],
text : null
});
var rec = {};
rec["W"] = reader.readInt();
rec["H"] = reader.readInt();
rec["Dpi"] = reader.readInt();
rec.fonts = [];
rec.text = null;
this.pages.push(rec);
}
var json_info = reader.readString();
try
{
this.info = JSON.parse(json_info);
} catch(err) {}
this.free(_info);
Module["_free"](_info);
return this.pages.length > 0;
};
CFile.prototype["close"] = function()
@ -167,6 +182,7 @@
Module["_Close"](this.nativeFile);
this.nativeFile = 0;
this.pages = [];
this.info = null;
if (this.stream > 0)
Module["_free"](this.stream);
this.stream = -1;
@ -189,12 +205,12 @@
self.drawingFileCurrentPageIndex = pageIndex;
var retValue = Module["_GetPixmap"](this.nativeFile, pageIndex, width, height, backgroundColor === undefined ? 0xFFFFFF : backgroundColor);
self.drawingFileCurrentPageIndex = -1;
if (this.pages[pageIndex].fonts.length > 0)
if (this.pages[pageIndex].fonts.length > 0)
{
// ждем загрузки шрифтов для этой страницы
Module["_free"](retValue);
retValue = null;
retValue = null;
}
return retValue;
};
@ -351,7 +367,7 @@
}
self["AscViewer"]["CheckStreamId"] = function(data, status) {
var lenArray = new Int32Array(Module["HEAP8"].buffer, data, 4);
var lenArray = new Int32Array(Module["HEAP8"].buffer, data, 4);
var len = lenArray[0];
len -= 4;
@ -378,11 +394,11 @@
{
self.fontStreams[fileId] = self.fontStreams[fileId] || {};
self.fontStreams[fileId].pages = self.fontStreams[fileId].pages || [];
addToArrayAsDictionary(self.fontStreams[fileId].pages, self.drawingFileCurrentPageIndex);
addToArrayAsDictionary(self.fontStreams[fileId].pages, self.drawingFileCurrentPageIndex);
if (self.drawingFile)
{
addToArrayAsDictionary(self.drawingFile.pages[self.drawingFileCurrentPageIndex].fonts, fileId);
addToArrayAsDictionary(self.drawingFile.pages[self.drawingFileCurrentPageIndex].fonts, fileId);
}
if (fileStatus != 2)
@ -423,10 +439,10 @@
var memoryBuffer = fileId.toUtf8();
var pointer = Module["_malloc"](memoryBuffer.length);
Module.HEAP8.set(memoryBuffer, pointer);
Module.HEAP8.set(memoryBuffer, pointer);
Module["HEAP8"][status] = (fileStatus == 0) ? 1 : 0;
return pointer;
};
};
function fontToMemory(file, isCheck)
{
@ -444,7 +460,7 @@
}
}
var stream_index = file.GetStreamIndex();
var stream_index = file.GetStreamIndex();
var streams = AscFonts.getFontStreams();
var stream = AscFonts.getFontStream(stream_index);
@ -457,7 +473,7 @@
Module["_SetFontBinary"](idPointer, streamPointer, stream.size);
Module["_free"](streamPointer);
Module["_free"](streamPointer);
Module["_free"](idPointer);
}

View File

@ -5,6 +5,7 @@
#include "../../../../../common/Base64.h"
#include "../../../../../common/File.h"
#include "drawingfile.h"
#include "serialize.h"
#ifdef _WIN32
#define WASM_EXPORT __declspec(dllexport)
@ -102,23 +103,31 @@ WASM_EXPORT void Close (CGraphicsFileDrawing* pGraphics)
delete pGraphics;
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NULL);
}
WASM_EXPORT int* GetInfo (CGraphicsFileDrawing* pGraphics)
WASM_EXPORT BYTE* GetInfo (CGraphicsFileDrawing* pGraphics)
{
NSWasm::CData oRes;
oRes.SkipLen();
int pages_count = pGraphics->GetPagesCount();
int* buffer = new int[pages_count * 3 + 1];
int buffer_index = 0;
buffer[buffer_index++] = pages_count;
oRes.AddInt(pages_count);
for (int page = 0; page < pages_count; ++page)
{
int nW = 0;
int nH = 0;
int nDpi = 0;
pGraphics->GetPageInfo(page, nW, nH, nDpi);
buffer[buffer_index++] = nW;
buffer[buffer_index++] = nH;
buffer[buffer_index++] = nDpi;
oRes.AddInt(nW);
oRes.AddInt(nH);
oRes.AddInt(nDpi);
}
return buffer;
std::wstring wsInfo = pGraphics->GetInfo();
std::string sInfo = U_TO_UTF8(wsInfo);
oRes.WriteString((BYTE*)sInfo.c_str(), sInfo.length());
oRes.WriteLen();
BYTE* bRes = oRes.GetBuffer();
oRes.ClearWithoutAttack();
return bRes;
}
WASM_EXPORT BYTE* GetPixmap(CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH, int nBackgroundColor)
{
@ -153,9 +162,9 @@ static DWORD GetLength(BYTE* x)
int main()
{
#define XPS_TEST 1
#define XPS_TEST 0
#define DJVU_TEST 0
#define PDF_TEST 0
#define PDF_TEST 1
#if PDF_TEST
BYTE* pPdfData = NULL;
DWORD nPdfBytesCount;
@ -183,12 +192,14 @@ int main()
return 1;
}
}
int* info = GetInfo(test);
int pages_count = *info;
BYTE* info = GetInfo(test);
DWORD nLength = GetLength(info);
nLength -= 4;
int pages_count = GetLength(info + 4);
int test_page = 0;
int width = info[test_page * 3 + 1];
int height = info[test_page * 3 + 2];
std::cout << "Page " << test_page << " width " << width << " height " << height << " dpi " << info[test_page * 3 + 3] << std::endl;
int width = GetLength(info + test_page * 12 + 8);
int height = GetLength(info + test_page * 12 + 12);
std::cout << "Page " << test_page << " width " << width << " height " << height << " dpi " << GetLength(info + test_page * 12 + 16) << std::endl;
BYTE* res = NULL;
if (pages_count > 0)
@ -203,9 +214,12 @@ int main()
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
resFrame->ClearNoAttack();
nLength = GetLength(info + pages_count * 12 + 8);
std::cout << "json "<< std::string((char*)(info + pages_count * 12 + 12), nLength);
std::cout << std::endl;
BYTE* pLinks = GetLinks(test, test_page);
DWORD nLength = GetLength(pLinks);
nLength = GetLength(pLinks);
DWORD i = 4;
nLength -= 4;
while (i < nLength)
@ -284,11 +298,11 @@ int main()
RELEASEARRAYOBJECTS(pXpsData);
return 1;
}
int* info = GetInfo(test);
int pages_count = *info;
int* size = GetSize(test);
int pages_count = *size;
int test_page = 0;
int width = info[test_page * 3 + 1];
int height = info[test_page * 3 + 2];
int width = size[test_page * 3 + 1];
int height = size[test_page * 3 + 2];
std::cout << "Page " << test_page << " width " << width << " height " << height << std::endl;
std::cout << std::endl;
@ -319,7 +333,7 @@ int main()
if (!res)
{
RELEASEARRAYOBJECTS(pXpsData);
RELEASEARRAYOBJECTS(info);
RELEASEARRAYOBJECTS(size);
return 1;
}
@ -332,6 +346,10 @@ int main()
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
resFrame->ClearNoAttack();
BYTE* info = GetInfo(test);
nLength = GetLength(info + 4);
std::cout << "json "<< std::string((char*)(info + 8), nLength);
std::cout << std::endl;
BYTE* pGlyphs = GetGlyphs(test, test_page);
@ -365,6 +383,7 @@ int main()
Close(test);
RELEASEARRAYOBJECTS(pXpsData);
RELEASEARRAYOBJECTS(size);
RELEASEARRAYOBJECTS(info);
RELEASEARRAYOBJECTS(res);
RELEASEARRAYOBJECTS(pLinks);
@ -391,11 +410,11 @@ int main()
RELEASEARRAYOBJECTS(pDjVuData);
return 1;
}
int* info = GetInfo(test);
int pages_count = *info;
int* size = GetSize(test);
int pages_count = *size;
int test_page = 1;
int width = info[test_page * 3 + 1];
int height = info[test_page * 3 + 2];
int width = size[test_page * 3 + 1];
int height = size[test_page * 3 + 2];
std::cout << "Page " << test_page << " width " << width << " height " << height << std::endl;
std::cout << std::endl;
@ -421,7 +440,7 @@ int main()
BYTE* res = NULL;
if (pages_count > 0)
res = GetPixmap(test, test_page, width, height);
res = GetPixmap(test, test_page, width, height, 0xFFFFFF);
CBgraFrame* resFrame = new CBgraFrame();
resFrame->put_Data(res);
@ -432,6 +451,10 @@ int main()
resFrame->SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
resFrame->ClearNoAttack();
BYTE* info = GetInfo(test);
nLength = GetLength(info + 4);
std::cout << "json "<< std::string((char*)(info + 8), nLength);
std::cout << std::endl;
BYTE* pGlyphs = GetGlyphs(test, test_page);
@ -465,9 +488,9 @@ int main()
Close(test);
RELEASEARRAYOBJECTS(pDjVuData);
RELEASEARRAYOBJECTS(size);
RELEASEARRAYOBJECTS(info);
RELEASEARRAYOBJECTS(res);
RELEASEARRAYOBJECTS(pGlyphs);
RELEASEARRAYOBJECTS(pLinks);
RELEASEARRAYOBJECTS(pStructure);
RELEASEOBJECT(resFrame);

View File

@ -110,6 +110,10 @@ public:
{
return pReader->GetStructure();
}
std::wstring GetInfo()
{
return pReader->GetInfo();
}
void DestroyText()
{

View File

@ -85,6 +85,7 @@ public:
bool bIsDarkMode = false);
// Common methods for viewer
virtual std::wstring GetInfo() = 0;
#ifdef BUILDING_WASM_MODULE
virtual unsigned char* GetStructure() = 0;
virtual unsigned char* GetLinks(int nPageIndex) = 0;

View File

@ -98,6 +98,12 @@ void CDjVuFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* p
if (m_pImplementation)
m_pImplementation->DrawPageOnRenderer(pRenderer, nPageIndex, pBreak);
}
std::wstring CDjVuFile::GetInfo()
{
if (m_pImplementation)
return m_pImplementation->GetInfo();
return L"";
}
void CDjVuFile::ConvertToPdf(const std::wstring& wsDstPath)
{
if (m_pImplementation)

View File

@ -70,6 +70,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 std::wstring GetInfo();
void ConvertToPdf(const std::wstring& path);

View File

@ -258,6 +258,26 @@ void CDjVuFileImplementation::ConvertToPdf(const std::wstring& wsDstPath)
oPdf.SaveToFile(wsDstPath);
}
std::wstring CDjVuFileImplementation::GetInfo()
{
std::wstring sRes = L"{";
double nW = 0;
double nH = 0;
double nDpi = 0;
GetPageInfo(0, &nW, &nH, &nDpi, &nDpi);
sRes += L"\"PageSize\":\"";
std::wstring size = std::to_wstring(nW);
sRes += size.substr(0, size.length() - 4);
sRes += L"x";
size = std::to_wstring(nH);
sRes += size.substr(0, size.length() - 4);
sRes += L"\",\"NumberOfPages\":";
sRes += std::to_wstring(GetPagesCount());
sRes += L"}";
return sRes;
}
#ifdef BUILDING_WASM_MODULE
void getBookmars(const GP<DjVmNav>& nav, int& pos, int count, NSWasm::CData& out, int level)

View File

@ -77,6 +77,7 @@ public:
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
void ConvertToPdf(const std::wstring& wsDstPath);
std::wstring GetInfo();
#ifdef BUILDING_WASM_MODULE
BYTE* GetStructure();

View File

@ -42,11 +42,13 @@
#include "../DesktopEditor/raster/BgraFrame.h"
#include "../DesktopEditor/graphics/IRenderer.h"
#include "../DesktopEditor/common/Directory.h"
#include "../DesktopEditor/common/StringExt.h"
#include "lib/xpdf/PDFDoc.h"
#include "lib/xpdf/GlobalParams.h"
#include "lib/xpdf/ErrorCodes.h"
#include "lib/xpdf/ImageOutputDev.h"
#include "lib/xpdf/TextString.h"
#include "Src/RendererOutputDev.h"
#ifdef BUILDING_WASM_MODULE
@ -55,9 +57,7 @@
#include "lib/xpdf/Link.h"
#include "lib/xpdf/TextOutputDev.h"
#include "lib/goo/GList.h"
#include "../DesktopEditor/common/StringExt.h"
#include <vector>
//#include <fstream>
#endif
namespace PdfReader
@ -435,6 +435,91 @@ return 0;
// return wsXml;
return L"";
}
#define DICT_LOOKUP(sName, wsName) \
if (info.dictLookup(sName, &obj1)->isString())\
{\
TextString* s = new TextString(obj1.getString());\
sRes += L"\"";\
sRes += wsName;\
sRes += L"\":\"";\
std::wstring sValue = NSStringExt::CConverter::GetUnicodeFromUTF32(s->getUnicode(), s->getLength());\
NSStringExt::Replace(sValue, L"\"", L"\\\"");\
sRes += sValue;\
sRes += L"\",";\
delete s;\
}\
#define DICT_LOOKUP_DATE(sName, wsName) \
if (info.dictLookup(sName, &obj1)->isString())\
{\
char* str = obj1.getString()->getCString();\
int length = obj1.getString()->getLength();\
if (str && length > 21)\
{\
TextString* s = new TextString(obj1.getString());\
std::wstring sNoDate = NSStringExt::CConverter::GetUnicodeFromUTF32(s->getUnicode(), s->getLength());\
std::wstring sDate = sNoDate.substr(2, 4) + L'-' + sNoDate.substr(6, 2) + L'-' + sNoDate.substr(8, 2) + L'T' +\
sNoDate.substr(10, 2) + L':' + sNoDate.substr(12, 2) + L':' + sNoDate.substr(14, 2) + L".000+" +\
sNoDate.substr(17, 2) + L':' + sNoDate.substr(20, 2);\
NSStringExt::Replace(sDate, L"\"", L"\\\"");\
sRes += L"\"";\
sRes += wsName;\
sRes += L"\":\"";\
sRes += sDate;\
sRes += L"\",";\
delete s;\
}\
}\
std::wstring CPdfReader::GetInfo()
{
if (!m_pInternal->m_pPDFDocument)
return NULL;
std::wstring sRes = L"{";
Object info, obj1;
m_pInternal->m_pPDFDocument->getDocInfo(&info);
if (info.isDict())
{
DICT_LOOKUP("Title", L"Title");
DICT_LOOKUP("Author", L"Author");
DICT_LOOKUP("Subject", L"Subject");
DICT_LOOKUP("Keywords", L"Keywords");
DICT_LOOKUP("Creator", L"Creator");
DICT_LOOKUP("Producer", L"Producer");
DICT_LOOKUP_DATE("CreationDate", L"CreationDate");
DICT_LOOKUP_DATE("ModDate", L"ModDate");
}
info.free();
obj1.free();
std::wstring version = std::to_wstring(GetVersion());
sRes += L"\"Version\":";
sRes += version.substr(0, version.length() - 5);
double nW = 0;
double nH = 0;
double nDpi = 0;
GetPageInfo(0, &nW, &nH, &nDpi, &nDpi);
sRes += L",\"PageSize\":\"";
version = std::to_wstring(nW);
sRes += version.substr(0, version.length() - 4);
sRes += L"x";
version = std::to_wstring(nH);
sRes += version.substr(0, version.length() - 4);
sRes += L"\",\"NumberOfPages\":";
sRes += std::to_wstring(GetPagesCount());
sRes += L",\"FastWebView\":";
sRes += m_pInternal->m_pPDFDocument->isLinearized() ? L"true" : L"false";
sRes += L",\"Tagged\":";
sRes += m_pInternal->m_pPDFDocument->getStructTreeRoot()->isDict() ? L"true" : L"false";
sRes += L"}";
return sRes;
}
#ifdef BUILDING_WASM_MODULE
void getBookmars(PDFDoc* pdfDoc, OutlineItem* pOutlineItem, NSWasm::CData& out, int level)
{
@ -576,7 +661,7 @@ return 0;
if (kind == actionGoTo)
{
str = ((LinkGoTo*)pLinkAction)->getNamedDest();
LinkDest* pLinkDest = m_pInternal->m_pPDFDocument->findDest(str);
LinkDest* pLinkDest = str ? m_pInternal->m_pPDFDocument->findDest(str) : ((LinkGoTo*)pLinkAction)->getDest()->copy();
if (pLinkDest)
{
int pg;

View File

@ -84,6 +84,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 std::wstring GetInfo();
int GetError();
double GetVersion();

View File

@ -3712,12 +3712,14 @@ namespace NExtractTools
case AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB:
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:
case AVS_OFFICESTUDIO_FILE_IMAGE:
bIsNeedDoct = true;
break;
default:
if (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo)
bIsNeedDoct = true;
break;
}
if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo) && !bIsNeedDoct)
{
if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM == nFormatTo ||
@ -4149,6 +4151,12 @@ namespace NExtractTools
int nFormatTo = AVS_OFFICESTUDIO_FILE_UNKNOWN;
if(NULL != params.m_nFormatTo)
nFormatTo = *params.m_nFormatTo;
if (nFormatTo == AVS_OFFICESTUDIO_FILE_UNKNOWN)
{
return AVS_FILEUTILS_ERROR_CONVERT_PARAMS;
}
std::wstring sFontPath;
if(NULL != params.m_sFontDir)
sFontPath = *params.m_sFontDir;

View File

@ -180,6 +180,10 @@ void CXpsFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pB
m_pInternal->m_pDocument->DrawPage(nPageIndex, pRenderer, pBreak);
}
std::wstring CXpsFile::GetInfo()
{
return m_pInternal->m_pDocument->GetInfo();
}
#ifndef DISABLE_PDF_CONVERTATION
void CXpsFile::ConvertToPdf(const std::wstring& wsPath)

View File

@ -65,6 +65,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 std::wstring GetInfo();
#ifndef DISABLE_PDF_CONVERTATION
void ConvertToPdf(const std::wstring& wsDstPath);

View File

@ -34,6 +34,7 @@
#include "../../DesktopEditor/xml/include/xmlutils.h"
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/StringExt.h"
namespace XPS
{
@ -347,4 +348,71 @@ namespace XPS
m_mStaticResources.insert(std::pair<std::wstring, CStaticResource*>(wsPath, pStaticResource));
return pStaticResource;
}
std::wstring CDocument::GetInfo()
{
XmlUtils::CXmlLiteReader oReader;
std::wstring sRes = L"{";
if (oReader.FromStringA(m_wsPath->readXml(L"_rels/.rels")) && oReader.ReadNextNode() && L"Relationships" == oReader.GetName())
{
std::wstring wsCoreFile;
while (oReader.ReadNextNode())
{
if (L"Relationship" == oReader.GetName())
{
std::wstring wsAttr;
ReadAttribute(oReader, L"Type", wsAttr);
if (wsAttr.find(L"core-properties") != std::wstring::npos)
{
ReadAttribute(oReader, L"Target", wsCoreFile);
break;
}
}
}
if (!wsCoreFile.empty() && m_wsPath->exists(wsCoreFile))
{
oReader.Clear();
if (oReader.FromStringA(m_wsPath->readXml(wsCoreFile)) && oReader.ReadNextNode() && oReader.GetName() == L"cp:coreProperties")
{
while (oReader.ReadNextNode())
{
std::wstring sName = oReader.GetName();
if (sName == L"dc:title")
sName = L"Title";
else if (sName == L"dc:subject")
sName = L"Subject";
else if (sName == L"dc:creator")
sName = L"Creator";
else if (sName == L"dcterms:created")
sName = L"CreationDate";
else if (sName == L"dcterms:modified")
sName = L"ModDate";
sRes += L"\"";
sRes += sName;
sRes += L"\":\"";
sName = oReader.GetText2();
NSStringExt::Replace(sName, L"\"", L"\\\"");
sRes += oReader.GetText2();
sRes += L"\",";
}
}
}
}
int nW = 0;
int nH = 0;
GetPageSize(0, nW, nH);
sRes += L"\"PageSize\":\"";
sRes += std::to_wstring(nW);
sRes += L"x";
sRes += std::to_wstring(nH);
sRes += L"\",\"NumberOfPages\":";
sRes += std::to_wstring(GetPageCount());
sRes += L"}";
return sRes;
}
}

View File

@ -57,6 +57,7 @@ namespace XPS
void DrawPage(int nPageIndex, IRenderer* pRenderer, bool* pbBreak);
void Close();
CStaticResource* GetStaticResource(const wchar_t* wsPath);
std::wstring GetInfo();
#ifdef BUILDING_WASM_MODULE
struct CDocumentStructure