From 335e1c3979fae11410bce75ef61457cd6e437ff2 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 30 Oct 2023 17:53:53 +0300 Subject: [PATCH 1/4] Fix bug #64530 --- PdfFile/PdfFile.cpp | 2 +- PdfFile/PdfWriter.cpp | 27 ++++++++++++++++++++++++--- PdfFile/PdfWriter.h | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/PdfFile/PdfFile.cpp b/PdfFile/PdfFile.cpp index 1fa52c9466..b47427117b 100644 --- a/PdfFile/PdfFile.cpp +++ b/PdfFile/PdfFile.cpp @@ -1899,7 +1899,7 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command) } case IAdvancedCommand::AdvancedCommandType::FormField: { - return m_pInternal->pWriter->AddFormField(m_pInternal->pAppFonts, (CFormFieldInfo*)command); + return m_pInternal->pWriter->AddFormField(m_pInternal->pAppFonts, (CFormFieldInfo*)command, m_pInternal->wsTempFolder); } case IAdvancedCommand::AdvancedCommandType::Annotaion: { diff --git a/PdfFile/PdfWriter.cpp b/PdfFile/PdfWriter.cpp index 68a266c320..b185c5e87e 100644 --- a/PdfFile/PdfWriter.cpp +++ b/PdfFile/PdfWriter.cpp @@ -1077,7 +1077,7 @@ HRESULT CPdfWriter::AddLink(const double& dX, const double& dY, const double& dW return S_OK; } -HRESULT CPdfWriter::AddFormField(NSFonts::IApplicationFonts* pAppFonts, CFormFieldInfo* pFieldInfo) +HRESULT CPdfWriter::AddFormField(NSFonts::IApplicationFonts* pAppFonts, CFormFieldInfo* pFieldInfo, const std::wstring& wsTempDirectory) { unsigned int unPagesCount = m_pDocument->GetPagesCount(); if (!m_pDocument || 0 == unPagesCount || !pFieldInfo) @@ -1547,8 +1547,29 @@ HRESULT CPdfWriter::AddFormField(NSFonts::IApplicationFonts* pAppFonts, CFormFie PdfWriter::CImageDict* pImage = NULL; if (wsPath.length()) { - Aggplus::CImage oImage(wsPath); - pImage = LoadImage(&oImage, 255); + Aggplus::CImage* pCImage = NULL; + CImageFileFormatChecker oImageFormat(wsPath); + if (_CXIMAGE_FORMAT_WMF == oImageFormat.eFileType || + _CXIMAGE_FORMAT_EMF == oImageFormat.eFileType || + _CXIMAGE_FORMAT_SVM == oImageFormat.eFileType || + _CXIMAGE_FORMAT_SVG == oImageFormat.eFileType) + { + MetaFile::IMetaFile* pMeta = MetaFile::Create(pAppFonts); + pMeta->LoadFromFile(wsPath.c_str()); + + double dNewW = std::max(10.0, dW) / 25.4 * 300; + std::wstring wsTempFile = GetTempFile(wsTempDirectory); + pMeta->ConvertToRaster(wsTempFile.c_str(), _CXIMAGE_FORMAT_PNG, dNewW); + + RELEASEOBJECT(pMeta); + + pCImage = new Aggplus::CImage(wsTempFile); + } + else + pCImage = new Aggplus::CImage(wsPath); + + pImage = LoadImage(pCImage, 255); + RELEASEOBJECT(pCImage); } pField->SetAppearance(pImage); diff --git a/PdfFile/PdfWriter.h b/PdfFile/PdfWriter.h index a55c4ea1f0..6986c25d01 100644 --- a/PdfFile/PdfWriter.h +++ b/PdfFile/PdfWriter.h @@ -193,7 +193,7 @@ public: //---------------------------------------------------------------------------------------- HRESULT AddHyperlink(const double& dX, const double& dY, const double& dW, const double& dH, const std::wstring& wsUrl, const std::wstring& wsTooltip); HRESULT AddLink(const double& dX, const double& dY, const double& dW, const double& dH, const double& dDestX, const double& dDestY, const int& nPage); - HRESULT AddFormField (NSFonts::IApplicationFonts* pAppFonts, CFormFieldInfo* pFieldInfo); + HRESULT AddFormField (NSFonts::IApplicationFonts* pAppFonts, CFormFieldInfo* pFieldInfo, const std::wstring& wsTempDirectory); HRESULT AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotFieldInfo* pFieldInfo); //---------------------------------------------------------------------------------------- // Дополнительные функции Pdf рендерера From 5a24c2895c0a44dba76b4b48f441300173077d76 Mon Sep 17 00:00:00 2001 From: Viktor Andreev Date: Wed, 1 Nov 2023 15:10:35 +0600 Subject: [PATCH 2/4] Fix bug #64863 --- .../Format/Logic/Biff_structures/PtgList.cpp | 2 +- OOXML/XlsxFormat/Chart/ChartSerialize.cpp | 45 ++++++++++++------- OOXML/XlsxFormat/Styles/dxf.cpp | 8 ++++ .../Worksheets/ConditionalFormatting.cpp | 2 + 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp index 039fe2cc7c..fae7a7ed1c 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_structures/PtgList.cpp @@ -135,7 +135,7 @@ void PtgList::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool ful case 0x00: break; case 0x01: case 0x02: - formula += L",[" + arrColumn->second[colFirst] + L"]"; if(columns == 0x01) break; + formula += L",['" + arrColumn->second[colFirst] + L"]"; if(columns == 0x01) break; formula += L":[" + arrColumn->second[colLast] + L"]"; break; } } diff --git a/OOXML/XlsxFormat/Chart/ChartSerialize.cpp b/OOXML/XlsxFormat/Chart/ChartSerialize.cpp index 42ced8808c..1b0a4fc042 100644 --- a/OOXML/XlsxFormat/Chart/ChartSerialize.cpp +++ b/OOXML/XlsxFormat/Chart/ChartSerialize.cpp @@ -1401,7 +1401,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); writer.WriteString(L">"); if (m_oddHeader.IsInit()) { - if (std::wstring::npos != m_oddHeader->find(' ') || std::wstring::npos != m_oddHeader->find('\n')) + if (std::wstring::npos != m_oddHeader->find(' ')&&( m_oddHeader->at(0) == ' ' || m_oddHeader->at(m_oddHeader->size()-1) == ' ') + || std::wstring::npos != m_oddHeader->find('\n')&&( m_oddHeader->at(0) == '\n' || m_oddHeader->at(m_oddHeader->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -1410,7 +1411,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); } if (m_oddFooter.IsInit()) { - if (std::wstring::npos != m_oddFooter->find(' ') || std::wstring::npos != m_oddFooter->find('\n')) + if (std::wstring::npos != m_oddFooter->find(' ')&&( m_oddFooter->at(0) == ' ' || m_oddFooter->at(m_oddFooter->size()-1) == ' ') + || std::wstring::npos != m_oddFooter->find('\n')&&( m_oddFooter->at(0) == '\n' || m_oddFooter->at(m_oddFooter->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -1419,7 +1421,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); } if (m_evenHeader.IsInit()) { - if (std::wstring::npos != m_evenHeader->find(' ') || std::wstring::npos != m_evenHeader->find('\n')) + if (std::wstring::npos != m_evenHeader->find(' ')&&( m_evenHeader->at(0) == ' ' || m_evenHeader->at(m_evenHeader->size()-1) == ' ') + || std::wstring::npos != m_evenHeader->find('\n')&&( m_evenHeader->at(0) == '\n' || m_evenHeader->at(m_evenHeader->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -1428,7 +1431,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); } if ( m_evenFooter.IsInit()) { - if (std::wstring::npos != m_evenFooter->find(' ') || std::wstring::npos != m_evenFooter->find('\n')) + if (std::wstring::npos != m_evenFooter->find(' ')&&( m_evenFooter->at(0) == ' ' || m_evenFooter->at(m_evenFooter->size()-1) == ' ') + || std::wstring::npos != m_evenFooter->find('\n')&&( m_evenFooter->at(0) == '\n' || m_evenFooter->at(m_evenFooter->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -1437,7 +1441,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); } if (m_firstHeader.IsInit()) { - if (std::wstring::npos != m_firstHeader->find(' ') || std::wstring::npos != m_firstHeader->find('\n')) + if (std::wstring::npos != m_firstHeader->find(' ')&&( m_firstHeader->at(0) == ' ' || m_firstHeader->at(m_firstHeader->size()-1) == ' ') + || std::wstring::npos != m_firstHeader->find('\n')&&( m_firstHeader->at(0) == '\n' || m_firstHeader->at(m_firstHeader->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -1446,7 +1451,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); } if (m_firstFooter.IsInit()) { - if (std::wstring::npos != m_firstFooter->find(' ') || std::wstring::npos != m_firstFooter->find('\n')) + if (std::wstring::npos != m_firstFooter->find(' ')&&( m_firstFooter->at(0) == ' ' || m_firstFooter->at(m_firstFooter->size()-1) == ' ') + || std::wstring::npos != m_firstFooter->find('\n')&&( m_firstFooter->at(0) == '\n' || m_firstFooter->at(m_firstFooter->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -2520,7 +2526,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); writer.WriteString(L">"); if (m_f.IsInit()) { - if (std::wstring::npos != m_f->find(' ') || std::wstring::npos != m_f->find('\n')) + if (std::wstring::npos != m_f->find(' ')&&( m_f->at(0) == ' ' || m_f->at(m_f->size()-1) == ' ') + || std::wstring::npos != m_f->find('\n')&&( m_f->at(0) == '\n' || m_f->at(m_f->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -2642,7 +2649,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); if (m_v.IsInit()) { - if (std::wstring::npos != m_v->find(' ') || std::wstring::npos != m_v->find('\n')) + if (std::wstring::npos != m_v->find(' ')&&( m_v->at(0) == ' ' || m_v->at(m_v->size()-1) == ' ') + || std::wstring::npos != m_v->find('\n')&&( m_v->at(0) == '\n' || m_v->at(m_v->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -3894,7 +3902,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); } else { - if (std::wstring::npos != pTypeVal->find(' ') || std::wstring::npos != pTypeVal->find('\n')) + if (std::wstring::npos != pTypeVal->find(' ')&&( pTypeVal->at(0) == ' ' || pTypeVal->at(pTypeVal->size()-1) == ' ') + || std::wstring::npos != pTypeVal->find('\n')&&( pTypeVal->at(0) == '\n' || pTypeVal->at(pTypeVal->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -4399,7 +4408,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); } else { - if (std::wstring::npos != pTypeVal->find(' ') || std::wstring::npos != pTypeVal->find('\n')) + if (std::wstring::npos != pTypeVal->find(' ')&&( pTypeVal->at(0) == ' ' || pTypeVal->at(pTypeVal->size()-1) == ' ') + || std::wstring::npos != pTypeVal->find('\n')&&( pTypeVal->at(0) == '\n' || pTypeVal->at(pTypeVal->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -4690,7 +4700,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); if (m_name.IsInit()) { - if (std::wstring::npos != m_name->find(' ') || std::wstring::npos != m_name->find('\n')) + if (std::wstring::npos != m_name->find(' ')&&( m_name->at(0) == ' ' || m_name->at(m_name->size()-1) == ' ') + || std::wstring::npos != m_name->find('\n')&&( m_name->at(0) == '\n' || m_name->at(m_name->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -5126,7 +5137,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); writer.WriteString(L">"); if (m_v.IsInit()) { - if (std::wstring::npos != m_v->find(' ') || std::wstring::npos != m_v->find('\n')) + if (std::wstring::npos != m_v->find(' ')&&( m_v->at(0) == ' ' || m_v->at(m_v->size()-1) == ' ') + || std::wstring::npos != m_v->find('\n')&&( m_v->at(0) == '\n' || m_v->at(m_v->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -5187,7 +5199,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); if (m_f.IsInit()) { - if (std::wstring::npos != m_f->find(' ') || std::wstring::npos != m_f->find('\n')) + if (std::wstring::npos != m_f->find(' ')&&( m_f->at(0) == ' ' || m_f->at(m_f->size()-1) == ' ') + || std::wstring::npos != m_f->find('\n')&&( m_f->at(0) == '\n' || m_f->at(m_f->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -5355,7 +5368,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); if (m_f.IsInit()) { - if (std::wstring::npos != m_f->find(' ') || std::wstring::npos != m_f->find('\n')) + if (std::wstring::npos != m_f->find(' ')&&( m_f->at(0) == ' ' || m_f->at(m_f->size()-1) == ' ') + || std::wstring::npos != m_f->find('\n')&&( m_f->at(0) == '\n' || m_f->at(m_f->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); @@ -9485,7 +9499,8 @@ xmlns:c16r2=\"http://schemas.microsoft.com/office/drawing/2015/06/chart\""); if (m_name.IsInit()) { - if (std::wstring::npos != m_name->find(' ') || std::wstring::npos != m_name->find('\n')) + if (std::wstring::npos != m_name->find(' ')&&( m_name->at(0) == ' ' || m_name->at(m_name->size()-1) == ' ') + || std::wstring::npos != m_name->find('\n')&&( m_name->at(0) == '\n' || m_name->at(m_name->size()-1) == '\n')) writer.WriteString(L""); else writer.WriteString(L""); diff --git a/OOXML/XlsxFormat/Styles/dxf.cpp b/OOXML/XlsxFormat/Styles/dxf.cpp index 2cdd59878f..7a655abf88 100644 --- a/OOXML/XlsxFormat/Styles/dxf.cpp +++ b/OOXML/XlsxFormat/Styles/dxf.cpp @@ -43,6 +43,7 @@ #include "../../XlsbFormat/Biff12_records/CommonRecords.h" #include "../../Common/SimpleTypes_Shared.h" +#include namespace OOX { @@ -145,7 +146,14 @@ namespace OOX else if ( _T("font") == sName ) m_oFont = oReader; else if ( _T("numFmt") == sName ) + { m_oNumFmt = oReader; + if(m_oNumFmt->m_oFormatCode.IsInit()) + if(m_oNumFmt->m_oFormatCode.get().find(L""")) + boost::algorithm::replace_all(m_oNumFmt->m_oFormatCode.get(), L""", L"\""); + + + } else if ( _T("protection") == sName ) m_oProtection = oReader; } diff --git a/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp b/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp index 30b5a0fc6a..3ae020f2a2 100644 --- a/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp +++ b/OOXML/XlsxFormat/Worksheets/ConditionalFormatting.cpp @@ -394,6 +394,8 @@ void CConditionalFormatIconSet::ReadAttributes(XLS::BaseObjectPtr& obj) if(ptr != nullptr) { + if(ptr->index < 0) + ptr->index = 0; m_oIconId = ptr->index; switch(ptr->iconSet.set) From 6a6d8e64142b96b24cda93febf79d69942e068c0 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Wed, 1 Nov 2023 18:11:41 +0300 Subject: [PATCH 3/4] for bug #64944 --- OdfFile/Reader/Converter/mediaitems.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OdfFile/Reader/Converter/mediaitems.cpp b/OdfFile/Reader/Converter/mediaitems.cpp index c2cc8148f2..baacf2a84f 100644 --- a/OdfFile/Reader/Converter/mediaitems.cpp +++ b/OdfFile/Reader/Converter/mediaitems.cpp @@ -38,6 +38,7 @@ #include "../../../OOXML/Base/Base.h" #include "../../../OOXML/SystemUtility/File.h" +#include "../../../OOXML/SystemUtility/SystemUtility.h" #include "../../../DesktopEditor/common/Directory.h" #include "../../../DesktopEditor/raster/ImageFileFormatChecker.h" @@ -56,7 +57,13 @@ bool is_internal(const std::wstring & uri, const std::wstring & packetRoot) std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath; - return NSFile::CFileBinary::Exists(resultPath) || NSDirectory::Exists(mediaPath); + OOX::CPath pathRoot(packetRoot); + OOX::CPath pathFile(resultPath); + + std::wstring testRoot = pathRoot.GetPath(); + std::wstring testFile = pathFile.GetPath(); + + return NSFile::CFileBinary::Exists(resultPath) || NSDirectory::Exists(mediaPath) || (std::wstring::npos != testFile.find(testRoot)); } mediaitems::item::item(std::wstring const & _href,_rels_type _type, std::wstring const & _outputName, From 743e83420d235df49c895e28b9a4102cfcc8f5cb Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Wed, 1 Nov 2023 21:49:29 +0300 Subject: [PATCH 4/4] fix --- OOXML/Common/ComplexTypes.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/OOXML/Common/ComplexTypes.cpp b/OOXML/Common/ComplexTypes.cpp index f6902902e8..6fd06ffebe 100644 --- a/OOXML/Common/ComplexTypes.cpp +++ b/OOXML/Common/ComplexTypes.cpp @@ -2614,14 +2614,6 @@ namespace Word WritingElement_ReadAttributes_Read_else_if(oReader, L"w:before-autospacing", m_oBeforeAutospacing) WritingElement_ReadAttributes_Read_else_if(oReader, L"w:after-autospacing", m_oAfterAutospacing) WritingElement_ReadAttributes_End(oReader) - - if (m_oLine.IsInit()) - { - if (m_oLine->GetValue() < 0) - { - m_oLine->SetValue(-m_oLine->GetValue()); - } - } } //--------------------------------------------------------------------------------