diff --git a/DesktopEditor/graphics/IRenderer.h b/DesktopEditor/graphics/IRenderer.h index 6ee8c92f45..849f6e6d56 100644 --- a/DesktopEditor/graphics/IRenderer.h +++ b/DesktopEditor/graphics/IRenderer.h @@ -144,6 +144,7 @@ public: FormField = 3, // Обратная совместимость для docxf Annotaion = 4, DeleteAnnot = 5, + WidgetsInfo = 6, Undefined = 255 }; diff --git a/DesktopEditor/graphics/MetafileToRenderer.cpp b/DesktopEditor/graphics/MetafileToRenderer.cpp index 25b2c7a8ae..b12fc408a8 100644 --- a/DesktopEditor/graphics/MetafileToRenderer.cpp +++ b/DesktopEditor/graphics/MetafileToRenderer.cpp @@ -924,6 +924,7 @@ namespace NSOnlineOfficeBinToPdf case ctFormField: case ctAnnotField: case ctAnnotFieldDelete: + case ctWidgetsInfo: { IAdvancedCommand::AdvancedCommandType eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Undefined; switch (eCommand) @@ -931,6 +932,7 @@ namespace NSOnlineOfficeBinToPdf case ctFormField: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::FormField; break; case ctAnnotField: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Annotaion; break; case ctAnnotFieldDelete: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::DeleteAnnot; break; + case ctWidgetsInfo: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::WidgetsInfo; break; default: break; } diff --git a/DesktopEditor/graphics/MetafileToRenderer.h b/DesktopEditor/graphics/MetafileToRenderer.h index ebabee8400..57f64880f9 100644 --- a/DesktopEditor/graphics/MetafileToRenderer.h +++ b/DesktopEditor/graphics/MetafileToRenderer.h @@ -182,6 +182,7 @@ namespace NSOnlineOfficeBinToPdf ctDocInfo = 163, ctAnnotField = 164, ctAnnotFieldDelete = 165, + ctWidgetsInfo = 166, ctPageWidth = 200, ctPageHeight = 201, diff --git a/PdfFile/PdfFile.cpp b/PdfFile/PdfFile.cpp index c90b040bb5..62ea49da33 100644 --- a/PdfFile/PdfFile.cpp +++ b/PdfFile/PdfFile.cpp @@ -1921,6 +1921,7 @@ HRESULT CPdfFile::IsSupportAdvancedCommand(const IAdvancedCommand::AdvancedComma case IAdvancedCommand::AdvancedCommandType::FormField: case IAdvancedCommand::AdvancedCommandType::Annotaion: case IAdvancedCommand::AdvancedCommandType::DeleteAnnot: + case IAdvancedCommand::AdvancedCommandType::WidgetsInfo: return S_OK; default: break; @@ -1974,7 +1975,13 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command) if (m_pInternal->bEdit && m_pInternal->bEditPage) DeleteAnnot(pCommand->GetID()); #endif - return true; + return S_OK; + } + case IAdvancedCommand::AdvancedCommandType::WidgetsInfo: + { + CWidgetsInfo* pCommand = (CWidgetsInfo*)command; + + return S_OK; } default: break; diff --git a/PdfFile/PdfReader.cpp b/PdfFile/PdfReader.cpp index 27ae4d8a19..c822f2ab06 100644 --- a/PdfFile/PdfReader.cpp +++ b/PdfFile/PdfReader.cpp @@ -779,7 +779,7 @@ BYTE* CPdfReader::GetWidgets() NSWasm::CData oRes; oRes.SkipLen(); - PdfReader::CAnnots* pAnnots = new PdfReader::CAnnots(m_pPDFDocument); + PdfReader::CAnnots* pAnnots = new PdfReader::CAnnots(m_pPDFDocument, m_pFontManager, m_pFontList); if (pAnnots) pAnnots->ToWASM(oRes); RELEASEOBJECT(pAnnots); diff --git a/PdfFile/SrcReader/PdfAnnot.cpp b/PdfFile/SrcReader/PdfAnnot.cpp index 6381d64372..217b393aba 100644 --- a/PdfFile/SrcReader/PdfAnnot.cpp +++ b/PdfFile/SrcReader/PdfAnnot.cpp @@ -31,6 +31,7 @@ */ #include "PdfAnnot.h" +#include "RendererOutputDev.h" #include "../lib/xpdf/TextString.h" #include "../lib/xpdf/Link.h" #include "../lib/xpdf/Annot.h" @@ -686,10 +687,7 @@ CAnnotWidget::CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField) : CAnnot(pdfDo oFontRef.fetch(xref, &oFont); oFontRef.free(); - Object oFontName; - if (oFont.isDict() && oFont.dictLookup("Name", &oFontName)->isName()) - m_sFontName = oFontName.getName(); - oFontName.free(); oFont.free(); + oFont.free(); } // Цвет текста - из DA @@ -854,6 +852,14 @@ CAnnotWidget::~CAnnotWidget() RELEASEOBJECT(m_arrAction[i]); } +void CAnnotWidget::SetFont(PDFDoc* pdfDoc, AcroFormField* pField, NSFonts::IFontManager* pFontManager, CFontList *pFontList) +{ + std::wstring wsFileName, wsFontName; + GetFont(pdfDoc->getXRef(), pFontManager, pFontList, NULL, wsFileName, wsFontName); + + m_sFontName = U_TO_UTF8(wsFileName); +} + //------------------------------------------------------------------------ // Popup //------------------------------------------------------------------------ @@ -1364,7 +1370,7 @@ CAnnotCaret::CAnnotCaret(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex) : CM // Annots //------------------------------------------------------------------------ -CAnnots::CAnnots(PDFDoc* pdfDoc) +CAnnots::CAnnots(PDFDoc* pdfDoc, NSFonts::IFontManager* pFontManager, CFontList *pFontList) { Object oObj1, oObj2; XRef* xref = pdfDoc->getXRef(); @@ -1406,7 +1412,7 @@ CAnnots::CAnnots(PDFDoc* pdfDoc) oParentRefObj.free(); oField.free(); oFieldRef.free(); - CAnnot* pAnnot = NULL; + CAnnotWidget* pAnnot = NULL; AcroFormFieldType oType = pField->getAcroFormFieldType(); switch (oType) { @@ -1440,7 +1446,10 @@ CAnnots::CAnnots(PDFDoc* pdfDoc) break; } if (pAnnot) + { + pAnnot->SetFont(pdfDoc, pField, pFontManager, pFontList); m_arrAnnots.push_back(pAnnot); + } } } diff --git a/PdfFile/SrcReader/PdfAnnot.h b/PdfFile/SrcReader/PdfAnnot.h index 3cb8cf968c..a617f96d4f 100644 --- a/PdfFile/SrcReader/PdfAnnot.h +++ b/PdfFile/SrcReader/PdfAnnot.h @@ -213,6 +213,8 @@ class CAnnotWidget : public CAnnot public: virtual ~CAnnotWidget(); + void SetFont(PDFDoc* pdfDoc, AcroFormField* pField, NSFonts::IFontManager* pFontManager, CFontList *pFontList); + protected: CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField); @@ -481,7 +483,7 @@ private: class CAnnots { public: - CAnnots(PDFDoc* pdfDoc); + CAnnots(PDFDoc* pdfDoc, NSFonts::IFontManager* pFontManager, CFontList *pFontList); ~CAnnots(); void ToWASM(NSWasm::CData& oRes); @@ -510,7 +512,7 @@ private: std::vector m_arrCO; // Порядок вычислений - CO std::vector m_arrParents; // Родительские Fields - std::vector m_arrAnnots; + std::vector m_arrAnnots; }; }