mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
djvu links
This commit is contained in:
@ -79,6 +79,10 @@ WASM_EXPORT BYTE* XPS_GetInternalLinks(CGraphicsFileDrawing* pGraphics, int nPag
|
|||||||
{
|
{
|
||||||
return pGraphics->GetXPSInternalLinks(nPageIndex, nRasterW, nRasterH);
|
return pGraphics->GetXPSInternalLinks(nPageIndex, nRasterW, nRasterH);
|
||||||
}
|
}
|
||||||
|
WASM_EXPORT BYTE* DJVU_GetLinks(CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
return pGraphics->GetDJVULinks(nPageIndex, nRasterW, nRasterH);
|
||||||
|
}
|
||||||
WASM_EXPORT BYTE* XPS_GetStructure(CGraphicsFileDrawing* pGraphics)
|
WASM_EXPORT BYTE* XPS_GetStructure(CGraphicsFileDrawing* pGraphics)
|
||||||
{
|
{
|
||||||
return pGraphics->GetXPSStructure();
|
return pGraphics->GetXPSStructure();
|
||||||
@ -99,13 +103,13 @@ WASM_EXPORT void XPS_Delete(BYTE* pData)
|
|||||||
#ifdef TEST_AS_EXECUTABLE
|
#ifdef TEST_AS_EXECUTABLE
|
||||||
static DWORD GetLength(BYTE* x)
|
static DWORD GetLength(BYTE* x)
|
||||||
{
|
{
|
||||||
return x[0] | x[1] << 8 | x[2] << 16 | x[3] << 24;
|
return x ? (x[0] | x[1] << 8 | x[2] << 16 | x[3] << 24) : 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#define XPS_TEST 1
|
#define XPS_TEST 0
|
||||||
#define DJVU_TEST 0
|
#define DJVU_TEST 1
|
||||||
#if XPS_TEST
|
#if XPS_TEST
|
||||||
BYTE* pXpsData = NULL;
|
BYTE* pXpsData = NULL;
|
||||||
DWORD nXpsBytesCount;
|
DWORD nXpsBytesCount;
|
||||||
@ -280,7 +284,7 @@ int main()
|
|||||||
int width = info[1] * 96 / info[3];
|
int width = info[1] * 96 / info[3];
|
||||||
int height = info[2] * 96 / info[3];
|
int height = info[2] * 96 / info[3];
|
||||||
|
|
||||||
BYTE* pGlyphs = DJVU_GetGlyphs(test, 3, width, height);
|
BYTE* pGlyphs = DJVU_GetGlyphs(test, 0, width, height);
|
||||||
DWORD nLength = GetLength(pGlyphs);
|
DWORD nLength = GetLength(pGlyphs);
|
||||||
DWORD i = 4;
|
DWORD i = 4;
|
||||||
nLength -= 4;
|
nLength -= 4;
|
||||||
@ -309,9 +313,21 @@ int main()
|
|||||||
i += nPathLength;
|
i += nPathLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BYTE* pLinks = DJVU_GetLinks(test, 0, width, height);
|
||||||
|
nLength = GetLength(pLinks);
|
||||||
|
i = 4;
|
||||||
|
nLength -= 4;
|
||||||
|
while (i < nLength)
|
||||||
|
{
|
||||||
|
DWORD nPathLength = GetLength(pLinks + i);
|
||||||
|
i += 4;
|
||||||
|
std::cout << "Link "<< std::string((char*)(pLinks + i), nPathLength) << std::endl;
|
||||||
|
i += nPathLength;
|
||||||
|
}
|
||||||
|
|
||||||
BYTE* res = NULL;
|
BYTE* res = NULL;
|
||||||
if (pages_count > 0)
|
if (pages_count > 0)
|
||||||
res = XPS_GetPixmap(test, 3, width, height);
|
res = XPS_GetPixmap(test, 0, width, height);
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
std::cout << (int)res[i] << " ";
|
std::cout << (int)res[i] << " ";
|
||||||
@ -348,6 +364,7 @@ int main()
|
|||||||
RELEASEARRAYOBJECTS(info);
|
RELEASEARRAYOBJECTS(info);
|
||||||
RELEASEARRAYOBJECTS(res);
|
RELEASEARRAYOBJECTS(res);
|
||||||
RELEASEARRAYOBJECTS(pGlyphs);
|
RELEASEARRAYOBJECTS(pGlyphs);
|
||||||
|
RELEASEARRAYOBJECTS(pLinks);
|
||||||
RELEASEARRAYOBJECTS(pStructure);
|
RELEASEARRAYOBJECTS(pStructure);
|
||||||
RELEASEOBJECT(resFrame);
|
RELEASEOBJECT(resFrame);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -90,6 +90,10 @@ public:
|
|||||||
{
|
{
|
||||||
return ((CXpsFile*)pReader)->GetInternalLinks(nPageIndex, nRasterW, nRasterH);
|
return ((CXpsFile*)pReader)->GetInternalLinks(nPageIndex, nRasterW, nRasterH);
|
||||||
}
|
}
|
||||||
|
BYTE* GetDJVULinks(int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
return ((CDjVuFile*)pReader)->GetPageLinks(nPageIndex, nRasterW, nRasterH);
|
||||||
|
}
|
||||||
BYTE* GetXPSStructure()
|
BYTE* GetXPSStructure()
|
||||||
{
|
{
|
||||||
return ((CXpsFile*)pReader)->GetStructure();
|
return ((CXpsFile*)pReader)->GetStructure();
|
||||||
|
|||||||
@ -118,4 +118,10 @@ BYTE* CDjVuFile::GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH)
|
|||||||
return m_pImplementation->GetPageGlyphs(nPageIndex, nRasterW, nRasterH);
|
return m_pImplementation->GetPageGlyphs(nPageIndex, nRasterW, nRasterH);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
BYTE* CDjVuFile::GetPageLinks (int nPageIndex, int nRasterW, int nRasterH)
|
||||||
|
{
|
||||||
|
if (m_pImplementation)
|
||||||
|
return m_pImplementation->GetPageLinks(nPageIndex, nRasterW, nRasterH);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -74,5 +74,6 @@ public:
|
|||||||
#ifdef WASM_MODE
|
#ifdef WASM_MODE
|
||||||
BYTE* GetStructure();
|
BYTE* GetStructure();
|
||||||
BYTE* GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH);
|
BYTE* GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH);
|
||||||
|
BYTE* GetPageLinks (int nPageIndex, int nRasterW, int nRasterH);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
@ -568,6 +568,25 @@ BYTE* CDjVuFileImplementation::GetPageGlyphs(int nPageIndex, const
|
|||||||
oRes.ClearWithoutAttack();
|
oRes.ClearWithoutAttack();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
BYTE* CDjVuFileImplementation::GetPageLinks (int nPageIndex, const int& nRasterW, const int& nRasterH)
|
||||||
|
{
|
||||||
|
GP<DjVuImage> pPage = m_pDoc->get_page(nPageIndex);
|
||||||
|
GP<DjVuAnno> pAnno = pPage->get_decoded_anno();
|
||||||
|
GPList<GMapArea> map_areas = pAnno->ant->map_areas;
|
||||||
|
|
||||||
|
CData oRes;
|
||||||
|
oRes.SkipLen();
|
||||||
|
for(GPosition pos(map_areas); pos; ++pos)
|
||||||
|
{
|
||||||
|
GUTF8String sURL = map_areas[pos]->url;
|
||||||
|
oRes.WriteString((BYTE*)sURL.getbuf(), sURL.length());
|
||||||
|
}
|
||||||
|
oRes.WriteLen();
|
||||||
|
|
||||||
|
BYTE* res = oRes.GetBuffer();
|
||||||
|
oRes.ClearWithoutAttack();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pPage, int nPage, XmlUtils::CXmlNode& text)
|
void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pPage, int nPage, XmlUtils::CXmlNode& text)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -82,6 +82,7 @@ public:
|
|||||||
#ifdef WASM_MODE
|
#ifdef WASM_MODE
|
||||||
BYTE* GetStructure();
|
BYTE* GetStructure();
|
||||||
BYTE* GetPageGlyphs(int nPageIndex, const int& nRasterW, const int& nRasterH);
|
BYTE* GetPageGlyphs(int nPageIndex, const int& nRasterW, const int& nRasterH);
|
||||||
|
BYTE* GetPageLinks (int nPageIndex, const int& nRasterW, const int& nRasterH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user