mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Test split with changes
This commit is contained in:
@ -1548,10 +1548,8 @@ bool CPdfEditor::EditPage(int _nPageIndex, bool bSet, bool bActualPos)
|
||||
}
|
||||
bool CPdfEditor::SplitPages(const int* arrPageIndex, unsigned int unLength, PDFDoc* _pDoc, int nStartRefID)
|
||||
{
|
||||
if (m_nMode == Mode::WriteNew)
|
||||
return false;
|
||||
if (m_nMode == Mode::Unknown)
|
||||
m_nMode = Mode::WriteNew;
|
||||
return false;
|
||||
PDFDoc* pPDFDocument = _pDoc;
|
||||
XRef* xref = pPDFDocument->getXRef();
|
||||
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
||||
@ -1913,8 +1911,10 @@ bool CPdfEditor::SplitPages(const int* arrPageIndex, unsigned int unLength, PDFD
|
||||
}
|
||||
bool CPdfEditor::SplitPages(const int* arrPageIndex, unsigned int unLength)
|
||||
{
|
||||
if (m_nMode != Mode::Unknown)
|
||||
if (m_nMode == Mode::WriteNew)
|
||||
return false;
|
||||
if (m_nMode == Mode::Unknown)
|
||||
m_nMode = Mode::WriteNew;
|
||||
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
||||
if (!pDoc)
|
||||
return false;
|
||||
@ -2675,7 +2675,7 @@ bool CPdfEditor::DeleteAnnot(int nID, Object* oAnnots)
|
||||
}
|
||||
bool CPdfEditor::EditWidgets(IAdvancedCommand* pCommand)
|
||||
{
|
||||
if (m_nMode != Mode::WriteAppend && !IncrementalUpdates())
|
||||
if (m_nMode == Mode::Unknown && !IncrementalUpdates())
|
||||
return false;
|
||||
|
||||
CWidgetsInfo* pFieldInfo = (CWidgetsInfo*)pCommand;
|
||||
|
||||
@ -355,11 +355,39 @@ TEST_F(CPdfFileTest, SplitPdf)
|
||||
//GTEST_SKIP();
|
||||
|
||||
LoadFromFile();
|
||||
std::vector<int> arrPages = { 0, 1, 2 };
|
||||
BYTE* pFile = pdfFile->SplitPages(arrPages.data(), arrPages.size());
|
||||
|
||||
int nBufferLen = NULL;
|
||||
BYTE* pBuffer = NULL;
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.OpenFile(NSFile::GetProcessDirectory() + L"/base64.txt"))
|
||||
{
|
||||
DWORD dwFileSize = oFile.GetFileSize();
|
||||
BYTE* pFileContent = new BYTE[dwFileSize];
|
||||
if (!pFileContent)
|
||||
{
|
||||
oFile.CloseFile();
|
||||
FAIL();
|
||||
}
|
||||
|
||||
DWORD dwReaded;
|
||||
EXPECT_TRUE(oFile.ReadFile(pFileContent, dwFileSize, dwReaded));
|
||||
|
||||
nBufferLen = NSBase64::Base64DecodeGetRequiredLength(dwFileSize);
|
||||
pBuffer = new BYTE[nBufferLen];
|
||||
if (!pBuffer)
|
||||
{
|
||||
RELEASEARRAYOBJECTS(pFileContent);
|
||||
FAIL();
|
||||
}
|
||||
|
||||
EXPECT_TRUE(NSBase64::Base64Decode((const char*)pFileContent, dwFileSize, pBuffer, &nBufferLen));
|
||||
}
|
||||
oFile.CloseFile();
|
||||
|
||||
std::vector<int> arrPages = { 1 };
|
||||
BYTE* pFile = pdfFile->SplitPages(arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
ASSERT_TRUE(pFile != NULL);
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
std::wstring wsSplitFile = NSFile::GetProcessDirectory() + L"/test_split.pdf";
|
||||
if (oFile.CreateFileW(wsSplitFile))
|
||||
{
|
||||
@ -369,6 +397,7 @@ TEST_F(CPdfFileTest, SplitPdf)
|
||||
oFile.CloseFile();
|
||||
|
||||
RELEASEARRAYOBJECTS(pFile);
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
}
|
||||
|
||||
TEST_F(CPdfFileTest, MergePdf)
|
||||
|
||||
Reference in New Issue
Block a user