diff --git a/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.cpp b/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.cpp index 10d7b23556..e08ccd51a8 100644 --- a/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.cpp +++ b/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.cpp @@ -79,6 +79,10 @@ WASM_EXPORT BYTE* XPS_GetInternalLinks(CGraphicsFileDrawing* pGraphics, int nPag { 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) { return pGraphics->GetXPSStructure(); @@ -99,13 +103,13 @@ WASM_EXPORT void XPS_Delete(BYTE* pData) #ifdef TEST_AS_EXECUTABLE 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() { -#define XPS_TEST 1 -#define DJVU_TEST 0 +#define XPS_TEST 0 +#define DJVU_TEST 1 #if XPS_TEST BYTE* pXpsData = NULL; DWORD nXpsBytesCount; @@ -280,7 +284,7 @@ int main() int width = info[1] * 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 i = 4; nLength -= 4; @@ -309,9 +313,21 @@ int main() 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; 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++) std::cout << (int)res[i] << " "; @@ -348,6 +364,7 @@ int main() RELEASEARRAYOBJECTS(info); RELEASEARRAYOBJECTS(res); RELEASEARRAYOBJECTS(pGlyphs); + RELEASEARRAYOBJECTS(pLinks); RELEASEARRAYOBJECTS(pStructure); RELEASEOBJECT(resFrame); return 0; diff --git a/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.h b/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.h index d230ad3d1d..3d2526c705 100644 --- a/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.h +++ b/DesktopEditor/graphics/pro/js/wasm/src/wasmgraphics.h @@ -90,6 +90,10 @@ public: { return ((CXpsFile*)pReader)->GetInternalLinks(nPageIndex, nRasterW, nRasterH); } + BYTE* GetDJVULinks(int nPageIndex, int nRasterW, int nRasterH) + { + return ((CDjVuFile*)pReader)->GetPageLinks(nPageIndex, nRasterW, nRasterH); + } BYTE* GetXPSStructure() { return ((CXpsFile*)pReader)->GetStructure(); diff --git a/DjVuFile/DjVu.cpp b/DjVuFile/DjVu.cpp index 7b49fbe7e0..90c00a2362 100644 --- a/DjVuFile/DjVu.cpp +++ b/DjVuFile/DjVu.cpp @@ -118,4 +118,10 @@ BYTE* CDjVuFile::GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH) return m_pImplementation->GetPageGlyphs(nPageIndex, nRasterW, nRasterH); return NULL; } +BYTE* CDjVuFile::GetPageLinks (int nPageIndex, int nRasterW, int nRasterH) +{ + if (m_pImplementation) + return m_pImplementation->GetPageLinks(nPageIndex, nRasterW, nRasterH); + return NULL; +} #endif diff --git a/DjVuFile/DjVu.h b/DjVuFile/DjVu.h index 84204f54ad..f3436d2523 100644 --- a/DjVuFile/DjVu.h +++ b/DjVuFile/DjVu.h @@ -74,5 +74,6 @@ public: #ifdef WASM_MODE BYTE* GetStructure(); BYTE* GetPageGlyphs(int nPageIndex, int nRasterW, int nRasterH); + BYTE* GetPageLinks (int nPageIndex, int nRasterW, int nRasterH); #endif }; diff --git a/DjVuFile/DjVuFileImplementation.cpp b/DjVuFile/DjVuFileImplementation.cpp index 93ae86cbfb..0799430bd9 100644 --- a/DjVuFile/DjVuFileImplementation.cpp +++ b/DjVuFile/DjVuFileImplementation.cpp @@ -568,6 +568,25 @@ BYTE* CDjVuFileImplementation::GetPageGlyphs(int nPageIndex, const oRes.ClearWithoutAttack(); return res; } +BYTE* CDjVuFileImplementation::GetPageLinks (int nPageIndex, const int& nRasterW, const int& nRasterH) +{ + GP pPage = m_pDoc->get_page(nPageIndex); + GP pAnno = pPage->get_decoded_anno(); + GPList 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 void CDjVuFileImplementation::CreateFrame(IRenderer* pRenderer, GP& pPage, int nPage, XmlUtils::CXmlNode& text) { diff --git a/DjVuFile/DjVuFileImplementation.h b/DjVuFile/DjVuFileImplementation.h index bb742390c7..0d64a0176e 100644 --- a/DjVuFile/DjVuFileImplementation.h +++ b/DjVuFile/DjVuFileImplementation.h @@ -82,6 +82,7 @@ public: #ifdef WASM_MODE BYTE* GetStructure(); BYTE* GetPageGlyphs(int nPageIndex, const int& nRasterW, const int& nRasterH); + BYTE* GetPageLinks (int nPageIndex, const int& nRasterW, const int& nRasterH); #endif private: