mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Add nStartRefID to Editor
This commit is contained in:
@ -216,11 +216,13 @@ namespace NSOnlineOfficeBinToPdf
|
|||||||
std::wstring wsPath = oReader.ReadString();
|
std::wstring wsPath = oReader.ReadString();
|
||||||
std::wstring wsPassword = oReader.ReadString();
|
std::wstring wsPassword = oReader.ReadString();
|
||||||
int nLength = oReader.ReadInt();
|
int nLength = oReader.ReadInt();
|
||||||
int* pPageIndex = new int[nLength];
|
int* pPageIndex = NULL;
|
||||||
|
if (nLength > 0)
|
||||||
|
pPageIndex = new int[nLength];
|
||||||
for (int i = 0; i < nLength; ++i)
|
for (int i = 0; i < nLength; ++i)
|
||||||
pPageIndex[i] = oReader.ReadInt();
|
pPageIndex[i] = oReader.ReadInt();
|
||||||
pPdf->MergePages(wsPath, wsPassword, pPageIndex, nLength);
|
pPdf->MergePages(wsPath, wsPassword, pPageIndex, nLength);
|
||||||
delete[] pPageIndex;
|
RELEASEARRAYOBJECTS(pPageIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AddCommandType::WidgetInfo:
|
case AddCommandType::WidgetInfo:
|
||||||
|
|||||||
@ -349,11 +349,11 @@ PdfWriter::CObjectBase* DictToCDictObject2(Object* obj, PdfWriter::CDocument* pD
|
|||||||
|
|
||||||
return pBase;
|
return pBase;
|
||||||
}
|
}
|
||||||
PdfWriter::CDictObject* GetWidgetParent(PDFDoc* pdfDoc, PdfWriter::CDocument* pDoc, Object* pParentRef)
|
PdfWriter::CDictObject* GetWidgetParent(PDFDoc* pdfDoc, PdfWriter::CDocument* pDoc, Object* pParentRef, int nStartRefID)
|
||||||
{
|
{
|
||||||
if (!pParentRef || !pParentRef->isRef() || !pdfDoc)
|
if (!pParentRef || !pParentRef->isRef() || !pdfDoc)
|
||||||
return NULL;
|
return NULL;
|
||||||
PdfWriter::CDictObject* pParent = pDoc->GetParent(pParentRef->getRefNum());
|
PdfWriter::CDictObject* pParent = pDoc->GetParent(pParentRef->getRefNum() + nStartRefID);
|
||||||
if (pParent)
|
if (pParent)
|
||||||
return pParent;
|
return pParent;
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ PdfWriter::CDictObject* GetWidgetParent(PDFDoc* pdfDoc, PdfWriter::CDocument* pD
|
|||||||
PdfWriter::CXref* pXref = new PdfWriter::CXref(pDoc, pParentRef->getRefNum());
|
PdfWriter::CXref* pXref = new PdfWriter::CXref(pDoc, pParentRef->getRefNum());
|
||||||
pParent = new PdfWriter::CDictObject();
|
pParent = new PdfWriter::CDictObject();
|
||||||
pXref->Add(pParent, pParentRef->getRefGen());
|
pXref->Add(pParent, pParentRef->getRefGen());
|
||||||
if (!pDoc->EditParent(pXref, pParent, pParentRef->getRefNum()))
|
if (!pDoc->EditParent(pXref, pParent, pParentRef->getRefNum() + nStartRefID))
|
||||||
{
|
{
|
||||||
RELEASEOBJECT(pXref);
|
RELEASEOBJECT(pXref);
|
||||||
oParent.free();
|
oParent.free();
|
||||||
@ -381,7 +381,7 @@ PdfWriter::CDictObject* GetWidgetParent(PDFDoc* pdfDoc, PdfWriter::CDocument* pD
|
|||||||
{
|
{
|
||||||
Object oParentRef;
|
Object oParentRef;
|
||||||
oParent.dictGetValNF(i, &oParentRef);
|
oParent.dictGetValNF(i, &oParentRef);
|
||||||
PdfWriter::CDictObject* pParent2 = GetWidgetParent(pdfDoc, pDoc, &oParentRef);
|
PdfWriter::CDictObject* pParent2 = GetWidgetParent(pdfDoc, pDoc, &oParentRef, nStartRefID);
|
||||||
if (pParent2)
|
if (pParent2)
|
||||||
{
|
{
|
||||||
pParent->Add("Parent", pParent2);
|
pParent->Add("Parent", pParent2);
|
||||||
@ -1633,10 +1633,11 @@ BYTE* CPdfEditor::SplitPages(const int* arrPageIndex, unsigned int unLength)
|
|||||||
RELEASEARRAYOBJECTS(pRes);
|
RELEASEARRAYOBJECTS(pRes);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
bool CPdfEditor::MergePages(PDFDoc* pDocument, const int* arrPageIndex, unsigned int unLength)
|
bool CPdfEditor::MergePages(const int* arrPageIndex, unsigned int unLength)
|
||||||
{
|
{
|
||||||
if (m_nMode != Mode::WriteAppend && !IncrementalUpdates())
|
if (m_nMode != Mode::WriteAppend && !IncrementalUpdates())
|
||||||
return false;
|
return false;
|
||||||
|
PDFDoc* pDocument = m_pReader->GetLastPDFDocument();
|
||||||
int nPagesBefore = m_pReader->GetNumPages() - pDocument->getNumPages();
|
int nPagesBefore = m_pReader->GetNumPages() - pDocument->getNumPages();
|
||||||
bool bRes = SplitPages(arrPageIndex, unLength, pDocument);
|
bool bRes = SplitPages(arrPageIndex, unLength, pDocument);
|
||||||
if (!bRes)
|
if (!bRes)
|
||||||
@ -1668,7 +1669,7 @@ bool CPdfEditor::DeletePage(int nPageIndex)
|
|||||||
}
|
}
|
||||||
bool CPdfEditor::AddPage(int nPageIndex)
|
bool CPdfEditor::AddPage(int nPageIndex)
|
||||||
{
|
{
|
||||||
if (m_nMode != Mode::WriteAppend && !IncrementalUpdates())
|
if (m_nMode == Mode::Unknown)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Применение добавления страницы для writer
|
// Применение добавления страницы для writer
|
||||||
@ -1699,7 +1700,8 @@ bool CPdfEditor::EditAnnot(int _nPageIndex, int nID)
|
|||||||
{
|
{
|
||||||
PDFDoc* pPDFDocument = NULL;
|
PDFDoc* pPDFDocument = NULL;
|
||||||
PdfReader::CPdfFontList* pFontList = NULL;
|
PdfReader::CPdfFontList* pFontList = NULL;
|
||||||
int nPageIndex = m_pReader->GetPageIndex(_nPageIndex, &pPDFDocument, &pFontList);
|
int nStartRefID = 0;
|
||||||
|
int nPageIndex = m_pReader->GetPageIndex(_nPageIndex, &pPDFDocument, &pFontList, &nStartRefID);
|
||||||
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
||||||
if (nPageIndex < 0 || !pPDFDocument || !pDoc)
|
if (nPageIndex < 0 || !pPDFDocument || !pDoc)
|
||||||
return false;
|
return false;
|
||||||
@ -1722,7 +1724,7 @@ bool CPdfEditor::EditAnnot(int _nPageIndex, int nID)
|
|||||||
Object oAnnotRef, oAnnot, oType;
|
Object oAnnotRef, oAnnot, oType;
|
||||||
for (int i = 0; i < oAnnots.arrayGetLength(); ++i)
|
for (int i = 0; i < oAnnots.arrayGetLength(); ++i)
|
||||||
{
|
{
|
||||||
if (oAnnots.arrayGetNF(i, &oAnnotRef)->isRef() && oAnnotRef.getRefNum() == nID)
|
if (oAnnots.arrayGetNF(i, &oAnnotRef)->isRef() && oAnnotRef.getRefNum() + nStartRefID == nID)
|
||||||
break;
|
break;
|
||||||
oAnnotRef.free();
|
oAnnotRef.free();
|
||||||
}
|
}
|
||||||
@ -1857,9 +1859,9 @@ bool CPdfEditor::EditAnnot(int _nPageIndex, int nID)
|
|||||||
if (!strcmp("Popup", chKey))
|
if (!strcmp("Popup", chKey))
|
||||||
{
|
{
|
||||||
Object oPopupRef;
|
Object oPopupRef;
|
||||||
if (oAnnot.dictGetValNF(nIndex, &oPopupRef)->isRef() && EditAnnot(nPageIndex, oPopupRef.getRefNum()))
|
if (oAnnot.dictGetValNF(nIndex, &oPopupRef)->isRef() && EditAnnot(nPageIndex, oPopupRef.getRefNum() + nStartRefID))
|
||||||
{
|
{
|
||||||
PdfWriter::CAnnotation* pPopup = pDoc->GetAnnot(oPopupRef.getRefNum());
|
PdfWriter::CAnnotation* pPopup = pDoc->GetAnnot(oPopupRef.getRefNum() + nStartRefID);
|
||||||
if (pPopup)
|
if (pPopup)
|
||||||
{
|
{
|
||||||
pAnnot->Add("Popup", pPopup);
|
pAnnot->Add("Popup", pPopup);
|
||||||
@ -1872,7 +1874,7 @@ bool CPdfEditor::EditAnnot(int _nPageIndex, int nID)
|
|||||||
{
|
{
|
||||||
Object oParentRef;
|
Object oParentRef;
|
||||||
oAnnot.dictGetValNF(nIndex, &oParentRef);
|
oAnnot.dictGetValNF(nIndex, &oParentRef);
|
||||||
PdfWriter::CDictObject* pParent = GetWidgetParent(pPDFDocument, pDoc, &oParentRef);
|
PdfWriter::CDictObject* pParent = GetWidgetParent(pPDFDocument, pDoc, &oParentRef, nStartRefID);
|
||||||
|
|
||||||
if (!pParent)
|
if (!pParent)
|
||||||
{
|
{
|
||||||
@ -2021,7 +2023,6 @@ bool CPdfEditor::EditWidgets(IAdvancedCommand* pCommand)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
CWidgetsInfo* pFieldInfo = (CWidgetsInfo*)pCommand;
|
CWidgetsInfo* pFieldInfo = (CWidgetsInfo*)pCommand;
|
||||||
PDFDoc* pPDFDocument = m_pReader->GetPDFDocument(0);
|
|
||||||
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
||||||
|
|
||||||
std::vector<CWidgetsInfo::CParent*> arrParents = pFieldInfo->GetParents();
|
std::vector<CWidgetsInfo::CParent*> arrParents = pFieldInfo->GetParents();
|
||||||
@ -2031,10 +2032,16 @@ bool CPdfEditor::EditWidgets(IAdvancedCommand* pCommand)
|
|||||||
if (pDParent)
|
if (pDParent)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
PDFDoc* pPDFDocument = NULL;
|
||||||
|
int nStartRefID = 0;
|
||||||
|
int nRefID = m_pReader->FindRefNum(pParent->nID, &pPDFDocument, &nStartRefID);
|
||||||
|
if (nRefID < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
Object oParentRef;
|
Object oParentRef;
|
||||||
// TODO узнать gen родителя
|
// TODO узнать gen родителя
|
||||||
oParentRef.initRef(pParent->nID, 0);
|
oParentRef.initRef(nRefID, 0);
|
||||||
GetWidgetParent(pPDFDocument, pDoc, &oParentRef);
|
GetWidgetParent(pPDFDocument, pDoc, &oParentRef, nStartRefID);
|
||||||
// TODO перевыставить детей
|
// TODO перевыставить детей
|
||||||
oParentRef.free();
|
oParentRef.free();
|
||||||
}
|
}
|
||||||
@ -2132,9 +2139,9 @@ bool CPdfEditor::IsBase14(const std::wstring& wsFontName, bool& bBold, bool& bIt
|
|||||||
if (wsFontPath.empty())
|
if (wsFontPath.empty())
|
||||||
{
|
{
|
||||||
std::map<std::wstring, std::wstring> mFonts = m_pReader->GetFonts();
|
std::map<std::wstring, std::wstring> mFonts = m_pReader->GetFonts();
|
||||||
std::map<std::wstring, std::wstring>::iterator it2 = mFonts.find(wsFontName);
|
it = mFonts.find(wsFontName);
|
||||||
if (it2 != mFonts.end())
|
if (it != mFonts.end())
|
||||||
wsFontPath = it2->second;
|
wsFontPath = it->second;
|
||||||
}
|
}
|
||||||
if (wsFontPath.empty())
|
if (wsFontPath.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public:
|
|||||||
|
|
||||||
BYTE* SplitPages(const int* arrPageIndex, unsigned int unLength);
|
BYTE* SplitPages(const int* arrPageIndex, unsigned int unLength);
|
||||||
bool SplitPages(const int* arrPageIndex, unsigned int unLength, PDFDoc* _pDoc);
|
bool SplitPages(const int* arrPageIndex, unsigned int unLength, PDFDoc* _pDoc);
|
||||||
bool MergePages(PDFDoc* pDoc, const int* arrPageIndex, unsigned int unLength);
|
bool MergePages(const int* arrPageIndex, unsigned int unLength);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GetPageTree(XRef* xref, Object* pPagesRefObj, PdfWriter::CPageTree* pPageParent = NULL);
|
void GetPageTree(XRef* xref, Object* pPagesRefObj, PdfWriter::CPageTree* pPageParent = NULL);
|
||||||
|
|||||||
@ -140,9 +140,8 @@ bool CPdfFile::MergePages(const std::wstring& wsPath, const std::wstring& wsPass
|
|||||||
{
|
{
|
||||||
if (!m_pInternal->pEditor)
|
if (!m_pInternal->pEditor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_pInternal->pReader->MergePages(wsPath, wsPassword))
|
if (m_pInternal->pReader->MergePages(wsPath, wsPassword))
|
||||||
return m_pInternal->pEditor->MergePages(m_pInternal->pReader->GetLastPDFDocument(), arrPageIndex, unLength);
|
return m_pInternal->pEditor->MergePages(arrPageIndex, unLength);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool CPdfFile::MovePage(int nPageIndex, int nPos)
|
bool CPdfFile::MovePage(int nPageIndex, int nPos)
|
||||||
@ -174,28 +173,23 @@ bool CPdfFile::IsNeedCMap()
|
|||||||
}
|
}
|
||||||
void CPdfFile::SetCMapMemory(BYTE* pData, DWORD nSizeData)
|
void CPdfFile::SetCMapMemory(BYTE* pData, DWORD nSizeData)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pReader)
|
if (m_pInternal->pReader)
|
||||||
return;
|
m_pInternal->pReader->SetCMapMemory(pData, nSizeData);
|
||||||
m_pInternal->pReader->SetCMapMemory(pData, nSizeData);
|
|
||||||
}
|
}
|
||||||
void CPdfFile::SetCMapFolder(const std::wstring& sFolder)
|
void CPdfFile::SetCMapFolder(const std::wstring& sFolder)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pReader)
|
if (m_pInternal->pReader)
|
||||||
return;
|
m_pInternal->pReader->SetCMapFolder(sFolder);
|
||||||
m_pInternal->pReader->SetCMapFolder(sFolder);
|
|
||||||
}
|
}
|
||||||
void CPdfFile::SetCMapFile(const std::wstring& sFile)
|
void CPdfFile::SetCMapFile(const std::wstring& sFile)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pReader)
|
if (m_pInternal->pReader)
|
||||||
return;
|
m_pInternal->pReader->SetCMapFile(sFile);
|
||||||
m_pInternal->pReader->SetCMapFile(sFile);
|
|
||||||
}
|
}
|
||||||
void CPdfFile::ToXml(const std::wstring& sFile, bool bSaveStreams)
|
void CPdfFile::ToXml(const std::wstring& sFile, bool bSaveStreams)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pReader)
|
if (m_pInternal->pReader)
|
||||||
return;
|
m_pInternal->pReader->ToXml(sFile, bSaveStreams);
|
||||||
|
|
||||||
m_pInternal->pReader->ToXml(sFile, bSaveStreams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPdfFile::GetMetaData(const std::wstring& sFile, const std::wstring& sMetaName, BYTE** pMetaData, DWORD& nMetaLength)
|
bool CPdfFile::GetMetaData(const std::wstring& sFile, const std::wstring& sMetaName, BYTE** pMetaData, DWORD& nMetaLength)
|
||||||
@ -487,21 +481,18 @@ int CPdfFile::SaveToFile(const std::wstring& wsPath)
|
|||||||
}
|
}
|
||||||
void CPdfFile::SetPassword(const std::wstring& wsPassword)
|
void CPdfFile::SetPassword(const std::wstring& wsPassword)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pWriter)
|
if (m_pInternal->pWriter)
|
||||||
return;
|
m_pInternal->pWriter->SetPassword(wsPassword);
|
||||||
m_pInternal->pWriter->SetPassword(wsPassword);
|
|
||||||
}
|
}
|
||||||
void CPdfFile::SetDocumentID(const std::wstring& wsDocumentID)
|
void CPdfFile::SetDocumentID(const std::wstring& wsDocumentID)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pWriter)
|
if (m_pInternal->pWriter)
|
||||||
return;
|
m_pInternal->pWriter->SetDocumentID(wsDocumentID);
|
||||||
m_pInternal->pWriter->SetDocumentID(wsDocumentID);
|
|
||||||
}
|
}
|
||||||
void CPdfFile::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength)
|
void CPdfFile::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pWriter)
|
if (m_pInternal->pWriter)
|
||||||
return;
|
m_pInternal->pWriter->AddMetaData(sMetaName, pMetaData, nMetaLength);
|
||||||
m_pInternal->pWriter->AddMetaData(sMetaName, pMetaData, nMetaLength);
|
|
||||||
}
|
}
|
||||||
HRESULT CPdfFile::OnlineWordToPdf(const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams)
|
HRESULT CPdfFile::OnlineWordToPdf(const std::wstring& wsSrcFile, const std::wstring& wsDstFile, CConvertFromBinParams* pParams)
|
||||||
{
|
{
|
||||||
@ -855,28 +846,24 @@ HRESULT CPdfFile::get_BrushTextureImage(Aggplus::CImage** pImage)
|
|||||||
{
|
{
|
||||||
if (!m_pInternal->pWriter)
|
if (!m_pInternal->pWriter)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
return m_pInternal->pWriter->get_BrushTextureImage(pImage);
|
return m_pInternal->pWriter->get_BrushTextureImage(pImage);
|
||||||
}
|
}
|
||||||
HRESULT CPdfFile::put_BrushTextureImage(Aggplus::CImage* pImage)
|
HRESULT CPdfFile::put_BrushTextureImage(Aggplus::CImage* pImage)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pWriter)
|
if (!m_pInternal->pWriter)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
return m_pInternal->pWriter->put_BrushTextureImage(pImage);
|
return m_pInternal->pWriter->put_BrushTextureImage(pImage);
|
||||||
}
|
}
|
||||||
HRESULT CPdfFile::get_BrushTransform(Aggplus::CMatrix& oMatrix)
|
HRESULT CPdfFile::get_BrushTransform(Aggplus::CMatrix& oMatrix)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pWriter)
|
if (!m_pInternal->pWriter)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
return m_pInternal->pWriter->get_BrushTransform(oMatrix);
|
return m_pInternal->pWriter->get_BrushTransform(oMatrix);
|
||||||
}
|
}
|
||||||
HRESULT CPdfFile::put_BrushTransform(const Aggplus::CMatrix& oMatrix)
|
HRESULT CPdfFile::put_BrushTransform(const Aggplus::CMatrix& oMatrix)
|
||||||
{
|
{
|
||||||
if (!m_pInternal->pWriter)
|
if (!m_pInternal->pWriter)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
return m_pInternal->pWriter->put_BrushTransform(oMatrix);
|
return m_pInternal->pWriter->put_BrushTransform(oMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -412,6 +412,28 @@ void CPdfReader::SetParams(COfficeDrawingPageParams* pParams)
|
|||||||
globalParams->setDrawAnnotations(bDraw);
|
globalParams->setDrawAnnotations(bDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CPdfReader::FindRefNum(int nObjID, PDFDoc** _pDoc, int* _nStartRefID)
|
||||||
|
{
|
||||||
|
int nStartRefID = 0;
|
||||||
|
for (CPdfReaderContext* pPDFContext : m_vPDFContext)
|
||||||
|
{
|
||||||
|
if (!pPDFContext || !pPDFContext->m_pDocument)
|
||||||
|
continue;
|
||||||
|
PDFDoc* pDoc = pPDFContext->m_pDocument;
|
||||||
|
|
||||||
|
int nLastRefID = pDoc->getXRef()->getNumObjects();
|
||||||
|
if (nObjID < nStartRefID + nLastRefID)
|
||||||
|
{
|
||||||
|
if (_pDoc)
|
||||||
|
*_pDoc = pDoc;
|
||||||
|
if (_nStartRefID)
|
||||||
|
*_nStartRefID = nStartRefID;
|
||||||
|
return nObjID - nStartRefID;
|
||||||
|
}
|
||||||
|
nStartRefID += nLastRefID;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
int CPdfReader::GetPageIndex(int nAbsPageIndex, PDFDoc** _pDoc, PdfReader::CPdfFontList** pFontList, int* nStartRefID)
|
int CPdfReader::GetPageIndex(int nAbsPageIndex, PDFDoc** _pDoc, PdfReader::CPdfFontList** pFontList, int* nStartRefID)
|
||||||
{
|
{
|
||||||
int nTotalPages = 0;
|
int nTotalPages = 0;
|
||||||
|
|||||||
@ -88,6 +88,7 @@ public:
|
|||||||
NSFonts::IFontManager* GetFontManager() { return m_pFontManager; }
|
NSFonts::IFontManager* GetFontManager() { return m_pFontManager; }
|
||||||
PDFDoc* GetLastPDFDocument();
|
PDFDoc* GetLastPDFDocument();
|
||||||
PDFDoc* GetPDFDocument(int PDFIndex);
|
PDFDoc* GetPDFDocument(int PDFIndex);
|
||||||
|
int FindRefNum(int nObjID, PDFDoc** pDoc = NULL, int* nStartRefID = NULL);
|
||||||
int GetPageIndex(int nPageIndex, PDFDoc** pDoc = NULL, PdfReader::CPdfFontList** pFontList = NULL, int* nStartRefID = NULL);
|
int GetPageIndex(int nPageIndex, PDFDoc** pDoc = NULL, PdfReader::CPdfFontList** pFontList = NULL, int* nStartRefID = NULL);
|
||||||
|
|
||||||
BYTE* GetStructure();
|
BYTE* GetStructure();
|
||||||
|
|||||||
@ -3709,7 +3709,7 @@ PdfWriter::CAnnotAppearanceObject* CPdfWriter::DrawAP(PdfWriter::CAnnotation* pA
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
PdfWriter::CPage* pCurPage = m_pPage;
|
PdfWriter::CPage* pCurPage = m_pPage;
|
||||||
PdfWriter::CPage* pFakePage = m_pDocument->CreateFakePage();
|
PdfWriter::CPage* pFakePage = new PdfWriter::CPage(m_pDocument);
|
||||||
m_pPage = pFakePage;
|
m_pPage = pFakePage;
|
||||||
m_pDocument->SetCurPage(pFakePage);
|
m_pDocument->SetCurPage(pFakePage);
|
||||||
m_pPage->StartTransform(1, 0, 0, 1, -pAnnot->GetPageX(), 0);
|
m_pPage->StartTransform(1, 0, 0, 1, -pAnnot->GetPageX(), 0);
|
||||||
@ -3739,7 +3739,7 @@ void CPdfWriter::DrawWidgetAP(PdfWriter::CAnnotation* pA, BYTE* pRender, LONG nL
|
|||||||
PdfWriter::CWidgetAnnotation* pAnnot = (PdfWriter::CWidgetAnnotation*)pA;
|
PdfWriter::CWidgetAnnotation* pAnnot = (PdfWriter::CWidgetAnnotation*)pA;
|
||||||
|
|
||||||
PdfWriter::CPage* pCurPage = m_pPage;
|
PdfWriter::CPage* pCurPage = m_pPage;
|
||||||
PdfWriter::CPage* pFakePage = m_pDocument->CreateFakePage();
|
PdfWriter::CPage* pFakePage = new PdfWriter::CPage(m_pDocument);
|
||||||
m_pPage = pFakePage;
|
m_pPage = pFakePage;
|
||||||
m_pDocument->SetCurPage(pFakePage);
|
m_pDocument->SetCurPage(pFakePage);
|
||||||
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom));
|
m_oTransform.Set(1, 0, 0, 1, PT_2_MM(-pAnnot->GetPageX() - pAnnot->GetRect().fLeft), PT_2_MM(pAnnot->GetRect().fBottom));
|
||||||
|
|||||||
@ -1508,9 +1508,7 @@ namespace PdfWriter
|
|||||||
{
|
{
|
||||||
if (!pParent || !EditXref(pXref))
|
if (!pParent || !EditXref(pXref))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_mParents[nID] = pParent;
|
m_mParents[nID] = pParent;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool CDocument::EditXref(CXref* pXref)
|
bool CDocument::EditXref(CXref* pXref)
|
||||||
@ -1551,10 +1549,6 @@ namespace PdfWriter
|
|||||||
return p->second;
|
return p->second;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
CPage* CDocument::CreateFakePage()
|
|
||||||
{
|
|
||||||
return new CPage(this, NULL);
|
|
||||||
}
|
|
||||||
bool CDocument::EditCO(const std::vector<int>& arrCO)
|
bool CDocument::EditCO(const std::vector<int>& arrCO)
|
||||||
{
|
{
|
||||||
if (arrCO.empty())
|
if (arrCO.empty())
|
||||||
@ -1627,6 +1621,8 @@ namespace PdfWriter
|
|||||||
CObjectBase* pObj = m_pPageTree->RemovePage(nPageIndex);
|
CObjectBase* pObj = m_pPageTree->RemovePage(nPageIndex);
|
||||||
if (pObj->GetType() == object_type_DICT && ((CDictObject*)pObj)->GetDictType() == dict_type_PAGE)
|
if (pObj->GetType() == object_type_DICT && ((CDictObject*)pObj)->GetDictType() == dict_type_PAGE)
|
||||||
return m_pPageTree->InsertPage(nPos, (CPage*)pObj);
|
return m_pPageTree->InsertPage(nPos, (CPage*)pObj);
|
||||||
|
else
|
||||||
|
delete pObj;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -209,7 +209,6 @@ namespace PdfWriter
|
|||||||
CDictObject* GetParent(int nID);
|
CDictObject* GetParent(int nID);
|
||||||
CPage* GetCurPage() { return m_pCurPage; }
|
CPage* GetCurPage() { return m_pCurPage; }
|
||||||
void SetCurPage(CPage* pPage) { m_pCurPage = pPage; }
|
void SetCurPage(CPage* pPage) { m_pCurPage = pPage; }
|
||||||
CPage* CreateFakePage();
|
|
||||||
bool EditCO(const std::vector<int>& arrCO);
|
bool EditCO(const std::vector<int>& arrCO);
|
||||||
const std::map<int, CAnnotation*>& GetAnnots() { return m_mAnnotations; }
|
const std::map<int, CAnnotation*>& GetAnnots() { return m_mAnnotations; }
|
||||||
void AddShapeXML(const std::string& sXML);
|
void AddShapeXML(const std::string& sXML);
|
||||||
|
|||||||
@ -546,7 +546,7 @@ namespace PdfWriter
|
|||||||
if (m_pStream)
|
if (m_pStream)
|
||||||
delete m_pStream;
|
delete m_pStream;
|
||||||
}
|
}
|
||||||
CObjectBase* CDictObject::Get(const std::string& sKey) const
|
CObjectBase* CDictObject::Get(const std::string& sKey) const
|
||||||
{
|
{
|
||||||
std::map<std::string, CObjectBase*>::const_iterator oIter = m_mList.find(sKey);
|
std::map<std::string, CObjectBase*>::const_iterator oIter = m_mList.find(sKey);
|
||||||
if (m_mList.end() != oIter)
|
if (m_mList.end() != oIter)
|
||||||
@ -619,7 +619,7 @@ namespace PdfWriter
|
|||||||
{
|
{
|
||||||
Add(sKey, new CBoolObject(bBool));
|
Add(sKey, new CBoolObject(bBool));
|
||||||
}
|
}
|
||||||
const char* CDictObject::GetKey(const CObjectBase* pObject)
|
const char* CDictObject::GetKey(const CObjectBase* pObject)
|
||||||
{
|
{
|
||||||
for (auto const &oIter : m_mList)
|
for (auto const &oIter : m_mList)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -224,7 +224,7 @@ namespace PdfWriter
|
|||||||
if (pResources)
|
if (pResources)
|
||||||
pResources->Fix();
|
pResources->Fix();
|
||||||
}
|
}
|
||||||
void CPageTree::AddPage(CDictObject* pPage)
|
void CPageTree::AddPage(CPage* pPage)
|
||||||
{
|
{
|
||||||
m_pPages->Add(pPage);
|
m_pPages->Add(pPage);
|
||||||
(*m_pCount)++;
|
(*m_pCount)++;
|
||||||
@ -346,16 +346,9 @@ namespace PdfWriter
|
|||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// CPage
|
// CPage
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
CPage::CPage(CDocument* pDocument, CXref* pXref)
|
CPage::CPage(CDocument* pDocument)
|
||||||
{
|
{
|
||||||
Init(pDocument);
|
Init(pDocument);
|
||||||
if (pXref)
|
|
||||||
{
|
|
||||||
AddResource(pXref);
|
|
||||||
m_pContents = new CArrayObject();
|
|
||||||
Add("Contents", m_pContents);
|
|
||||||
AddContents(pXref);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void CPage::Fix()
|
void CPage::Fix()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -65,7 +65,7 @@ namespace PdfWriter
|
|||||||
CPageTree(CXref* pXref);
|
CPageTree(CXref* pXref);
|
||||||
CPageTree();
|
CPageTree();
|
||||||
void Fix();
|
void Fix();
|
||||||
void AddPage(CDictObject* pPage);
|
void AddPage(CPage* pPage);
|
||||||
CObjectBase* GetObj(int nPageIndex);
|
CObjectBase* GetObj(int nPageIndex);
|
||||||
CPage* GetPage(int nPageIndex);
|
CPage* GetPage(int nPageIndex);
|
||||||
CObjectBase* RemovePage(int nPageIndex);
|
CObjectBase* RemovePage(int nPageIndex);
|
||||||
@ -93,7 +93,7 @@ namespace PdfWriter
|
|||||||
class CPage : public CDictObject
|
class CPage : public CDictObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPage(CDocument* pDocument, CXref* pXref = NULL);
|
CPage(CDocument* pDocument);
|
||||||
CPage(CXref* pXref, CPageTree* pParent, CDocument* pDocument);
|
CPage(CXref* pXref, CPageTree* pParent, CDocument* pDocument);
|
||||||
~CPage();
|
~CPage();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user