mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
change origin to top left corner
only in xps format the canvas sizes are multiplied
This commit is contained in:
@ -242,8 +242,8 @@
|
||||
this.pages[pageIndex].Lines[Line].Glyphs.push({
|
||||
fontName : _fontName,
|
||||
fontSize : _fontSize,
|
||||
X : _X * 1.015,
|
||||
Y : _Y * 1.015,
|
||||
X : _X,
|
||||
Y : _Y,
|
||||
UChar : String.fromCharCode(_Char)
|
||||
});
|
||||
}
|
||||
@ -297,8 +297,8 @@
|
||||
var rec = {};
|
||||
rec["link"] = reader.readString();
|
||||
rec["dest"] = reader.readDouble();
|
||||
rec["x"] = (this.type == 2 ? 1.015 : 1) * reader.readDouble();
|
||||
rec["y"] = (this.type == 2 ? 1.015 : 1) * reader.readDouble();
|
||||
rec["x"] = reader.readDouble();
|
||||
rec["y"] = reader.readDouble();
|
||||
rec["w"] = reader.readDouble();
|
||||
rec["h"] = reader.readDouble();
|
||||
res.push(rec);
|
||||
|
||||
@ -153,7 +153,7 @@ int main()
|
||||
BYTE* pPdfData = NULL;
|
||||
DWORD nPdfBytesCount;
|
||||
NSFile::CFileBinary oFile;
|
||||
if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test3.pdf", &pPdfData, nPdfBytesCount))
|
||||
if (!oFile.ReadAllBytes(NSFile::GetProcessDirectory() + L"/test.pdf", &pPdfData, nPdfBytesCount))
|
||||
{
|
||||
RELEASEARRAYOBJECTS(pPdfData);
|
||||
return 1;
|
||||
@ -168,7 +168,7 @@ int main()
|
||||
}
|
||||
int* info = GetInfo(test);
|
||||
int pages_count = *info;
|
||||
int test_page = 1;
|
||||
int test_page = 2;
|
||||
int width = info[test_page * 3 + 1];
|
||||
int height = info[test_page * 3 + 2];
|
||||
std::cout << "Page " << test_page << " width " << width << " height " << height << std::endl;
|
||||
@ -319,8 +319,6 @@ int main()
|
||||
int width = info[test_page * 3 + 1];
|
||||
int height = info[test_page * 3 + 2];
|
||||
std::cout << "Page " << test_page << " width " << width << " height " << height << std::endl;
|
||||
width *= 96.0 / (double)info[test_page * 3 + 3];
|
||||
height *= 96.0 / (double)info[test_page * 3 + 3];
|
||||
|
||||
BYTE* res = NULL;
|
||||
if (pages_count > 0)
|
||||
@ -452,8 +450,6 @@ int main()
|
||||
int width = info[test_page * 3 + 1];
|
||||
int height = info[test_page * 3 + 2];
|
||||
std::cout << "Page " << test_page << " width " << width << " height " << height << std::endl;
|
||||
width *= 96.0 / (double)info[test_page * 3 + 3];
|
||||
height *= 96.0 / (double)info[test_page * 3 + 3];
|
||||
|
||||
BYTE* res = NULL;
|
||||
if (pages_count > 0)
|
||||
|
||||
@ -13,20 +13,24 @@ class CGraphicsFileDrawing
|
||||
private:
|
||||
IOfficeDrawingFile* pReader;
|
||||
NSFonts::IApplicationFonts* pApplicationFonts;
|
||||
int nType;
|
||||
public:
|
||||
CGraphicsFileDrawing(NSFonts::IApplicationFonts* pFonts)
|
||||
{
|
||||
pReader = NULL;
|
||||
pApplicationFonts = pFonts;
|
||||
pApplicationFonts->AddRef();
|
||||
nType = -1;
|
||||
}
|
||||
~CGraphicsFileDrawing()
|
||||
{
|
||||
RELEASEOBJECT(pReader);
|
||||
RELEASEINTERFACE(pApplicationFonts);
|
||||
nType = -1;
|
||||
}
|
||||
bool Open (BYTE* data, DWORD length, int nType, const char* password = NULL)
|
||||
bool Open (BYTE* data, DWORD length, int _nType, const char* password = NULL)
|
||||
{
|
||||
nType = _nType;
|
||||
if (nType == 0)
|
||||
pReader = new PdfReader::CPdfReader(pApplicationFonts);
|
||||
else if (nType == 1)
|
||||
@ -52,6 +56,11 @@ public:
|
||||
double dPageDpiX, dPageDpiY;
|
||||
double dWidth, dHeight;
|
||||
pReader->GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
if (nType == 2)
|
||||
{
|
||||
dWidth = dWidth / 25.4 * 96.0;
|
||||
dHeight = dHeight / 25.4 * 96.0;
|
||||
}
|
||||
nWidth = dWidth;
|
||||
nHeight = dHeight;
|
||||
nPageDpiX = dPageDpiX;
|
||||
|
||||
@ -465,14 +465,14 @@ BYTE* CDjVuFileImplementation::GetPageLinks (int nPageIndex)
|
||||
{
|
||||
GUTF8String str = map_areas[pos]->url;
|
||||
oRes.WriteString((BYTE*)str.getbuf(), str.length());
|
||||
|
||||
// Верхний левый угол
|
||||
double x = map_areas[pos]->get_xmin();
|
||||
double y = dHeight - map_areas[pos]->get_ymin();
|
||||
double y = dHeight - map_areas[pos]->get_ymax();
|
||||
oRes.AddDouble(0.0);
|
||||
oRes.AddDouble(x);
|
||||
oRes.AddDouble(y);
|
||||
oRes.AddDouble(map_areas[pos]->get_xmax() - x);
|
||||
oRes.AddDouble(dHeight - map_areas[pos]->get_ymax() - y);
|
||||
oRes.AddDouble(map_areas[pos]->get_ymax() - map_areas[pos]->get_ymin());
|
||||
}
|
||||
oRes.WriteLen();
|
||||
|
||||
|
||||
@ -679,7 +679,7 @@ return 0;
|
||||
continue;
|
||||
|
||||
GString* str = NULL;
|
||||
double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
|
||||
double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0, dy = 0.0;
|
||||
pLink->getRect(&x1, &y1, &x2, &y2);
|
||||
double height = m_pInternal->m_pPDFDocument->getPageCropHeight(nPageIndex);
|
||||
y1 = height - y1;
|
||||
@ -705,6 +705,7 @@ return 0;
|
||||
pg = pLinkDest->getPageNum();
|
||||
std::string sLink = "#" + std::to_string(pg - 1);
|
||||
str = new GString(sLink.c_str());
|
||||
dy = m_pInternal->m_pPDFDocument->getPageCropHeight(pg) - pLinkDest->getTop();
|
||||
}
|
||||
RELEASEOBJECT(pLinkDest);
|
||||
}
|
||||
@ -715,11 +716,12 @@ return 0;
|
||||
oRes.WriteString((BYTE*)str->getCString(), str->getLength());
|
||||
else
|
||||
oRes.WriteString(NULL, 0);
|
||||
oRes.AddDouble(0.0);
|
||||
// Верхний левый угол
|
||||
oRes.AddDouble(dy);
|
||||
oRes.AddDouble(x1);
|
||||
oRes.AddDouble(y1);
|
||||
oRes.AddDouble(y2);
|
||||
oRes.AddDouble(x2 - x1);
|
||||
oRes.AddDouble(y2 - y1);
|
||||
oRes.AddDouble(y1 - y2);
|
||||
RELEASEOBJECT(str);
|
||||
}
|
||||
oRes.WriteLen();
|
||||
|
||||
@ -713,10 +713,12 @@ namespace XPS
|
||||
m_pGlyphs = new NSWasm::CData();
|
||||
m_pGlyphs->SkipLen();
|
||||
}
|
||||
|
||||
double pdA, pdB, pdC, pdD, pdE, pdF;
|
||||
pRenderer->GetTransform(&pdA, &pdB, &pdC, &pdD, &pdE, &pdF);
|
||||
Aggplus::CMatrix oTransform(pdA, pdB, pdC, pdD, pdE, pdF);
|
||||
std::string sFontName = U_TO_UTF8(m_pFontManager->GetName());
|
||||
m_pGlyphs->WriteString((BYTE*)sFontName.c_str(), sFontName.length());
|
||||
m_pGlyphs->AddDouble(dFontSize);
|
||||
m_pGlyphs->AddDouble(dFontSize * pdA + pdE);
|
||||
m_pGlyphs->AddInt(unUtf16Len);
|
||||
#endif
|
||||
|
||||
@ -752,8 +754,12 @@ namespace XPS
|
||||
}
|
||||
|
||||
#ifdef BUILDING_WASM_MODULE
|
||||
m_pGlyphs->AddDouble(dXorigin);
|
||||
m_pGlyphs->AddDouble(dYorigin);
|
||||
double _dX = dXorigin;
|
||||
double _dY = dYorigin;
|
||||
oTransform.TransformPoint(_dX, _dY);
|
||||
// Верхний левый угол
|
||||
m_pGlyphs->AddDouble(_dX);
|
||||
m_pGlyphs->AddDouble(_dY - dFontSize * pdA + pdE);
|
||||
m_pGlyphs->AddInt(oEntry.nUnicode);
|
||||
m_pGlyphs->WriteLen();
|
||||
#endif
|
||||
@ -984,6 +990,9 @@ namespace XPS
|
||||
}
|
||||
else if (L"FixedPage.NavigateUri" == wsAttrName)
|
||||
{
|
||||
double pdA, pdB, pdC, pdD, pdE, pdF;
|
||||
pRenderer->GetTransform(&pdA, &pdB, &pdC, &pdD, &pdE, &pdF);
|
||||
Aggplus::CMatrix oTransform(pdA, pdB, pdC, pdD, pdE, pdF);
|
||||
double x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
|
||||
|
||||
CPageLink oLink = {0, 0, 0, 0, ""};
|
||||
@ -1000,6 +1009,7 @@ namespace XPS
|
||||
size_t nFindEndY = wsPath.find(L' ', nFindY);
|
||||
if (nFindEndY != std::wstring::npos)
|
||||
y1 = GetDouble(wsPath.substr(nFindY, nFindEndY - nFindY));
|
||||
oTransform.TransformPoint(x1, y1);
|
||||
}
|
||||
}
|
||||
nFindX = wsPath.find(L"L ");
|
||||
@ -1014,6 +1024,7 @@ namespace XPS
|
||||
size_t nFindEndY = wsPath.find(L' ', nFindY);
|
||||
if (nFindEndY != std::wstring::npos)
|
||||
y2 = GetDouble(wsPath.substr(nFindY, nFindEndY - nFindY));
|
||||
oTransform.TransformPoint(x2, y2);
|
||||
}
|
||||
}
|
||||
nFindX = wsPath.find(L"L ", nFindX);
|
||||
@ -1028,8 +1039,10 @@ namespace XPS
|
||||
size_t nFindEndY = wsPath.find(L' ', nFindY);
|
||||
if (nFindEndY != std::wstring::npos)
|
||||
y3 = GetDouble(wsPath.substr(nFindY, nFindEndY - nFindY));
|
||||
oTransform.TransformPoint(x3, y3);
|
||||
}
|
||||
}
|
||||
// Верхний левый угол
|
||||
oLink.dX = x1 == x2 ? fmin(x1, x3) : fmin(x1, x2);
|
||||
oLink.dY = y1 == y2 ? fmin(y1, y3) : fmin(y1, y2);
|
||||
oLink.dH = x1 == x2 ? abs(y1 - y2) : abs(y1 - y3);
|
||||
|
||||
Reference in New Issue
Block a user