mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
draw AP widget
This commit is contained in:
@ -368,10 +368,10 @@
|
||||
Module["_free"](ext);
|
||||
return res;
|
||||
};
|
||||
CFile.prototype["getInteractiveForms"] = function()
|
||||
CFile.prototype["getInteractiveForms"] = function(pageIndex, width, height)
|
||||
{
|
||||
var res = [];
|
||||
var ext = Module["_GetInteractiveForms"](this.nativeFile);
|
||||
var ext = Module["_GetInteractiveForms"](this.nativeFile, pageIndex, width, height);
|
||||
if (ext == 0)
|
||||
return res;
|
||||
|
||||
@ -401,8 +401,7 @@
|
||||
rec["locked"] = rec["annotflag"] & (1 << 7); // Locked
|
||||
rec["lockedC"] = rec["annotflag"] & (1 << 9); // LockedContents
|
||||
|
||||
rec["name"] = reader.readString();
|
||||
rec["page"] = reader.readInt();
|
||||
rec["name"] = reader.readString();
|
||||
// Необходимо смещение полученных координат как у getStructure и viewer.navigate
|
||||
rec["x1"] = reader.readDouble();
|
||||
rec["y1"] = reader.readDouble();
|
||||
|
||||
@ -183,6 +183,15 @@ int READ_INT(BYTE* x)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
/* тест сериализации указателя - 8 байт на x64
|
||||
int* p = new int;
|
||||
*p = 15;
|
||||
|
||||
std::cout << p << std::endl;
|
||||
std::cout << *p << std::endl;
|
||||
delete p;
|
||||
*/
|
||||
|
||||
// CHECK SYSTEM FONTS
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include "./Graphics.h"
|
||||
|
||||
CBgraFrame* GetFrame(IOfficeDrawingFile* pFile, int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip, bool bIsSwapRGB,
|
||||
NSFonts::IFontManager* pFonts = NULL, int nBackgroundColor = 0xFFFFFF, bool bIsDarkMode = false)
|
||||
NSFonts::IFontManager* pFonts = NULL, int nBackgroundColor = 0xFFFFFF, bool bIsDarkMode = false, int nBackgroundOpacity = 0xFF)
|
||||
{
|
||||
NSFonts::IFontManager *pFontManager = pFonts;
|
||||
|
||||
@ -79,7 +79,7 @@ CBgraFrame* GetFrame(IOfficeDrawingFile* pFile, int nPageIndex, int nRasterW, in
|
||||
else
|
||||
{
|
||||
unsigned int nColor = (unsigned int)nBackgroundColor;
|
||||
nColor = 0xFF000000 | nColor;
|
||||
nColor = (nBackgroundOpacity << 24) | nColor;
|
||||
|
||||
unsigned int nSize = (unsigned int)(nWidth * nHeight);
|
||||
unsigned int* pTemp = (unsigned int*)pBgraData;
|
||||
@ -118,9 +118,9 @@ CBgraFrame* GetFrame(IOfficeDrawingFile* pFile, int nPageIndex, int nRasterW, in
|
||||
}
|
||||
|
||||
unsigned char* IOfficeDrawingFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH,
|
||||
bool bIsFlip, NSFonts::IFontManager* pFonts, int nBackgroundColor, bool bIsDarkMode)
|
||||
bool bIsFlip, NSFonts::IFontManager* pFonts, int nBackgroundColor, bool bIsDarkMode, int nBackgroundOpacity)
|
||||
{
|
||||
CBgraFrame* pFrame = GetFrame(this, nPageIndex, nRasterW, nRasterH, bIsFlip, true, pFonts, nBackgroundColor, bIsDarkMode);
|
||||
CBgraFrame* pFrame = GetFrame(this, nPageIndex, nRasterW, nRasterH, bIsFlip, true, pFonts, nBackgroundColor, bIsDarkMode, nBackgroundOpacity);
|
||||
if (!pFrame)
|
||||
return NULL;
|
||||
|
||||
@ -132,9 +132,9 @@ unsigned char* IOfficeDrawingFile::ConvertToPixels(int nPageIndex, int nRasterW,
|
||||
}
|
||||
|
||||
void IOfficeDrawingFile::ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW, const int nRasterH,
|
||||
bool bIsFlip, NSFonts::IFontManager* pFonts, int nBackgroundColor, bool bIsDarkMode)
|
||||
bool bIsFlip, NSFonts::IFontManager* pFonts, int nBackgroundColor, bool bIsDarkMode, int nBackgroundOpacity)
|
||||
{
|
||||
CBgraFrame* pFrame = GetFrame(this, nPageIndex, nRasterW, nRasterH, bIsFlip, false, pFonts, nBackgroundColor, bIsDarkMode);
|
||||
CBgraFrame* pFrame = GetFrame(this, nPageIndex, nRasterW, nRasterH, bIsFlip, false, pFonts, nBackgroundColor, bIsDarkMode, nBackgroundOpacity);
|
||||
if (!pFrame)
|
||||
return;
|
||||
|
||||
|
||||
@ -77,12 +77,14 @@ public:
|
||||
bool bIsFlip = false,
|
||||
NSFonts::IFontManager* pFonts = NULL,
|
||||
int nBackgroundColor = 0xFFFFFF,
|
||||
bool bIsDarkMode = false);
|
||||
bool bIsDarkMode = false,
|
||||
int nBackgroundOpacity = 0xFF);
|
||||
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1,
|
||||
bool bIsFlip = false,
|
||||
NSFonts::IFontManager* pFonts = NULL,
|
||||
int nBackgroundColor = 0xFFFFFF,
|
||||
bool bIsDarkMode = false);
|
||||
bool bIsDarkMode = false,
|
||||
int nBackgroundOpacity = 0xFF);
|
||||
|
||||
// Common methods for viewer
|
||||
virtual std::wstring GetInfo() = 0;
|
||||
|
||||
@ -735,7 +735,7 @@ BYTE* CPdfReader::GetWidgets(int nPageIndex, int nRasterW, int nRasterH)
|
||||
globalParams->setDrawAnnotations(gFalse);
|
||||
globalParams->setDrawFormFields(gTrue);
|
||||
|
||||
BYTE* pPixData = m_pRenderer->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, 0, false);
|
||||
BYTE* pPixData = m_pRenderer->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, 0, false, 0);
|
||||
|
||||
globalParams->setDrawContent(bDrawContent);
|
||||
globalParams->setDrawAnnotations(bDrawAnnotations);
|
||||
@ -783,10 +783,42 @@ BYTE* CPdfReader::GetWidgets(int nPageIndex, int nRasterW, int nRasterH)
|
||||
double dx1, dy1, dx2, dy2;
|
||||
pField->getBBox(&dx1, &dy1, &dx2, &dy2);
|
||||
double height = m_pPDFDocument->getPageCropHeight(nPageIndex + 1);
|
||||
double width = m_pPDFDocument->getPageCropWidth (nPageIndex + 1);
|
||||
double dTemp = dy1;
|
||||
dy1 = height - dy2;
|
||||
dy2 = height - dTemp;
|
||||
oRes.AddDouble(dx1);
|
||||
oRes.AddDouble(height - dy1);
|
||||
oRes.AddDouble(dy1);
|
||||
oRes.AddDouble(dx2);
|
||||
oRes.AddDouble(height - dy2);
|
||||
oRes.AddDouble(dy2);
|
||||
|
||||
// Получение пикселей внешнего вида виджета
|
||||
int nRx1 = dx1 * (double)nRasterW / width;
|
||||
int nRx2 = dx2 * (double)nRasterW / width + 1;
|
||||
int nRy1 = dy1 * (double)nRasterH / height;
|
||||
int nRy2 = dy2 * (double)nRasterH / height + 1;
|
||||
if (nRx1 < 0) nRx1 = 0;
|
||||
if (nRy1 < 0) nRy1 = 0;
|
||||
if (nRx2 > nRasterW) nRx1 = nRasterW;
|
||||
if (nRy2 > nRasterH) nRy1 = nRasterH;
|
||||
|
||||
BYTE* pSubMatrix = new BYTE[(nRx2 - nRx1) * (nRy2 - nRy1) * 4];
|
||||
int p = 0;
|
||||
unsigned int* pTemp = (unsigned int*)pPixData;
|
||||
unsigned int* pSubTemp = (unsigned int*)pSubMatrix;
|
||||
for (int y = nRy1; y < nRy2; ++y)
|
||||
for (int x = nRx1; x < nRx2; ++x)
|
||||
pSubTemp[p++] = pTemp[y * nRasterW + x];
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pSubMatrix);
|
||||
oFrame.put_Width(nRx2 - nRx1);
|
||||
oFrame.put_Height(nRy2 - nRy1);
|
||||
oFrame.put_Stride(4 * (nRx2 - nRx1));
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.SaveFile(NSFile::GetProcessDirectory() + L"/res3.png", _CXIMAGE_FORMAT_PNG);
|
||||
oFrame.ClearNoAttack();
|
||||
RELEASEARRAYOBJECTS(pSubMatrix);
|
||||
|
||||
// Выравнивание текста - Q
|
||||
Object oQ;
|
||||
|
||||
Reference in New Issue
Block a user