mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
fix djvu coords and structure pages
This commit is contained in:
@ -192,7 +192,7 @@ void CDjVuFileImplementation::GetPageInfo(int nPageIndex, double*
|
|||||||
*pdDpiX = nDpi;
|
*pdDpiX = nDpi;
|
||||||
*pdDpiY = nDpi;
|
*pdDpiY = nDpi;
|
||||||
}
|
}
|
||||||
void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak)
|
void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak, double dKoefX, double dKoefY)
|
||||||
{
|
{
|
||||||
if (!m_pDoc)
|
if (!m_pDoc)
|
||||||
return;
|
return;
|
||||||
@ -218,7 +218,7 @@ void CDjVuFileImplementation::DrawPageOnRenderer(IRenderer* pRende
|
|||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XmlUtils::CXmlNode oText = ParseText(pPage);
|
XmlUtils::CXmlNode oText = ParseText(pPage, dKoefX, dKoefY);
|
||||||
CreateFrame(pRenderer, pPage, nPageIndex, oText);
|
CreateFrame(pRenderer, pPage, nPageIndex, oText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ BYTE* CDjVuFileImplementation::ConvertToPixels(int nPageIndex, cons
|
|||||||
pRenderer->put_Height(dHeight);
|
pRenderer->put_Height(dHeight);
|
||||||
|
|
||||||
bool bBreak = false;
|
bool bBreak = false;
|
||||||
DrawPageOnRenderer(pRenderer, nPageIndex, &bBreak);
|
DrawPageOnRenderer(pRenderer, nPageIndex, &bBreak, (double)nWidth * dPageDpiX / 25.4 / dWidth, (double)nHeight * dPageDpiX / 25.4 / dHeight);
|
||||||
|
|
||||||
RELEASEINTERFACE(pFontManager);
|
RELEASEINTERFACE(pFontManager);
|
||||||
RELEASEOBJECT(pRenderer);
|
RELEASEOBJECT(pRenderer);
|
||||||
@ -350,7 +350,7 @@ void getBookmars(const GP<DjVmNav>& nav, int& pos, int count, CDjVuFileImplement
|
|||||||
|
|
||||||
GUTF8String str = gpBookMark->url;
|
GUTF8String str = gpBookMark->url;
|
||||||
int endpos;
|
int endpos;
|
||||||
DWORD nPage = str.toULong(1, endpos);
|
DWORD nPage = str.toULong(1, endpos) - 1;
|
||||||
if (endpos == (int)str.length())
|
if (endpos == (int)str.length())
|
||||||
{
|
{
|
||||||
out.AddInt(nPage);
|
out.AddInt(nPage);
|
||||||
@ -1009,7 +1009,7 @@ void CDjVuFileImplementation::CreateGrFrame(IRenderer* pRenderer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage)
|
XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage, double dKoefX, double dKoefY)
|
||||||
{
|
{
|
||||||
XmlUtils::CXmlNode paragraph;
|
XmlUtils::CXmlNode paragraph;
|
||||||
const GP<DjVuText> text(DjVuText::create());
|
const GP<DjVuText> text(DjVuText::create());
|
||||||
@ -1056,13 +1056,13 @@ XmlUtils::CXmlNode CDjVuFileImplementation::ParseText(GP<DjVuImage> pPage)
|
|||||||
|
|
||||||
std::string sText = U_TO_UTF8(csWord);
|
std::string sText = U_TO_UTF8(csWord);
|
||||||
m_pGlyphs->WriteString((BYTE*)sText.c_str(), sText.length());
|
m_pGlyphs->WriteString((BYTE*)sText.c_str(), sText.length());
|
||||||
std::string sX = std::to_string(arrCoords[0]);
|
std::string sX = std::to_string(arrCoords[0] * dKoefX);
|
||||||
m_pGlyphs->WriteString((BYTE*)sX.c_str(), sX.length());
|
m_pGlyphs->WriteString((BYTE*)sX.c_str(), sX.length());
|
||||||
std::string sY = std::to_string(arrCoords[3]);
|
std::string sY = std::to_string(arrCoords[3] * dKoefY);
|
||||||
m_pGlyphs->WriteString((BYTE*)sY.c_str(), sY.length());
|
m_pGlyphs->WriteString((BYTE*)sY.c_str(), sY.length());
|
||||||
std::string sW = std::to_string(arrCoords[2] - arrCoords[0]);
|
std::string sW = std::to_string((arrCoords[2] - arrCoords[0]) * dKoefX);
|
||||||
m_pGlyphs->WriteString((BYTE*)sW.c_str(), sW.length());
|
m_pGlyphs->WriteString((BYTE*)sW.c_str(), sW.length());
|
||||||
std::string sH = std::to_string(arrCoords[1] - arrCoords[3]);
|
std::string sH = std::to_string((arrCoords[1] - arrCoords[3]) * dKoefY);
|
||||||
m_pGlyphs->WriteString((BYTE*)sH.c_str(), sH.length());
|
m_pGlyphs->WriteString((BYTE*)sH.c_str(), sH.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public:
|
|||||||
void SetTempDirectory(const std::wstring& wsDirectory);
|
void SetTempDirectory(const std::wstring& wsDirectory);
|
||||||
int GetPagesCount() const;
|
int GetPagesCount() const;
|
||||||
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
|
void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY) const;
|
||||||
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
|
void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak, double dKoefX = 0, double dKoefY = 0);
|
||||||
BYTE* ConvertToPixels(int nPageIndex, const int& nRasterW = -1, const int& nRasterH = -1);
|
BYTE* ConvertToPixels(int nPageIndex, const int& nRasterW = -1, const int& nRasterH = -1);
|
||||||
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
|
void ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int& nRasterW = -1, const int& nRasterH = -1);
|
||||||
void ConvertToPdf(const std::wstring& wsDstPath);
|
void ConvertToPdf(const std::wstring& wsDstPath);
|
||||||
@ -212,7 +212,7 @@ private:
|
|||||||
void CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
void CreateFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
||||||
void CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
void CreatePdfFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, int nPage, XmlUtils::CXmlNode& oText);
|
||||||
void CreateGrFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, bool* pBreak);
|
void CreateGrFrame(IRenderer* pRenderer, GP<DjVuImage>& pImage, bool* pBreak);
|
||||||
XmlUtils::CXmlNode ParseText(GP<DjVuImage> pPage);
|
XmlUtils::CXmlNode ParseText(GP<DjVuImage> pPage, double dKoefX, double dKoefY);
|
||||||
void TextToRenderer(IRenderer* pRenderer, XmlUtils::CXmlNode text, double koef, bool isView = true);
|
void TextToRenderer(IRenderer* pRenderer, XmlUtils::CXmlNode text, double koef, bool isView = true);
|
||||||
void DrawPageText(IRenderer* pRenderer, double* pdCoords, const std::wstring& wsText);
|
void DrawPageText(IRenderer* pRenderer, double* pdCoords, const std::wstring& wsText);
|
||||||
void ParseCoords(const std::wstring& wsCoordsStr, double* pdCoords, double dKoef);
|
void ParseCoords(const std::wstring& wsCoordsStr, double* pdCoords, double dKoef);
|
||||||
|
|||||||
@ -167,11 +167,11 @@
|
|||||||
for (let i = 0; i < _Word.length; i++)
|
for (let i = 0; i < _Word.length; i++)
|
||||||
{
|
{
|
||||||
this.pages[pageIndex].Lines[Line].Glyphs.push({
|
this.pages[pageIndex].Lines[Line].Glyphs.push({
|
||||||
X : (_X + _W / _Word.length * i) * 1.015,
|
X : _X + _W / (_Word.length - 1) * i,
|
||||||
UChar : _Word[i]
|
UChar : _Word[i]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y * 1.015;
|
this.pages[pageIndex].Lines[Line].Glyphs[0].Y = _Y + _H;
|
||||||
this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H;
|
this.pages[pageIndex].Lines[Line].Glyphs[0].fontSize = _H;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user