mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Fix validation
This commit is contained in:
@ -2378,12 +2378,18 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command)
|
||||
case IAdvancedCommand::AdvancedCommandType::ShapeStart:
|
||||
{
|
||||
CShapeStart* pCommand = (CShapeStart*)command;
|
||||
m_pInternal->pWriter->AddShapeXML(pCommand->GetShapeXML());
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (m_pInternal->bEdit && m_pInternal->bEditPage)
|
||||
m_pInternal->pWriter->m_pDocument->AddShapeXML(pCommand->GetShapeXML());
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
case IAdvancedCommand::AdvancedCommandType::ShapeEnd:
|
||||
{
|
||||
m_pInternal->pWriter->EndMarkedContent();
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (m_pInternal->bEdit && m_pInternal->bEditPage)
|
||||
m_pInternal->pWriter->m_pPage->EndMarkedContent();
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
default:
|
||||
|
||||
@ -1561,18 +1561,18 @@ BYTE* CPdfReader::GetShapes(int nPageIndex)
|
||||
{
|
||||
if (!m_pPDFDocument || !m_pPDFDocument->getCatalog())
|
||||
return NULL;
|
||||
Ref* pPageRef = m_pPDFDocument->getCatalog()->getPageRef(nPageIndex + 1);
|
||||
if (!pPageRef)
|
||||
Dict* pResources = m_pPDFDocument->getCatalog()->getPage(nPageIndex + 1)->getResourceDict();
|
||||
if (!pResources)
|
||||
return NULL;
|
||||
|
||||
Object oPageObj, oMetaOForm, oID;
|
||||
Object oProperties, oMetaOForm, oID;
|
||||
XRef* xref = m_pPDFDocument->getXRef();
|
||||
if (!xref->fetch(pPageRef->num, pPageRef->gen, &oPageObj)->isDict() || !oPageObj.dictLookup("MetaOForm", &oMetaOForm)->isDict("MetaOForm") || !oMetaOForm.dictLookup("ID", &oID)->isString())
|
||||
if (!pResources->lookup("Properties", &oProperties)->isDict() || !oProperties.dictLookup("MetaOForm", &oMetaOForm)->isDict("MetaOForm") || !oMetaOForm.dictLookup("ID", &oID)->isString())
|
||||
{
|
||||
oPageObj.free(); oMetaOForm.free(); oID.free();
|
||||
oProperties.free(); oMetaOForm.free(); oID.free();
|
||||
return NULL;
|
||||
}
|
||||
oPageObj.free();
|
||||
oProperties.free();
|
||||
|
||||
Object oTID, oID2;
|
||||
Object* pTrailerDict = xref->getTrailerDict();
|
||||
@ -1581,7 +1581,7 @@ BYTE* CPdfReader::GetShapes(int nPageIndex)
|
||||
oMetaOForm.free(); oID.free(); oTID.free(); oID2.free();
|
||||
return NULL;
|
||||
}
|
||||
oTID.free(); oID.free(); oID2.free();
|
||||
oID.free(); oTID.free(); oID2.free();
|
||||
|
||||
Object oMetadata;
|
||||
if (!oMetaOForm.dictLookup("Metadata", &oMetadata)->isArray())
|
||||
@ -1608,6 +1608,7 @@ BYTE* CPdfReader::GetShapes(int nPageIndex)
|
||||
}
|
||||
oRes.WriteString(sStr);
|
||||
}
|
||||
oMetadata.free();
|
||||
|
||||
oRes.WriteLen();
|
||||
BYTE* bRes = oRes.GetBuffer();
|
||||
|
||||
@ -2345,14 +2345,6 @@ HRESULT CPdfWriter::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData,
|
||||
{
|
||||
return m_pDocument->AddMetaData(sMetaName, pMetaData, nMetaLength) ? S_OK : S_FALSE;
|
||||
}
|
||||
void CPdfWriter::AddShapeXML(const std::string& sXML)
|
||||
{
|
||||
m_pDocument->AddShapeXML(sXML);
|
||||
}
|
||||
void CPdfWriter::EndMarkedContent()
|
||||
{
|
||||
m_pDocument->EndMarkedContent();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Дополнительные функции Pdf рендерера
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
@ -198,8 +198,6 @@ public:
|
||||
HRESULT AddFormField (NSFonts::IApplicationFonts* pAppFonts, CFormFieldInfo* pFieldInfo, const std::wstring& wsTempDirectory);
|
||||
HRESULT AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotFieldInfo* pFieldInfo);
|
||||
HRESULT AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData, DWORD nMetaLength);
|
||||
void AddShapeXML(const std::string& sXML);
|
||||
void EndMarkedContent();
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Дополнительные функции Pdf рендерера
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
@ -159,8 +159,6 @@ void CPdfWriter::Reset() {}
|
||||
bool CPdfWriter::IsValid() { return false; }
|
||||
bool CPdfWriter::IsPageValid() { return false; }
|
||||
void CPdfWriter::SetError() {}
|
||||
void CPdfWriter::EndMarkedContent() {}
|
||||
void CPdfWriter::AddShapeXML(const std::string& sXML) {}
|
||||
void CPdfWriter::AddLink(PdfWriter::CPage* pPage, const double& dX, const double& dY, const double& dW, const double& dH, const double& dDestX, const double& dDestY, const unsigned int& unDestPage) {}
|
||||
unsigned char* CPdfWriter::EncodeString(const unsigned int* pUnicodes, const unsigned int& unUnicodesCount, const unsigned int* pGIDs) { return NULL; }
|
||||
unsigned char* CPdfWriter::EncodeGID(const unsigned int& unGID, const unsigned int* pUnicodes, const unsigned int& unUnicodesCount) { return NULL; }
|
||||
|
||||
@ -1733,10 +1733,22 @@ namespace PdfWriter
|
||||
}
|
||||
void CDocument::AddShapeXML(const std::string& sXML)
|
||||
{
|
||||
CObjectBase* pObj = m_pCurPage->Get("MetaOForm");
|
||||
CDictObject* pResources = (CDictObject*)m_pCurPage->Get("Resources");
|
||||
if (!pResources)
|
||||
{
|
||||
pResources = new CDictObject();
|
||||
m_pCurPage->Add("Resources", pResources);
|
||||
}
|
||||
CDictObject* pProperties = (CDictObject*)pResources->Get("Properties");
|
||||
if (!pProperties)
|
||||
{
|
||||
pProperties = new CDictObject();
|
||||
pResources->Add("Properties", pProperties);
|
||||
}
|
||||
CObjectBase* pObj = pProperties->Get("MetaOForm");
|
||||
if (pObj && pObj->GetType() != object_type_DICT)
|
||||
{
|
||||
m_pCurPage->Remove("MetaOForm");
|
||||
pProperties->Remove("MetaOForm");
|
||||
pObj = NULL;
|
||||
}
|
||||
CDictObject* pMetaOForm = (CDictObject*)pObj;
|
||||
@ -1745,7 +1757,7 @@ namespace PdfWriter
|
||||
pMetaOForm = new CDictObject();
|
||||
m_pXref->Add(pMetaOForm);
|
||||
pMetaOForm->Add("Type", "MetaOForm");
|
||||
m_pCurPage->Add("MetaOForm", pMetaOForm);
|
||||
pProperties->Add("MetaOForm", pMetaOForm);
|
||||
m_vMetaOForms.push_back(pMetaOForm);
|
||||
|
||||
CBinaryObject* sID = NULL;
|
||||
@ -1777,13 +1789,4 @@ namespace PdfWriter
|
||||
|
||||
m_pCurPage->BeginMarkedContent("MetaOForm");
|
||||
}
|
||||
void CDocument::EndMarkedContent()
|
||||
{
|
||||
m_pCurPage->EndMarkedContent();
|
||||
}
|
||||
bool CDocument::HaveMetaOForm()
|
||||
{
|
||||
CObjectBase* pObj = m_pCurPage->Get("MetaOForm");
|
||||
return pObj && pObj->GetType() == object_type_DICT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,8 +199,6 @@ namespace PdfWriter
|
||||
bool EditCO(const std::vector<int>& arrCO);
|
||||
const std::map<int, CAnnotation*>& GetAnnots() { return m_mAnnotations; }
|
||||
void AddShapeXML(const std::string& sXML);
|
||||
void EndMarkedContent();
|
||||
bool HaveMetaOForm();
|
||||
private:
|
||||
|
||||
char* GetTTFontTag();
|
||||
|
||||
@ -5053,14 +5053,20 @@ void Gfx::opBeginMarkedContent(Object args[], int numArgs) {
|
||||
mcKind = gfxMCActualText;
|
||||
}
|
||||
obj.free();
|
||||
} else if (args[0].isName("MetaOForm")) {
|
||||
getContentObj(&obj);
|
||||
while (!obj.isEOF() && !obj.isCmd("EMC")) {
|
||||
obj.free();
|
||||
} else if (args[0].isName("MetaOForm") && res->lookupPropertiesNF("MetaOForm", &obj)) {
|
||||
Object oMetaOForm, oID, oTID, oID2;
|
||||
if (obj.fetch(xref, &oMetaOForm)->isDict("MetaOForm") && oMetaOForm.dictLookup("ID", &oID)->isString() && xref->getTrailerDict()->dictLookup("ID", &oTID)->isArray() &&
|
||||
oTID.arrayGet(1, &oID2)->isString() && oID2.getString()->cmp(oID.getString()) == 0) {
|
||||
oMetaOForm.free(); oID.free(); oTID.free(); oID2.free(); obj.free();
|
||||
getContentObj(&obj);
|
||||
while (!obj.isEOF() && !obj.isCmd("EMC")) {
|
||||
obj.free();
|
||||
getContentObj(&obj);
|
||||
}
|
||||
obj.free();
|
||||
return;
|
||||
}
|
||||
obj.free();
|
||||
return;
|
||||
oMetaOForm.free(); oID.free(); oTID.free(); oID2.free(); obj.free();
|
||||
}
|
||||
mc = new GfxMarkedContent(mcKind, ocState);
|
||||
markedContentStack->append(mc);
|
||||
|
||||
Reference in New Issue
Block a user