From 1619e421f2eaa4dfa4999f5a49cd4a896b3323df Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 25 Jun 2025 18:20:20 +0300 Subject: [PATCH 01/33] . --- OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp index 476255d068..aa6076dbb6 100644 --- a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp +++ b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp @@ -6257,7 +6257,7 @@ void CDrawingConverter::ConvertTextVML(XmlUtils::CXmlNode &nodeTextBox, PPTX::Lo } else { - std::vector nodesDiv3 = node1.GetNodes(L"*"); + std::vector nodesDiv3 = node2.GetNodes(L"*"); for (auto node3 : nodesDiv3) { name = node3.GetName(); From b5d56d1d6d48102cf960c0f62806710dc7f8a5c6 Mon Sep 17 00:00:00 2001 From: "Oleg.Korshul" Date: Sun, 29 Jun 2025 11:27:02 +0300 Subject: [PATCH 02/33] Fix build --- PdfFile/SrcWriter/FontOTWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PdfFile/SrcWriter/FontOTWriter.cpp b/PdfFile/SrcWriter/FontOTWriter.cpp index 6094e3930e..2cd23ac93e 100644 --- a/PdfFile/SrcWriter/FontOTWriter.cpp +++ b/PdfFile/SrcWriter/FontOTWriter.cpp @@ -4313,6 +4313,7 @@ namespace PdfWriter //---------------------------------------------------------------------------------------- // CCFFWriter //---------------------------------------------------------------------------------------- + const unsigned short scEmbeddedPostscript = 0xC15; struct CCFFWriter { typedef std::pair ByteAndUShort; @@ -4354,7 +4355,6 @@ namespace PdfWriter bool WriteName(const std::string& inSubsetFontName); BYTE GetMostCompressedOffsetSize(unsigned long inOffset); bool WriteTopIndex(); - static const unsigned short scEmbeddedPostscript = 0xC15; bool WriteTopDictSegment(CMemoryStream* ioTopDictSegment); bool WriteStringIndex(); bool WriteGlobalSubrsIndex(); From c3bf7ad49b45f005598558be5906ed550af3004d Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 30 Jun 2025 11:13:56 +0300 Subject: [PATCH 03/33] Fix bug 75101 --- PdfFile/SrcReader/RendererOutputDev.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/PdfFile/SrcReader/RendererOutputDev.cpp b/PdfFile/SrcReader/RendererOutputDev.cpp index 48fe5b3524..73500863b9 100644 --- a/PdfFile/SrcReader/RendererOutputDev.cpp +++ b/PdfFile/SrcReader/RendererOutputDev.cpp @@ -742,6 +742,15 @@ namespace PdfReader oFontDescriptor.dictLookup("FontBBox", &oDictItem); oDictItem.free(); + oFontDescriptor.dictLookup("Flags", &oDictItem); + if (oDictItem.isInt() && 0 != oDictItem.getInt()) + { + int nFlags = oDictItem.getInt(); + if (nFlags & 1) // моноширинный + oFontSelect.bFixedWidth = new INT(1); + } + oDictItem.free(); + oFontDescriptor.dictLookup("ItalicAngle", &oDictItem); if (oDictItem.isInt() && 0 != oDictItem.getInt()) { @@ -2414,6 +2423,7 @@ namespace PdfReader arrMatrix[4] = pNewTm[4] * pCTM[0] + pNewTm[5] * pCTM[2] + pCTM[4]; arrMatrix[5] = -(pNewTm[4] * pCTM[1] + pNewTm[5] * pCTM[3] + pCTM[5]) + pGState->getPageHeight(); + double dSize = 1; if (true) { double dNorma = std::min(sqrt(arrMatrix[0] * arrMatrix[0] + arrMatrix[1] * arrMatrix[1]), sqrt(arrMatrix[2] * arrMatrix[2] + arrMatrix[3] * arrMatrix[3])); @@ -2424,9 +2434,9 @@ namespace PdfReader arrMatrix[2] /= dNorma; arrMatrix[3] /= dNorma; - double dSize = 1; m_pRenderer->get_FontSize(&dSize); - m_pRenderer->put_FontSize(dSize * dNorma); + dSize *= dNorma; + m_pRenderer->put_FontSize(dSize); if (nRenderMode == 1 || nRenderMode == 2 || nRenderMode == 5 || nRenderMode == 6) m_pRenderer->put_PenSize(PDFCoordsToMM(pGState->getLineWidth() * dNorma)); } @@ -2491,9 +2501,12 @@ namespace PdfReader { unsigned int lUnicode = (unsigned int)wsUnicodeText[0]; long lStyle; + double dDpiX, dDpiY; m_pRenderer->get_FontStyle(&lStyle); + m_pRenderer->get_DpiX(&dDpiX); + m_pRenderer->get_DpiY(&dDpiY); m_pFontManager->SetStringGID(FALSE); - m_pFontManager->LoadFontFromFile(sFontPath, 0, dOldSize, 72, 72); + m_pFontManager->LoadFontFromFile(sFontPath, 0, dOldSize, dDpiX, dDpiY); NSFonts::IFontFile* pFontFile = m_pFontManager->GetFile(); if (pFontFile) @@ -2529,7 +2542,7 @@ namespace PdfReader return; } m_pRenderer->put_FontPath(wsFileName); - m_pFontManager->LoadFontFromFile(wsFileName, 0, dOldSize, 72, 72); + m_pFontManager->LoadFontFromFile(wsFileName, 0, dSize, dDpiX, dDpiY); bReplace = true; } } From 6ac9349ccb8d09f90d886f3bc3bdf436e8384b78 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 30 Jun 2025 13:33:19 +0300 Subject: [PATCH 04/33] Fix bug 75574 --- PdfFile/PdfReader.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/PdfFile/PdfReader.cpp b/PdfFile/PdfReader.cpp index 754d2e30be..72d20a2da4 100644 --- a/PdfFile/PdfReader.cpp +++ b/PdfFile/PdfReader.cpp @@ -596,7 +596,65 @@ bool CPdfReader::ValidMetaData() oTID.free(); bool bRes = oID2.getString()->cmp(oID.getString()) == 0; - oID.free(); oID2.free(); + oID.free(); + + int nNumXRefTables = xref->getNumXRefTables(); + if (bRes && nNumXRefTables > 1) + { + GFileOffset nOffeset = xref->getXRefTablePos(nNumXRefTables - 2); + BaseStream* str = pPDFContext->m_pDocument->getBaseStream(); + str->setPos(nOffeset); + Object oDict, obj1, obj2, obj3, obj4; + char buf[100]; + + int i, n = str->getBlock(buf, 100); + for (i = 0; i < n && Lexer::isSpace(buf[i]); ++i); + // xref table + if (i + 4 < n && buf[i] == 'x' && buf[i+1] == 'r' && buf[i+2] == 'e' && buf[i+3] == 'f' && Lexer::isSpace(buf[i+4])) + { + Stream* pSubStr = str->makeSubStream(nOffeset + i + 5, gFalse, 0, &oDict); + int c = pSubStr->getChar(); + while (c != 't') + c = pSubStr->getChar(); + pSubStr->getBlock(buf, 6); + + Parser* parser = new Parser(NULL, new Lexer(NULL, pSubStr->getBaseStream()->makeSubStream(pSubStr->getPos(), gFalse, 0, &oDict)), gTrue); + parser->getObj(&obj1); + delete parser; + delete pSubStr; + if (obj1.isDict() && obj1.dictLookup("ID", &oTID)->isArray() && oTID.arrayGet(1, &oID)->isString()) + { + bRes = oID2.getString()->cmp(oID.getString()) != 0; + } + obj1.free(); + oTID.free(); + } + else // xref stream + { + Stream* pSubStr = str->makeSubStream(nOffeset, gFalse, 0, &oDict); + Parser* parser = new Parser(NULL, new Lexer(NULL, pSubStr), gTrue); + parser->getObj(&obj1); + parser->getObj(&obj2); + parser->getObj(&obj3); + parser->getObj(&obj4); + if (obj1.isInt() && obj2.isInt() && obj3.isCmd("obj") && obj4.isStream()) + { + Dict* pPrevXRefDict = obj4.streamGetDict(); + if (pPrevXRefDict->lookup("ID", &oTID)->isArray() && oTID.arrayGet(1, &oID)->isString()) + { + bRes = oID2.getString()->cmp(oID.getString()) != 0; + } + oTID.free(); + } + obj4.free(); + obj3.free(); + obj2.free(); + obj1.free(); + delete parser; + } + } + oID2.free(); oID.free(); + return bRes; } bool CPdfReader::MergePages(BYTE* pData, DWORD nLength, const std::wstring& wsPassword, int nMaxID, const std::string& sPrefixForm) From 58be006bb9f62c1c31b2d67481d1195ef40c0360 Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Tue, 1 Jul 2025 11:37:15 +0300 Subject: [PATCH 05/33] fix bug #75635 --- OdfFile/Reader/Format/odfcontext.cpp | 8 ++--- .../Reader/Format/style_text_properties.cpp | 4 +-- OdfFile/Reader/Format/styles.cpp | 32 ++++++++++++------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/OdfFile/Reader/Format/odfcontext.cpp b/OdfFile/Reader/Format/odfcontext.cpp index 833815e0e0..5bcba151f3 100644 --- a/OdfFile/Reader/Format/odfcontext.cpp +++ b/OdfFile/Reader/Format/odfcontext.cpp @@ -387,8 +387,8 @@ namespace cpdoccore { const style_header_footer_properties_attlist& attr = headerProp->style_header_footer_properties_attlist_; _CP_OPT(double) header; - if (attr.fo_min_height_) header = attr.fo_min_height_->get_value_unit(length::pt); - else if (attr.svg_height_) header = attr.svg_height_->get_value_unit(length::pt); + if (attr.fo_min_height_) header = attr.fo_min_height_->get_value_unit(length::inch); + else if (attr.svg_height_) header = attr.svg_height_->get_value_unit(length::inch); Context.get_table_context().set_header_page(header); } @@ -398,8 +398,8 @@ namespace cpdoccore { const style_header_footer_properties_attlist& attr = footerProp->style_header_footer_properties_attlist_; _CP_OPT(double) footer; - if (attr.fo_min_height_) footer = attr.fo_min_height_->get_value_unit(length::pt); - else if (attr.svg_height_) footer = attr.svg_height_->get_value_unit(length::pt); + if (attr.fo_min_height_) footer = attr.fo_min_height_->get_value_unit(length::inch); + else if (attr.svg_height_) footer = attr.svg_height_->get_value_unit(length::inch); Context.get_table_context().set_footer_page(footer); } diff --git a/OdfFile/Reader/Format/style_text_properties.cpp b/OdfFile/Reader/Format/style_text_properties.cpp index 4464c7baa4..7266b0e249 100644 --- a/OdfFile/Reader/Format/style_text_properties.cpp +++ b/OdfFile/Reader/Format/style_text_properties.cpp @@ -557,7 +557,7 @@ void text_format_properties::drawing_serialize(std::wostream & strm, std::wstrin } void text_format_properties::xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context) { - double font_size = process_font_size_impl(fo_font_size_, NULL); + double font_size = process_font_size_impl(fo_font_size_, NULL, 1., 0.5); // sz in pt bool bBold = false, bItalic = false; if (font_size > 0) @@ -588,7 +588,7 @@ void text_format_properties::xlsx_serialize(std::wostream & strm, oox::xlsx_conv if (font) font_name = font->name(); } - //if (font_name.empty()) + if (font_name.empty()) { font_name = L"-"; } diff --git a/OdfFile/Reader/Format/styles.cpp b/OdfFile/Reader/Format/styles.cpp index 574acb2aac..9fcaef22b9 100644 --- a/OdfFile/Reader/Format/styles.cpp +++ b/OdfFile/Reader/Format/styles.cpp @@ -1518,6 +1518,15 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls header = Context.get_table_context().get_header_page(); footer = Context.get_table_context().get_footer_page(); + if (vertical_margins.fo_margin_bottom_ && vertical_margins.fo_margin_bottom_->get_type() == odf_types::length_or_percent::Length) + { + bottom = vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch); + } + if (vertical_margins.fo_margin_top_ && vertical_margins.fo_margin_top_->get_type() == odf_types::length_or_percent::Length) + { + top = vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch); + } + CP_XML_NODE(L"pageMargins") { if (horizontal_margins.fo_margin_left_ && horizontal_margins.fo_margin_left_->get_type() == odf_types::length_or_percent::Length) @@ -1528,33 +1537,32 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls CP_XML_ATTR(L"right" , horizontal_margins.fo_margin_right_->get_length().get_value_unit(odf_types::length::inch)); else CP_XML_ATTR(L"right", 0.7875); - if (vertical_margins.fo_margin_top_ && vertical_margins.fo_margin_top_->get_type() == odf_types::length_or_percent::Length) + if (top) { - top = vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch); - CP_XML_ATTR(L"top", *top); + CP_XML_ATTR(L"top", *top + header.get_value_or(0)); } else CP_XML_ATTR(L"top", 1.025); - if (vertical_margins.fo_margin_bottom_ && vertical_margins.fo_margin_bottom_->get_type() == odf_types::length_or_percent::Length) + if (bottom) { - bottom = vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch); - CP_XML_ATTR(L"bottom", *bottom); + CP_XML_ATTR(L"bottom", *bottom + footer.get_value_or(0)); } else CP_XML_ATTR(L"bottom", 1.025); if (header) { - *header = (*header / 72.0) + top.get_value_or(0); - if (*header < 0) *header = 0.7875; - CP_XML_ATTR(L"header", *header); // pt -> inch + double v = top ? *top : *header; + if (v < 0) v = 0.7875; + CP_XML_ATTR(L"header", v); } else CP_XML_ATTR(L"header", 0.7875); if (footer) { - *footer = (*footer / 72.0) + bottom.get_value_or(0); - if (*footer < 0) *footer = 0.7875; - CP_XML_ATTR(L"footer", *footer); + double v = bottom ? *bottom : *footer; + if (v < 0) v = 0.7875; + + CP_XML_ATTR(L"footer", v); } else CP_XML_ATTR(L"footer", 0.7875); } From 3047a9fb4736cd64ae51b32465df0bc8059bdd09 Mon Sep 17 00:00:00 2001 From: SimplestStudio Date: Tue, 1 Jul 2025 12:19:18 +0300 Subject: [PATCH 06/33] Fix bug 55007 --- Common/base.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/base.pri b/Common/base.pri index 8e240dfcf5..edc6698a55 100644 --- a/Common/base.pri +++ b/Common/base.pri @@ -47,7 +47,7 @@ win32 { DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR} QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME -QMAKE_TARGET_COPYRIGHT = Copyright (C) $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved +QMAKE_TARGET_COPYRIGHT = © $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved. # CONFIGURATION CONFIG(debug, debug|release) { From 17369e8bee4a9a847c907d2e2c3557f219ddabef Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Tue, 1 Jul 2025 12:30:41 +0300 Subject: [PATCH 07/33] fix bug #75568 --- MsBinaryFile/DocFile/CommentsMapping.cpp | 11 +++++++++-- MsBinaryFile/DocFile/PieceTable.cpp | 11 +++++++++-- MsBinaryFile/DocFile/WordDocument.cpp | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/MsBinaryFile/DocFile/CommentsMapping.cpp b/MsBinaryFile/DocFile/CommentsMapping.cpp index 092c131350..256aa5e9c1 100644 --- a/MsBinaryFile/DocFile/CommentsMapping.cpp +++ b/MsBinaryFile/DocFile/CommentsMapping.cpp @@ -169,10 +169,17 @@ namespace DocFileFormat { m_pXmlWriter->WriteNodeBegin( L"w15:commentEx", TRUE ); - m_pXmlWriter->WriteAttribute( L"w15:paraId", arrParaId[index]); + if (index < arrParaId.size()) + { + m_pXmlWriter->WriteAttribute(L"w15:paraId", arrParaId[index]); + } if (m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDepth > 0) { - m_pXmlWriter->WriteAttribute( L"w15:paraIdParent", arrParaId[index + m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDiatrdParent]); + size_t ind = index + m_document->AnnotationsReferencesEx->m_ReferencesEx[index].nDiatrdParent; + if (ind < arrParaId.size()) + { + m_pXmlWriter->WriteAttribute(L"w15:paraIdParent", arrParaId[ind]); + } } m_pXmlWriter->WriteAttribute( L"w15:done", L"0"); m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); diff --git a/MsBinaryFile/DocFile/PieceTable.cpp b/MsBinaryFile/DocFile/PieceTable.cpp index cf49adc537..6e210aa674 100644 --- a/MsBinaryFile/DocFile/PieceTable.cpp +++ b/MsBinaryFile/DocFile/PieceTable.cpp @@ -38,8 +38,10 @@ namespace DocFileFormat { if (fib->m_FibWord97.lcbClx < 1/* || !fib->m_FibBase.fComplex*/) return; + int streamSize = wordStream->size(); + // Read the bytes of complex file information - unsigned char* clx = new unsigned char[fib->m_FibWord97.lcbClx]; + unsigned char* clx = new unsigned char[fib->m_FibWord97.lcbClx]; if (tableStream) { @@ -47,7 +49,7 @@ namespace DocFileFormat tableStream->read(clx, (int)fib->m_FibWord97.lcbClx); } - Pieces = std::list(); + Pieces = std::list(); FileCharacterPositions = new std::map(); CharacterPositions = new std::map(); @@ -86,6 +88,11 @@ namespace DocFileFormat int indexCpNext = (i+1) * 4; int cpNext = FormatUtils::BytesToInt32(piecetable, indexCpNext, lcb); + if (cpNext > streamSize) + { + cpNext = streamSize; + } + //read the PCD int indexPcd = ((n + 1) * 4) + (i * 8); unsigned char *pcdBytes = new unsigned char[8]; diff --git a/MsBinaryFile/DocFile/WordDocument.cpp b/MsBinaryFile/DocFile/WordDocument.cpp index 4066179619..79157cf43d 100644 --- a/MsBinaryFile/DocFile/WordDocument.cpp +++ b/MsBinaryFile/DocFile/WordDocument.cpp @@ -273,7 +273,7 @@ namespace DocFileFormat bDocumentCodePage = true; } } - if (nWordVersion == 0) + if (nWordVersion == 0 && !bDocumentCodePage) { nDocumentCodePage = ENCODING_UTF16; bDocumentCodePage = true; From e0840e73d2aaf3adc2e1e6cdd10a1e6370ded24b Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Tue, 1 Jul 2025 17:00:40 +0300 Subject: [PATCH 08/33] . --- MsBinaryFile/DocFile/PieceTable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MsBinaryFile/DocFile/PieceTable.cpp b/MsBinaryFile/DocFile/PieceTable.cpp index 6e210aa674..1d86090f92 100644 --- a/MsBinaryFile/DocFile/PieceTable.cpp +++ b/MsBinaryFile/DocFile/PieceTable.cpp @@ -88,9 +88,9 @@ namespace DocFileFormat int indexCpNext = (i+1) * 4; int cpNext = FormatUtils::BytesToInt32(piecetable, indexCpNext, lcb); - if (cpNext > streamSize) + if (cpNext > fib->m_FibBase.fcMac) { - cpNext = streamSize; + cpNext = fib->m_FibBase.fcMac; } //read the PCD From fd05f3b16dd5b408ea6dd9293db39ad8402ed4ca Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Tue, 1 Jul 2025 17:18:46 +0300 Subject: [PATCH 09/33] fix bug #75551 --- .../Document/BinReader/BinaryReaderD.cpp | 8 +- .../Document/BinWriter/BinaryWriterD.cpp | 12 +-- .../Binary/Document/BinWriter/BinaryWriterD.h | 2 +- OOXML/DocxFormat/Logic/Paragraph.cpp | 4 +- OOXML/DocxFormat/Logic/ParagraphProperty.cpp | 5 +- OOXML/DocxFormat/Logic/SectionProperty.cpp | 74 ++++++++----------- OOXML/DocxFormat/Logic/SectionProperty.h | 20 ++--- OdfFile/Writer/Converter/DocxConverter.cpp | 26 ++----- .../Reader/OOXParagraphElementReaders.cpp | 6 +- 9 files changed, 63 insertions(+), 94 deletions(-) diff --git a/OOXML/Binary/Document/BinReader/BinaryReaderD.cpp b/OOXML/Binary/Document/BinReader/BinaryReaderD.cpp index 70a2f07c39..295239bb7d 100644 --- a/OOXML/Binary/Document/BinReader/BinaryReaderD.cpp +++ b/OOXML/Binary/Document/BinReader/BinaryReaderD.cpp @@ -1891,7 +1891,7 @@ int Binary_pPrReader::Read_pgHeader(BYTE type, long length, void* poResult) { Writers::HdrFtrItem* pHdrFtrItem = m_oFileWriter.get_headers_footers_writer().m_aHeaders[nHdrFtrIndex]; - ComplexTypes::Word::CHdrFtrRef* pRef = new ComplexTypes::Word::CHdrFtrRef(); + nullable pRef; pRef.Init(); pRef->m_oType.Init(); pRef->m_oType->SetValueFromByte(pHdrFtrItem->eType); @@ -1918,7 +1918,7 @@ int Binary_pPrReader::Read_pgFooter(BYTE type, long length, void* poResult) { Writers::HdrFtrItem* pHdrFtrItem = oBinary_HdrFtrTableReader.m_oHeaderFooterWriter.m_aFooters[nHdrFtrIndex]; - ComplexTypes::Word::CHdrFtrRef* pRef = new ComplexTypes::Word::CHdrFtrRef(); + nullable pRef; pRef.Init(); pRef->m_oType.Init(); pRef->m_oType->SetValueFromByte(pHdrFtrItem->eType); @@ -2016,8 +2016,8 @@ int Binary_pPrReader::ReadCols(BYTE type, long length, void* poResult) } else if ( c_oSerProp_Columns::Column == type ) { - ComplexTypes::Word::CColumn* pCol = new ComplexTypes::Word::CColumn(); - READ1_DEF(length, res, this->ReadCol, pCol); + nullable pCol; pCol.Init(); + READ1_DEF(length, res, this->ReadCol, pCol.GetPointer()); pCols->m_arrColumns.push_back(pCol); } else diff --git a/OOXML/Binary/Document/BinWriter/BinaryWriterD.cpp b/OOXML/Binary/Document/BinWriter/BinaryWriterD.cpp index 7aa5530d9b..6d72aa7bf2 100644 --- a/OOXML/Binary/Document/BinWriter/BinaryWriterD.cpp +++ b/OOXML/Binary/Document/BinWriter/BinaryWriterD.cpp @@ -1672,18 +1672,18 @@ void Binary_pPrWriter::WritePageMargin(OOX::Logic::CSectionProperty* pSectPr) } } } -void Binary_pPrWriter::WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr, std::vector& aRefs, bool bHdr) +void Binary_pPrWriter::WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr, std::vector>& aRefs, bool bHdr) { int nCurPos = 0; for (size_t i = 0, length = aRefs.size(); i < length; ++i) { - const ComplexTypes::Word::CHdrFtrRef& oRef = *aRefs[i]; - if ( oRef.m_oType.IsInit() && oRef.m_oId.IsInit()) + nullable& oRef = aRefs[i]; + if (oRef.IsInit() && oRef->m_oType.IsInit() && oRef->m_oId.IsInit()) { int nIndex = 0; OOX::CHdrFtr* pHdrFtr = NULL; - smart_ptr oFile = m_oBinaryHeaderFooterTableWriter->m_oDocumentRelsWriter->Find(oRef.m_oId->GetValue()); + smart_ptr oFile = m_oBinaryHeaderFooterTableWriter->m_oDocumentRelsWriter->Find(oRef->m_oId->GetValue()); if (oFile.IsInit() && (OOX::FileTypes::Header == oFile->type() || OOX::FileTypes::Footer == oFile->type())) { pHdrFtr = (OOX::CHdrFtr*)oFile.GetPointer(); @@ -1695,14 +1695,14 @@ void Binary_pPrWriter::WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr, { nIndex = (int)m_oBinaryHeaderFooterTableWriter->m_aHeaders.size(); m_oBinaryHeaderFooterTableWriter->m_aHeaders.push_back(pHdrFtr); - m_oBinaryHeaderFooterTableWriter->m_aHeaderTypes.push_back(oRef.m_oType->GetValue()); + m_oBinaryHeaderFooterTableWriter->m_aHeaderTypes.push_back(oRef->m_oType->GetValue()); m_oBinaryHeaderFooterTableWriter->m_aHeaderSectPrs.push_back(pSectPr); } else { nIndex = (int)m_oBinaryHeaderFooterTableWriter->m_aFooters.size(); m_oBinaryHeaderFooterTableWriter->m_aFooters.push_back(pHdrFtr); - m_oBinaryHeaderFooterTableWriter->m_aFooterTypes.push_back(oRef.m_oType->GetValue()); + m_oBinaryHeaderFooterTableWriter->m_aFooterTypes.push_back(oRef->m_oType->GetValue()); m_oBinaryHeaderFooterTableWriter->m_aFooterSectPrs.push_back(pSectPr); } nCurPos = m_oBcw.WriteItemStart(c_oSerProp_secPrType::hdrftrelem); diff --git a/OOXML/Binary/Document/BinWriter/BinaryWriterD.h b/OOXML/Binary/Document/BinWriter/BinaryWriterD.h index 38d742f38f..2e39ec9758 100644 --- a/OOXML/Binary/Document/BinWriter/BinaryWriterD.h +++ b/OOXML/Binary/Document/BinWriter/BinaryWriterD.h @@ -199,7 +199,7 @@ namespace BinDocxRW void WritePageSettings(OOX::Logic::CSectionProperty* pSectPr); void WritePageSize(OOX::Logic::CSectionProperty* pSectPr); void WritePageMargin(OOX::Logic::CSectionProperty* pSectPr); - void WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr, std::vector& aRefs, bool bHdr); + void WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr, std::vector< nullable>& aRefs, bool bHdr); void WritePageNumType(const ComplexTypes::Word::CPageNumber& pPageNumber); void WriteLineNumType(const ComplexTypes::Word::CLineNumber& pLineNumber); void WriteSectPrChange(const OOX::Logic::CSectPrChange& sectPrChange); diff --git a/OOXML/DocxFormat/Logic/Paragraph.cpp b/OOXML/DocxFormat/Logic/Paragraph.cpp index a1dcf4c085..347854242e 100644 --- a/OOXML/DocxFormat/Logic/Paragraph.cpp +++ b/OOXML/DocxFormat/Logic/Paragraph.cpp @@ -333,10 +333,8 @@ namespace OOX { CParagraphProperty prop2(document); prop2.fromXML(oReader); - - CParagraphProperty newProp = CParagraphProperty::Merge(*m_oParagraphProperty, prop2); - pItem = m_oParagraphProperty = new CParagraphProperty(newProp); + pItem = m_oParagraphProperty = new CParagraphProperty(CParagraphProperty::Merge(*m_oParagraphProperty, prop2)); m_arrItems.push_back( pItem ); continue; } diff --git a/OOXML/DocxFormat/Logic/ParagraphProperty.cpp b/OOXML/DocxFormat/Logic/ParagraphProperty.cpp index 5f4d01af35..ecfb005ba0 100644 --- a/OOXML/DocxFormat/Logic/ParagraphProperty.cpp +++ b/OOXML/DocxFormat/Logic/ParagraphProperty.cpp @@ -939,7 +939,10 @@ namespace OOX oProperties.m_oPPrChange = Merge(oPrev.m_oPPrChange, oCurrent.m_oPPrChange); oProperties.m_oPStyle = Merge(oPrev.m_oPStyle, oCurrent.m_oPStyle); oProperties.m_oRPr = Merge(oPrev.m_oRPr, oCurrent.m_oRPr); - oProperties.m_oSectPr = Merge(oPrev.m_oSectPr, oCurrent.m_oSectPr); + if (oCurrent.m_oSectPr.IsInit() && oPrev.m_oSectPr.IsInit()) + oProperties.m_oSectPr = OOX::Logic::CSectionProperty::Merge(oPrev.m_oSectPr.get(), oCurrent.m_oSectPr.get()); + else + oProperties.m_oSectPr = Merge(oPrev.m_oSectPr, oCurrent.m_oSectPr); oProperties.m_oShd = Merge(oPrev.m_oShd, oCurrent.m_oShd); oProperties.m_oSnapToGrid = Merge(oPrev.m_oSnapToGrid, oCurrent.m_oSnapToGrid); diff --git a/OOXML/DocxFormat/Logic/SectionProperty.cpp b/OOXML/DocxFormat/Logic/SectionProperty.cpp index 7b285e12f0..45f1c0a919 100644 --- a/OOXML/DocxFormat/Logic/SectionProperty.cpp +++ b/OOXML/DocxFormat/Logic/SectionProperty.cpp @@ -986,12 +986,6 @@ namespace OOX } CColumns::~CColumns() { - for ( unsigned int nIndex = 0; nIndex < m_arrColumns.size(); nIndex++ ) - { - if ( m_arrColumns[nIndex] ) delete m_arrColumns[nIndex]; - m_arrColumns[nIndex] = NULL; - } - m_arrColumns.clear(); } void CColumns::fromXML(XmlUtils::CXmlNode& oNode) { @@ -1006,13 +1000,13 @@ namespace OOX { for ( size_t nIndex = 0; nIndex < oCols.size(); nIndex++ ) { - XmlUtils::CXmlNode& oCol = oCols[nIndex]; - if ( oCol.IsValid() ) + XmlUtils::CXmlNode& oColNode = oCols[nIndex]; + if (oColNode.IsValid() ) { - ComplexTypes::Word::CColumn *oColumn = new ComplexTypes::Word::CColumn(); - *oColumn = oCol; + nullable oColumn; oColumn.Init(); + oColumn->FromXML(oColNode); - if (oColumn) m_arrColumns.push_back( oColumn ); + m_arrColumns.push_back( oColumn ); } } } @@ -1030,10 +1024,10 @@ namespace OOX std::wstring sName = oReader.GetName(); if ( L"w:col" == sName ) { - ComplexTypes::Word::CColumn *oColumn = new ComplexTypes::Word::CColumn(); - *oColumn = oReader; + nullable oColumn; oColumn.Init(); + oColumn->FromXML(oReader); - if (oColumn) m_arrColumns.push_back( oColumn ); + m_arrColumns.push_back( oColumn ); } } } @@ -1072,7 +1066,7 @@ namespace OOX for ( unsigned int nIndex = 0; nIndex < m_arrColumns.size(); nIndex++ ) { sResult += L"ToString(); sResult += L"/>"; } @@ -1502,19 +1496,6 @@ namespace OOX } void CSectionProperty::ClearItems() { - for ( unsigned int nIndex = 0; nIndex < m_arrFooterReference.size(); nIndex++ ) - { - if ( m_arrFooterReference[nIndex] ) delete m_arrFooterReference[nIndex]; - m_arrFooterReference[nIndex] = NULL; - } - m_arrFooterReference.clear(); - - for ( unsigned int nIndex = 0; nIndex < m_arrHeaderReference.size(); nIndex++ ) - { - if ( m_arrHeaderReference[nIndex] ) delete m_arrHeaderReference[nIndex]; - m_arrHeaderReference[nIndex] = NULL; - } - m_arrHeaderReference.clear(); } CSectionProperty& CSectionProperty::operator =(const XmlUtils::CXmlNode& oNode) { @@ -1562,10 +1543,10 @@ namespace OOX XmlUtils::CXmlNode& oNode = oNodes[nIndex]; if ( oNode.IsValid() ) { - ComplexTypes::Word::CHdrFtrRef *oFooter = new ComplexTypes::Word::CHdrFtrRef(); + nullable oFooter; oFooter.Init(); oFooter->FromXML(oNode); - if (oFooter) m_arrFooterReference.push_back( oFooter ); + m_arrFooterReference.push_back( oFooter ); } } } @@ -1587,10 +1568,10 @@ namespace OOX XmlUtils::CXmlNode& oNode = oNodes[nIndex]; if ( oNode.IsValid()) { - ComplexTypes::Word::CHdrFtrRef *oHeader = new ComplexTypes::Word::CHdrFtrRef(); + nullable < ComplexTypes::Word::CHdrFtrRef> oHeader; oHeader.Init(); oHeader->FromXML(oNode); - if (oHeader) m_arrHeaderReference.push_back( oHeader ); + m_arrHeaderReference.push_back( oHeader ); } } } @@ -1661,10 +1642,10 @@ namespace OOX m_oEndnotePr = oReader; else if ( !m_bSectPrChange && L"w:footerReference" == sName ) { - ComplexTypes::Word::CHdrFtrRef *oFooter = new ComplexTypes::Word::CHdrFtrRef(); - *oFooter = oReader; + nullable oFooter; oFooter.Init(); + oFooter->FromXML(oReader); - if (oFooter) m_arrFooterReference.push_back( oFooter ); + m_arrFooterReference.push_back( oFooter ); } else if ( L"w:footnotePr" == sName ) m_oFootnotePr = oReader; @@ -1672,10 +1653,10 @@ namespace OOX m_oFormProt = oReader; else if ( !m_bSectPrChange && L"w:headerReference" == sName ) { - ComplexTypes::Word::CHdrFtrRef *oHeader = new ComplexTypes::Word::CHdrFtrRef(); - *oHeader = oReader; + nullable < ComplexTypes::Word::CHdrFtrRef> oHeader; oHeader.Init(); + oHeader->FromXML(oReader); - if (oHeader) m_arrHeaderReference.push_back( oHeader ); + m_arrHeaderReference.push_back( oHeader ); } else if ( L"w:lnNumType" == sName ) m_oLnNumType = oReader; @@ -1710,10 +1691,10 @@ namespace OOX CDocxFlat* docx_flat = dynamic_cast(document); if (docx_flat) { - ComplexTypes::Word::CHdrFtrRef *pHeaderRef = new ComplexTypes::Word::CHdrFtrRef(); + nullable pHeaderRef; pHeaderRef.Init(); NSCommon::smart_ptr pHeader = new OOX::CHdrFtr(document); - if (pHeaderRef && pHeader.IsInit()) + if (pHeaderRef.IsInit() && pHeader.IsInit()) { OOX::IFileContainer* oldContainer = docx_flat->m_currentContainer; docx_flat->m_currentContainer = dynamic_cast(pHeader.GetPointer()); @@ -1735,10 +1716,10 @@ namespace OOX CDocxFlat* docx_flat = dynamic_cast(document); if (docx_flat) { - ComplexTypes::Word::CHdrFtrRef *pFooterRef = new ComplexTypes::Word::CHdrFtrRef(); + nullable pFooterRef; pFooterRef.Init(); NSCommon::smart_ptr pFooter = new OOX::CHdrFtr(document); - if (pFooter.IsInit() && pFooterRef) + if (pFooter.IsInit() && pFooterRef.IsInit()) { OOX::IFileContainer* oldContainer = docx_flat->m_currentContainer; docx_flat->m_currentContainer = dynamic_cast(pFooter.GetPointer()); @@ -1783,14 +1764,14 @@ namespace OOX for (size_t nIndex = 0; nIndex < m_arrHeaderReference.size(); nIndex++) { sResult += (L"ToString(); sResult += (L"/>"); } for (size_t nIndex = 0; nIndex < m_arrFooterReference.size(); nIndex++) { sResult += (L"ToString(); sResult += (L"/>"); } @@ -1891,6 +1872,11 @@ namespace OOX WritingElement_ReadAttributes_Read_else_if( oReader, (L"w:rsidSect"), m_oRsidSect ) WritingElement_ReadAttributes_End( oReader ) } + const CSectionProperty CSectionProperty::Merge(const CSectionProperty& oPrev, const CSectionProperty& oCurrent) + { + // ??? ну не хорошо это + return oPrev; + } } // Logic } diff --git a/OOXML/DocxFormat/Logic/SectionProperty.h b/OOXML/DocxFormat/Logic/SectionProperty.h index ef2907f7c2..27c7aa490f 100644 --- a/OOXML/DocxFormat/Logic/SectionProperty.h +++ b/OOXML/DocxFormat/Logic/SectionProperty.h @@ -54,12 +54,10 @@ namespace ComplexTypes virtual std::wstring ToString() const; - private: - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - - public: nullable m_oSpace; nullable m_oW; + private: + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); }; //-------------------------------------------------------------------------------- @@ -351,23 +349,20 @@ namespace OOX CColumns(); virtual ~CColumns(); - public: virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); virtual std::wstring toXML() const; virtual EElementType getType () const; - private: - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - - public: nullable m_oEqualWidth; nullable m_oNum; nullable m_oSep; nullable m_oSpace; - std::vector m_arrColumns; + std::vector< nullable> m_arrColumns; + private: + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); }; //-------------------------------------------------------------------------------- @@ -503,6 +498,7 @@ namespace OOX virtual std::wstring toXML() const; virtual EElementType getType() const; + static const CSectionProperty Merge(const CSectionProperty& oPrev, const CSectionProperty& oCurrent); private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); @@ -518,10 +514,10 @@ namespace OOX nullable m_oCols; nullable m_oDocGrid; nullable m_oEndnotePr; - std::vector m_arrFooterReference; + std::vector< nullable> m_arrFooterReference; nullable m_oFootnotePr; nullable m_oFormProt; - std::vector m_arrHeaderReference; + std::vector< nullable> m_arrHeaderReference; nullable m_oLnNumType; nullable m_oNoEndnote; nullable m_oPaperSrc; diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index 189a808d94..57c514c159 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -1840,16 +1840,9 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi if (other->m_arrFooterReference.size() > 0) { - for (size_t i =0 ; i < props->m_arrFooterReference.size() ; i++) - { - if (props->m_arrFooterReference[i]) delete props->m_arrFooterReference[i]; - props->m_arrFooterReference[i] = NULL; - } - props->m_arrFooterReference.clear(); - for (size_t i =0 ; i < other->m_arrFooterReference.size() ; i++) { - ComplexTypes::Word::CHdrFtrRef* ref = new ComplexTypes::Word::CHdrFtrRef(); + nullable < ComplexTypes::Word::CHdrFtrRef> ref; ref.Init(); ref->m_oId= other->m_arrFooterReference[i]->m_oId; ref->m_oType= other->m_arrFooterReference[i]->m_oType; @@ -1860,17 +1853,10 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi } if (other->m_arrHeaderReference.size() > 0) { - for (size_t i =0 ; i < props->m_arrHeaderReference.size() ; i++) - { - if (props->m_arrHeaderReference[i]) delete props->m_arrHeaderReference[i]; - props->m_arrHeaderReference[i] = NULL; - } - props->m_arrHeaderReference.clear(); - for (size_t i =0 ; i < other->m_arrHeaderReference.size() ; i++) { - ComplexTypes::Word::CHdrFtrRef* ref = new ComplexTypes::Word::CHdrFtrRef(); - + nullable < ComplexTypes::Word::CHdrFtrRef> ref; ref.Init(); + ref->m_oId= other->m_arrHeaderReference[i]->m_oId; ref->m_oType= other->m_arrHeaderReference[i]->m_oType; @@ -2122,7 +2108,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty* oox_section_pr, bool b for (size_t i = 0; i < s->m_arrHeaderReference.size(); i++) { - if (s->m_arrHeaderReference[i] == NULL) continue; + if (false == s->m_arrHeaderReference[i].IsInit()) continue; int type = s->m_arrHeaderReference[i]->m_oType.IsInit() ? s->m_arrHeaderReference[i]->m_oType->GetValue() : 0; @@ -2153,7 +2139,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty* oox_section_pr, bool b for (size_t i = 0; i < s->m_arrFooterReference.size(); i++) { - if (s->m_arrFooterReference[i] == NULL) continue; + if (false == s->m_arrFooterReference[i].IsInit()) continue; int type = s->m_arrFooterReference[i]->m_oType.IsInit() ? s->m_arrFooterReference[i]->m_oType->GetValue() : 0; @@ -2267,7 +2253,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty* oox_section_pr, bool b for (size_t i = 0; i < oox_section_pr->m_oCols->m_arrColumns.size(); i++) { - if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue; + if (false == oox_section_pr->m_oCols->m_arrColumns[i].IsInit()) continue; double space = default_space_pt; if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit()) diff --git a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp index f41cd7ec4a..c2d29de5b9 100644 --- a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp +++ b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp @@ -2110,7 +2110,7 @@ bool OOXSectionPropertyReader::Parse( ReaderParameter oParam , RtfSectionPropert { RtfSectionProperty::ColumnProperty::CollumnVar oNewColumn; - if (m_ooxSectionProperty->m_oCols->m_arrColumns[i] != NULL) + if (m_ooxSectionProperty->m_oCols->m_arrColumns[i].IsInit()) { if(m_ooxSectionProperty->m_oCols->m_arrColumns[i]->m_oW.IsInit() ) oNewColumn.m_nColumnWidth = m_ooxSectionProperty->m_oCols->m_arrColumns[i]->m_oW->ToTwips(); //twips??? todooo @@ -2336,7 +2336,7 @@ bool OOXSectionPropertyReader::Parse( ReaderParameter oParam , RtfSectionPropert } for (size_t i = 0 ; i < m_ooxSectionProperty->m_arrHeaderReference.size(); i++ ) { - OOXHeaderReader oHeaderReader(m_ooxSectionProperty->m_arrHeaderReference[i]); + OOXHeaderReader oHeaderReader(m_ooxSectionProperty->m_arrHeaderReference[i].GetPointer()); if(m_ooxSectionProperty->m_arrHeaderReference[i]->m_oType.IsInit() && m_ooxSectionProperty->m_arrHeaderReference[i]->m_oId.IsInit() ) @@ -2375,7 +2375,7 @@ bool OOXSectionPropertyReader::Parse( ReaderParameter oParam , RtfSectionPropert } for (size_t i = 0 ; i < m_ooxSectionProperty->m_arrFooterReference.size(); i++ ) { - OOXHeaderReader oFooterReader(m_ooxSectionProperty->m_arrFooterReference[i]); + OOXHeaderReader oFooterReader(m_ooxSectionProperty->m_arrFooterReference[i].GetPointer()); if(m_ooxSectionProperty->m_arrFooterReference[i]->m_oType.IsInit() && m_ooxSectionProperty->m_arrFooterReference[i]->m_oId.IsInit() ) From 10a6f6e61782f59116f46c86aa5741042aa70bbd Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Wed, 2 Jul 2025 14:04:02 +0300 Subject: [PATCH 10/33] fix bug #75568 --- MsBinaryFile/DocFile/DocumentProperties.h | 5 +-- MsBinaryFile/DocFile/FileInformationBlock.cpp | 5 +-- MsBinaryFile/DocFile/FileInformationBlock.h | 2 ++ MsBinaryFile/DocFile/WordDocument.cpp | 31 +++++++++++++------ MsBinaryFile/DocFile/WordDocument.h | 3 ++ 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/MsBinaryFile/DocFile/DocumentProperties.h b/MsBinaryFile/DocFile/DocumentProperties.h index 8546453062..e858e78e7a 100644 --- a/MsBinaryFile/DocFile/DocumentProperties.h +++ b/MsBinaryFile/DocFile/DocumentProperties.h @@ -53,7 +53,9 @@ namespace DocFileFormat WordDocumentProperties( FileInformationBlock* fib, POLE::Stream* tableStream ); friend class SettingsMapping; - private: + + unsigned short cpgText; + private: // True when facing pages should be printed bool fFacingPages; // True when window control is in effect @@ -535,7 +537,6 @@ namespace DocFileFormat unsigned short grfFmtFilter; // Book fold printing: sheets per booklet short iFolioPages; - unsigned short cpgText; // Revision mark CP info int cpMinRMText; // Revision mark CP info diff --git a/MsBinaryFile/DocFile/FileInformationBlock.cpp b/MsBinaryFile/DocFile/FileInformationBlock.cpp index 98a33ab5d6..e8efc8ebfa 100644 --- a/MsBinaryFile/DocFile/FileInformationBlock.cpp +++ b/MsBinaryFile/DocFile/FileInformationBlock.cpp @@ -840,8 +840,9 @@ namespace DocFileFormat } FileInformationBlock::FileInformationBlock( VirtualStreamReader reader ) { - m_nWordVersion = 0; - m_CodePage = 1250; + m_nWordVersion = 0; + m_CodePage = 1250; + m_CodePageSaved = 0; unsigned int flag16 = 0; unsigned char flag8 = 0; diff --git a/MsBinaryFile/DocFile/FileInformationBlock.h b/MsBinaryFile/DocFile/FileInformationBlock.h index 449f39ac93..70cdc38410 100644 --- a/MsBinaryFile/DocFile/FileInformationBlock.h +++ b/MsBinaryFile/DocFile/FileInformationBlock.h @@ -506,6 +506,8 @@ namespace DocFileFormat public: int m_nWordVersion; int m_CodePage; + int m_CodePageSaved; + FibBase m_FibBase; RgW97 m_RgW97; diff --git a/MsBinaryFile/DocFile/WordDocument.cpp b/MsBinaryFile/DocFile/WordDocument.cpp index 79157cf43d..d092189e10 100644 --- a/MsBinaryFile/DocFile/WordDocument.cpp +++ b/MsBinaryFile/DocFile/WordDocument.cpp @@ -102,6 +102,7 @@ namespace DocFileFormat bDocumentCodePage = false; nDocumentCodePage = ENCODING_WINDOWS_1250; nFontsCodePage = ENCODING_WINDOWS_1250; + nDocumentCodePageInfo = 0; } WordDocument::~WordDocument() @@ -147,7 +148,7 @@ namespace DocFileFormat //------------------------------------------------------------------------------------------------------------------- FIB = new FileInformationBlock(VirtualStreamReader(WordDocumentStream, 0, false )); - if (FIB->m_FibBase.nFib) + if (FIB->m_FibBase.nFib > 0) { if (FIB->m_FibBase.nFib <= Fib1995) { @@ -171,6 +172,12 @@ namespace DocFileFormat } } } + + if (FIB->m_FibBase.nFibBack != 0x00BF && FIB->m_FibBase.nFibBack != 0x00C1) + { + bErrorFile = true; + } + bool res = false; if (FIB->m_FibBase.fWhichTblStm) @@ -256,7 +263,7 @@ namespace DocFileFormat if (document_code_page1 > 0) { - nDocumentCodePage = document_code_page1; + nDocumentCodePageInfo = nDocumentCodePage = document_code_page1; bDocumentCodePage = true; } } @@ -269,18 +276,25 @@ namespace DocFileFormat if (document_code_page2 > 0) { - nDocumentCodePage = document_code_page2; + nDocumentCodePageInfo = nDocumentCodePage = document_code_page2; bDocumentCodePage = true; } } - if (nWordVersion == 0 && !bDocumentCodePage) + if (TableStream) + { + DocProperties = new WordDocumentProperties(FIB, TableStream); + if (DocProperties && DocProperties->cpgText > 0) + { + FIB->m_CodePageSaved = DocProperties->cpgText; + } + } + if (nWordVersion == 0 && !bErrorFile) { nDocumentCodePage = ENCODING_UTF16; bDocumentCodePage = true; } - + FIB->m_CodePage = nDocumentCodePage; - if (!bDocumentCodePage && m_nUserLCID > 0) { int user_codepage = m_lcidConverter.get_codepage(m_nUserLCID); @@ -440,7 +454,6 @@ namespace DocFileFormat // Read custom tables if (TableStream) { - DocProperties = new WordDocumentProperties (FIB, TableStream); Styles = new StyleSheet (FIB, TableStream, DataStream); listTable = new ListTable (FIB, TableStream); listFormatOverrideTable = new ListFormatOverrideTable (FIB, TableStream); @@ -480,8 +493,8 @@ namespace DocFileFormat { FIB->m_FibBase.fComplex = true; // Parse the piece table and construct a list that contains all chars - m_PieceTable = new PieceTable (FIB, TableStream, WordDocumentStream ); - Text = m_PieceTable->GetAllEncodingText (WordDocumentStream); + m_PieceTable = new PieceTable (FIB, TableStream, WordDocumentStream ); + Text = m_PieceTable->GetAllEncodingText (WordDocumentStream); } if (FIB->m_FibWord97.lcbClx < 1 || ((Text) && (Text->empty()))) diff --git a/MsBinaryFile/DocFile/WordDocument.h b/MsBinaryFile/DocFile/WordDocument.h index 683a60c7a7..f3d933e0b0 100644 --- a/MsBinaryFile/DocFile/WordDocument.h +++ b/MsBinaryFile/DocFile/WordDocument.h @@ -103,6 +103,9 @@ namespace DocFileFormat int nDocumentCodePage; bool bDocumentCodePage; int nFontsCodePage; + int nDocumentCodePageInfo; + + bool bErrorFile = false; inline StructuredStorageReader* GetStorage() const { From ecab418202fd68f41a64637a13a88407e9d30cb8 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Wed, 2 Jul 2025 16:51:09 +0300 Subject: [PATCH 11/33] Fix bug 75688 --- DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp index c20a4880fc..1f0e33aec0 100644 --- a/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp +++ b/DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp @@ -99,6 +99,7 @@ WASM_EXPORT int GetErrorCode(CDrawingFile* pFile) WASM_EXPORT void Close(CDrawingFile* pFile) { delete pFile; + g_applicationFonts->GetStreams()->Clear(); NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NULL); } WASM_EXPORT BYTE* GetInfo(CDrawingFile* pFile) From 88c84ad57768d1e4a7ca70215b6cd544c4e26f8e Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 3 Jul 2025 02:04:40 +0300 Subject: [PATCH 12/33] Fix loading dicts for hyphenation --- DesktopEditor/fontengine/js/module.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DesktopEditor/fontengine/js/module.js b/DesktopEditor/fontengine/js/module.js index a71cee881c..2e40678944 100644 --- a/DesktopEditor/fontengine/js/module.js +++ b/DesktopEditor/fontengine/js/module.js @@ -917,15 +917,15 @@ function onLoadFontsModule(window, undefined) this._mapToNames = AscCommon.spellcheckGetLanguages(); let _langKey = "" + lang; - let _langName = this._mapToNames[_langKey]; - if (_langName === undefined) + let _langObj = this._mapToNames[_langKey]; + if (!_langObj || !_langObj["hyphen"] || !_langObj["name"]) { this._dictionaries[_langKey] = false; callback(); return; } - this._loadDictionaryAttemt(_langKey, _langName, callback); + this._loadDictionaryAttemt(_langKey, _langObj["name"], callback); }; this._loadDictionaryAttemt = function(langKey, langName, callback, currentAttempt) From cc9b00329e65619a216da2f52d486acdadad83f3 Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Thu, 3 Jul 2025 14:17:49 +0300 Subject: [PATCH 13/33] fix bug #75733 --- MsBinaryFile/DocFile/PieceTable.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MsBinaryFile/DocFile/PieceTable.cpp b/MsBinaryFile/DocFile/PieceTable.cpp index 1d86090f92..62e85ba31d 100644 --- a/MsBinaryFile/DocFile/PieceTable.cpp +++ b/MsBinaryFile/DocFile/PieceTable.cpp @@ -88,9 +88,9 @@ namespace DocFileFormat int indexCpNext = (i+1) * 4; int cpNext = FormatUtils::BytesToInt32(piecetable, indexCpNext, lcb); - if (cpNext > fib->m_FibBase.fcMac) + if (cpNext > streamSize) { - cpNext = fib->m_FibBase.fcMac; + cpNext = streamSize; } //read the PCD @@ -187,6 +187,8 @@ namespace DocFileFormat pcdFcEnd += (int)pcd.fc; int cb = pcdFcEnd - (int)pcd.fc; + if (cb < 0) + break; unsigned char *bytes = new unsigned char[cb]; From 3bfa3643e690775c3a3788d48be315c45ef4dc82 Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Thu, 3 Jul 2025 16:36:19 +0300 Subject: [PATCH 14/33] . --- .../ASCOfficeDrawingConverter.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp index aa6076dbb6..5bf8ce0801 100644 --- a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp +++ b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp @@ -6246,27 +6246,29 @@ void CDrawingConverter::ConvertTextVML(XmlUtils::CXmlNode &nodeTextBox, PPTX::Lo for (auto node2 : nodesDiv2) { name = node2.GetName(); - std::wstring text2 = node1.GetText(); + std::wstring text2 = node2.GetText(); - if (name == L"b") run->rPr->b = true; - else if (name == L"i") run->rPr->i = true; + if (name == L"b") + run->rPr->b = true; + else if (name == L"i") + run->rPr->i = true; if (false == text2.empty()) { text += text2; } - else - { - std::vector nodesDiv3 = node2.GetNodes(L"*"); - for (auto node3 : nodesDiv3) - { - name = node3.GetName(); - - if (name == L"b") run->rPr->b = true; - else if (name == L"i") run->rPr->i = true; - text += node3.GetText(); - } + std::vector nodesDiv3 = node2.GetNodes(L"*"); + for (auto node3 : nodesDiv3) + { + name = node3.GetName(); + + if (name == L"b") + run->rPr->b = true; + else if (name == L"i") + run->rPr->i = true; + + text += node3.GetText(); } } } From a6efd8a374e95da775e6101ec22ff22789de2160 Mon Sep 17 00:00:00 2001 From: Green Date: Thu, 3 Jul 2025 17:39:25 +0300 Subject: [PATCH 15/33] Fix bug #75673 --- HwpFile/HwpDoc/OLEdoc/CompoundFile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HwpFile/HwpDoc/OLEdoc/CompoundFile.cpp b/HwpFile/HwpDoc/OLEdoc/CompoundFile.cpp index 82f48e8e49..4786d48da6 100644 --- a/HwpFile/HwpDoc/OLEdoc/CompoundFile.cpp +++ b/HwpFile/HwpDoc/OLEdoc/CompoundFile.cpp @@ -612,8 +612,8 @@ bool CCompoundFile::ParseHeader(CHWPStream& oBuffer) oBuffer.Skip(16); // Header CLSID m_nMinorVersion = oBuffer.ReadShort(); - if (0x003E != m_nMinorVersion) - return false; //TODO:: возможно следует просто пропускать такие несоответсвия + // if (0x003E != m_nMinorVersion) + // return false; //TODO:: возможно следует просто пропускать такие несоответсвия m_nMajorVersion = oBuffer.ReadShort(); From 3d39d5837f22cc53db23fa94c30651b2b06e82ac Mon Sep 17 00:00:00 2001 From: Green Date: Thu, 3 Jul 2025 17:58:31 +0300 Subject: [PATCH 16/33] Fixed unnecessary strikethrough in hwp conversion --- HwpFile/HwpDoc/Conversion/StyleConverter.cpp | 4 ++-- HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HwpFile/HwpDoc/Conversion/StyleConverter.cpp b/HwpFile/HwpDoc/Conversion/StyleConverter.cpp index d84ef39330..320816826c 100644 --- a/HwpFile/HwpDoc/Conversion/StyleConverter.cpp +++ b/HwpFile/HwpDoc/Conversion/StyleConverter.cpp @@ -243,7 +243,7 @@ CRunnerStyle CStyleConverter::GenerateRunnerStyle(const CHWPRecordCharShape& oCh if (oCharShape.Italic()) oRunnerStyle.SetItalic(true); - if (oCharShape.StrikeOut()) + if (oCharShape.StrikeOut() && ELineStyle2::NONE != oCharShape.GetStrikeOutType()) oRunnerStyle.SetStrike(EStrikeType::Single); if (oCharShape.SuperScript()) @@ -284,7 +284,7 @@ CRunnerStyle CStyleConverter::GenerateRunnerStyle(const CHWPRecordCharShape& oCh case ELineStyle1::SOLID_3D_REVERS_LI: oRunnerStyle.SetU({EUType::Thick, oCharShape.GetUnderlineColor()}); break; } } - else if (EUnderline::CENTER == eUnderlineType) + else if (EUnderline::CENTER == eUnderlineType && !oCharShape.StrikeOut()) { if (eUnderlineStyle == ELineStyle1::DOUBLE_SLIM || eUnderlineStyle == ELineStyle1::DOUBLE_WAVE) diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp index 3c472815f3..fd470e685a 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp @@ -310,7 +310,7 @@ bool CHWPRecordCharShape::Underline() const bool CHWPRecordCharShape::StrikeOut() const { - return ELineStyle2::NONE != m_eStrikeOutShape; + return 0x01 == m_chStrikeOut; } bool CHWPRecordCharShape::SuperScript() const From 34e1dabefbc60912127bc15760fe0754efb2af92 Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Thu, 3 Jul 2025 18:37:03 +0300 Subject: [PATCH 17/33] fix bug #75722 --- MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp index b626b3dc14..e5580069fd 100644 --- a/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp +++ b/MsBinaryFile/XlsFile/Format/Logic/Biff_records/BoolErr.cpp @@ -71,7 +71,10 @@ int BoolErr::serialize(std::wostream & stream) CP_XML_NODE(L"c") { CP_XML_ATTR(L"r", ref); - CP_XML_ATTR(L"t", L"b"); + if (bes.fError) + CP_XML_ATTR(L"t", L"e"); + else + CP_XML_ATTR(L"t", L"b"); if (cell.ixfe - global_info_->cellStyleXfs_count > 0) { From 36454f4c6e9a691444de8363172b70a64e42f193 Mon Sep 17 00:00:00 2001 From: Green Date: Thu, 3 Jul 2025 18:52:52 +0300 Subject: [PATCH 18/33] Fix bug #75679 --- HwpFile/HwpDoc/HWPSection.cpp | 20 +------------------- HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/HwpFile/HwpDoc/HWPSection.cpp b/HwpFile/HwpDoc/HWPSection.cpp index 342a2dd04a..8921a247bf 100644 --- a/HwpFile/HwpDoc/HWPSection.cpp +++ b/HwpFile/HwpDoc/HWPSection.cpp @@ -630,31 +630,13 @@ int CHWPSection::ParseCtrlRecurse(CCtrl* pCurrCtrl, int nRunLevel, CHWPStream& o ParseRecurse(pNewPara, nLevel, oBuffer, 0, nVersion); } } - else if (ECtrlObjectType::Shape == pCtrl->GetCtrlType() && EShapeType::Rect == ((CCtrlGeneralShape*)pCtrl)->GetShapeType()) + else if (ECtrlObjectType::Shape == pCtrl->GetCtrlType()) { CHWPPargraph *pNewPara = CHWPPargraph::Parse(nTagNum, nLevel, nSize, oBuffer, 0, nVersion); ((CCtrlCommon*)pCtrl)->AddParagraph(pNewPara); CHWPPargraph::Parse(*pNewPara, nSize, oBuffer, 0, nVersion); ParseRecurse(pNewPara, nLevel, oBuffer, 0, nVersion); } - else if (ECtrlObjectType::Shape == pCtrl->GetCtrlType()) - { - CCtrlCommon *pCtrlCommon = (CCtrlCommon*)(pCtrl); - if (0 < pCtrlCommon->GetCaptionWidth() && pCtrlCommon->CaptionsEmpty()) - { - CCapParagraph *pNewPara = new CCapParagraph(); - pCtrlCommon->AddCaption(pNewPara); - CHWPPargraph::Parse(*pNewPara, nSize, oBuffer, 0, nVersion); - ParseRecurse(pNewPara, nLevel, oBuffer, 0, nVersion); - } - else - { - CHWPPargraph *pNewPara = CHWPPargraph::Parse(nTagNum, nLevel, nSize, oBuffer, 0, nVersion); - pCtrlCommon->AddParagraph(pNewPara); - CHWPPargraph::Parse(*pNewPara, nLevel, oBuffer, 0, nVersion); - ParseRecurse(pNewPara, nLevel, oBuffer, 0, nVersion); - } - } else if (ECtrlObjectType::HeadFoot == pCtrl->GetCtrlType()) { CHWPPargraph *pNewPara = CHWPPargraph::Parse(nTagNum, nLevel, nSize, oBuffer, 0, nVersion); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp index e28b3671cb..32451fa36c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp @@ -236,8 +236,18 @@ namespace HWP oBuffer.ReadInt(m_nObjInstanceID); oBuffer.ReadInt(m_nBlockPageBreak); - if (nSize > oBuffer.GetDistanceToLastPos(true)) + if (nSize > oBuffer.GetDistanceToLastPos()) oBuffer.ReadString(m_sObjDesc, EStringCharacter::UTF16); + + if (nSize > oBuffer.GetDistanceToLastPos()) + { + oBuffer.ReadInt(m_nCaptionAttr); + oBuffer.ReadInt(m_nCaptionWidth); + oBuffer.ReadInt(m_nCaptionSpacing); + oBuffer.ReadInt(m_nCaptionMaxW); + } + + oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true)); } CCtrlCommon::CCtrlCommon(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) From 23008b3737b2648f24525a391f127834094cb0b2 Mon Sep 17 00:00:00 2001 From: Green Date: Thu, 3 Jul 2025 19:43:13 +0300 Subject: [PATCH 19/33] Fix bug #75718 --- HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp | 53 +++---------------- 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp index c98600f13b..06250710e0 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp @@ -1652,57 +1652,15 @@ void CConverter2OOXML::WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStr if (nullptr == pCtrlShape) return; - double dScaleX = 1., dScaleY = 1.; + int nFinalWidth = pCtrlShape->GetCurWidth(); + int nFinalHeight = pCtrlShape->GetCurHeight(); - const int nOrgWidth{pCtrlShape->GetOrgWidth()}, nOrgHeight{pCtrlShape->GetOrgHeight()}; - const int nCurWidth{pCtrlShape->GetCurWidth()}, nCurHeight{pCtrlShape->GetCurHeight()}; - - if (0 != nCurWidth && 0 != nOrgWidth) - dScaleX = (double)nCurWidth / (double)nOrgWidth; - - if (0 != nCurHeight && 0 != nOrgHeight) - dScaleY = (double)nCurHeight / (double)nOrgHeight; - - if (0 != pCtrlShape->GetWidth() && 0 != nCurWidth) - dScaleX *= (double)pCtrlShape->GetWidth() / (double)nCurWidth; - - if (0 != pCtrlShape->GetHeight() && 0 != nCurHeight) - dScaleY *= (double)pCtrlShape->GetHeight() / (double)nCurHeight; - - int nFinalWidth {pCtrlShape->GetWidth() }; - int nFinalHeight{pCtrlShape->GetHeight()}; - - if (0 == nFinalWidth) + if (0 == nFinalWidth || 0 == nFinalHeight) { - if (nullptr != pWidth && 0 != *pWidth) - nFinalWidth = *pWidth; - else - nFinalWidth = nCurWidth; + nFinalWidth = std::abs(pCtrlShape->GetWidth()); + nFinalHeight = std::abs(pCtrlShape->GetHeight()); } - if (nullptr != pWidth && 0 != *pWidth) - dScaleX *= (double)*pWidth / (double)nFinalWidth; - - if (0 == nFinalHeight) - { - if (nullptr != pHeight && 0 != *pHeight) - nFinalHeight = *pHeight; - else - nFinalHeight = nCurHeight; - } - - if (nullptr != pHeight && 0 != *pHeight) - dScaleY *= (double)*pHeight / (double)nFinalHeight; - - TMatrix oFinalMatrix{pCtrlShape->GetFinalMatrix()}; - oFinalMatrix.ApplyToSize(dScaleX, dScaleY); - - nFinalWidth = ceil((double)nFinalWidth * dScaleX); - nFinalHeight = ceil((double)nFinalHeight * dScaleY); - - nFinalWidth -= (pCtrlShape->GetLeftInMargin() + pCtrlShape->GetRightInMargin()); - nFinalHeight -= (pCtrlShape->GetTopInMargin() + pCtrlShape->GetBottomInMargin()); - if (nullptr != pWidth) *pWidth = Transform::HWPUINT2OOXML(nFinalWidth); @@ -1740,6 +1698,7 @@ void CConverter2OOXML::WriteShapeWrapMode(const CCtrlCommon* pCtrlShape, NSStrin } case ETextWrap::BEHIND_TEXT: case ETextWrap::IN_FRONT_OF_TEXT: + default: { oBuilder.WriteString(L""); break; From 103c8dd575c5cc280db877113191c6d431a41bb9 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Thu, 3 Jul 2025 20:45:30 +0300 Subject: [PATCH 20/33] Fix return errors --- DesktopEditor/doctrenderer/docbuilder_p.cpp | 5 +++-- DesktopEditor/doctrenderer/docbuilder_p.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DesktopEditor/doctrenderer/docbuilder_p.cpp b/DesktopEditor/doctrenderer/docbuilder_p.cpp index 5839d377b8..c41fef4256 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.cpp +++ b/DesktopEditor/doctrenderer/docbuilder_p.cpp @@ -1273,7 +1273,7 @@ namespace NSDoctRenderer if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS) { m_pInternal->m_bIsOpenedFromSimpleJS = false; - return true; + return 0; } m_pInternal->m_nFileType = -1; @@ -1514,7 +1514,8 @@ namespace NSDoctRenderer if (nCountParameters > 2) sParams = _builder_params[2].c_str(); - this->SaveFile(nFormat, _builder_params[1].c_str(), sParams); + int nSaveError = this->SaveFile(nFormat, _builder_params[1].c_str(), sParams); + bIsNoError = (0 == nSaveError); } else if ("WriteData" == sFuncNum) { diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index 7843771637..15fab1df4b 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -927,7 +927,7 @@ namespace NSDoctRenderer COfficeFileFormatChecker oChecker; if (!oChecker.isOfficeFile(sFileCopy)) - return false; + return 1; if (oChecker.nFileType & AVS_OFFICESTUDIO_FILE_DOCUMENT) m_nFileType = 0; From dda00c3b18fc5991624898a1d1a6926d0b3558f5 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Fri, 4 Jul 2025 14:18:04 +0300 Subject: [PATCH 21/33] Fix get MK.RI & MK.IX --- PdfFile/PdfReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PdfFile/PdfReader.cpp b/PdfFile/PdfReader.cpp index 72d20a2da4..876378e611 100644 --- a/PdfFile/PdfReader.cpp +++ b/PdfFile/PdfReader.cpp @@ -1507,7 +1507,7 @@ BYTE* CPdfReader::GetButtonIcon(int nBackgroundColor, int _nPageIndex, bool bBas } oStr.free(); oResources.free(); } - else if (oAP.isDict() && (oStr.free(), true) && oAP.dictLookup(arrAPName[j], &oStr)->isStream()) + else if ((oStr.free(), true) && oMK.dictLookup("I", &oStr)->isNull() && oAP.isDict() && (oStr.free(), true) && oAP.dictLookup(arrAPName[j], &oStr)->isStream()) { // Получение единственного XObject из Resources, если возможно Object oResources; From 4770a2b22bb2a58a999ac8a08b088dd078b920f8 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Fri, 4 Jul 2025 14:27:16 +0300 Subject: [PATCH 22/33] Fix bug 75687 --- Common/OfficeFileFormatChecker2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index bf6845478a..50f30e05be 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -240,7 +240,7 @@ bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwByt documentID.clear(); - if (dwBytes < 1) + if (dwBytes < 5 || (pBuffer[0] == 'P' && pBuffer[1] == 'K')) return false; pBuffer[dwBytes - 1] = '\0'; From 1dc8990c9d1c758d566839745703366fc588ba7c Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Fri, 4 Jul 2025 17:31:44 +0300 Subject: [PATCH 23/33] fix images --- OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp b/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp index 242e22a764..6f62666178 100644 --- a/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp +++ b/OOXML/Binary/Presentation/BinaryFileReaderWriter.cpp @@ -358,6 +358,12 @@ namespace NSBinPptxRW } addit.push_back(std::make_pair(strAdditional, typeAdditional)); } + + if (pPair != m_mapImages.end()) + { + return pPair->second; + } + if (false == strExts.empty()) { m_pContentTypes->AddDefault(strExts.substr(1)); From ec906774dd55bbdd8294f62bcfbfb115fa4a5fbe Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Fri, 4 Jul 2025 23:04:18 +0300 Subject: [PATCH 24/33] Fix bug 75101 --- DesktopEditor/fontengine/ApplicationFonts.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DesktopEditor/fontengine/ApplicationFonts.cpp b/DesktopEditor/fontengine/ApplicationFonts.cpp index 3b54c8365d..018a2c1100 100644 --- a/DesktopEditor/fontengine/ApplicationFonts.cpp +++ b/DesktopEditor/fontengine/ApplicationFonts.cpp @@ -1958,6 +1958,10 @@ namespace NSFonts if (FT_Open_Face(m_internal->m_library, &oOpenArgs, nFaceIndex, &pFace)) return; + bool bIsASC = false; + if (pFace->family_name && (0 == strcmp(pFace->family_name, "ASCW3"))) + bIsASC = true; + for (int nCharMap = 0; nCharMap < pFace->num_charmaps; nCharMap++) { FT_Set_Charmap(pFace, pFace->charmaps[nCharMap]); @@ -1967,7 +1971,8 @@ namespace NSFonts while (indexG) { - pChecker->Check((int)character, indexG); + if (!bIsASC || (character < 35 || character > 255)) + pChecker->Check((int)character, indexG); character = FT_Get_Next_Char(pFace, character, &indexG); } } From 21ca48c6f65661607ec52985763367f18110fc9a Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Fri, 4 Jul 2025 23:08:11 +0300 Subject: [PATCH 25/33] Fir bug 75101 --- DesktopEditor/fontengine/ApplicationFontsWorker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/fontengine/ApplicationFontsWorker.h b/DesktopEditor/fontengine/ApplicationFontsWorker.h index ee12e5a4e2..1b91b50427 100644 --- a/DesktopEditor/fontengine/ApplicationFontsWorker.h +++ b/DesktopEditor/fontengine/ApplicationFontsWorker.h @@ -36,7 +36,7 @@ #include #include "../graphics/pro/Fonts.h" -#define ONLYOFFICE_FONTS_VERSION 12 +#define ONLYOFFICE_FONTS_VERSION 13 #define ONLYOFFICE_ALL_FONTS_VERSION 2 class CApplicationFontsWorkerBreaker From 33c6640ce07688240d6e37ca506f969a31799f1c Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 9 Jul 2025 18:15:26 +0300 Subject: [PATCH 26/33] fix bug #75754 --- .../Reader/Converter/xlsx_defined_names.cpp | 18 ++++--- OdfFile/Reader/Converter/xlsx_defined_names.h | 2 + OdfFile/Reader/Converter/xlsx_table_state.cpp | 49 ++++++++++++++++--- OdfFile/Reader/Converter/xlsx_table_state.h | 10 ++-- .../Reader/Converter/xlsx_tablecontext.cpp | 18 ++++++- OdfFile/Reader/Converter/xlsx_tablecontext.h | 6 ++- .../Converter/xlsxconversioncontext.cpp | 13 ++++- .../Reader/Converter/xlsxconversioncontext.h | 2 +- OdfFile/Reader/Format/chart_build_oox.cpp | 8 +-- OdfFile/Reader/Format/search_table_cell.cpp | 8 +-- OdfFile/Reader/Format/table.cpp | 22 +++++---- OdfFile/Reader/Format/table.h | 24 ++++----- OdfFile/Reader/Format/table_docx.cpp | 16 +++--- OdfFile/Reader/Format/table_pptx.cpp | 16 +++--- OdfFile/Reader/Format/table_xlsx.cpp | 24 +++++---- 15 files changed, 156 insertions(+), 80 deletions(-) diff --git a/OdfFile/Reader/Converter/xlsx_defined_names.cpp b/OdfFile/Reader/Converter/xlsx_defined_names.cpp index 1196f35cba..cac3955970 100644 --- a/OdfFile/Reader/Converter/xlsx_defined_names.cpp +++ b/OdfFile/Reader/Converter/xlsx_defined_names.cpp @@ -56,13 +56,16 @@ public: { oox_ref = converter.convert_named_ref(ref); } - content_.push_back(name_and_ref()); - - content_.back().name = name; - content_.back().ref = oox_ref; - content_.back().tableId = tableId; + add(name, oox_ref, tableId); } + void add(std::wstring const& name, std::wstring const& oox_ref, int tableId) + { + content_.emplace_back(); + content_.back().name = name; + content_.back().ref = oox_ref; + content_.back().tableId = tableId; + } void xlsx_serialize(std::wostream & _Wostream) { if (content_.empty()) return; @@ -120,7 +123,10 @@ void xlsx_defined_names::add(std::wstring const & name, std::wstring const & ref { return impl_->add(name, ref, formula, tableId); } - +void xlsx_defined_names::add(std::wstring const& name, std::wstring const& oox_ref, int tableId) +{ + return impl_->add(name, oox_ref, tableId); +} void xlsx_defined_names::xlsx_serialize(std::wostream & _Wostream) { return impl_->xlsx_serialize(_Wostream); diff --git a/OdfFile/Reader/Converter/xlsx_defined_names.h b/OdfFile/Reader/Converter/xlsx_defined_names.h index 518c8dc6c2..5818c31619 100644 --- a/OdfFile/Reader/Converter/xlsx_defined_names.h +++ b/OdfFile/Reader/Converter/xlsx_defined_names.h @@ -46,6 +46,8 @@ namespace oox { ~xlsx_defined_names(); void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId); + void add(std::wstring const& name, std::wstring const& oox_ref, int tableId); + void xlsx_serialize(std::wostream & _Wostream); private: diff --git a/OdfFile/Reader/Converter/xlsx_table_state.cpp b/OdfFile/Reader/Converter/xlsx_table_state.cpp index a01e144f09..bbb21ab9df 100644 --- a/OdfFile/Reader/Converter/xlsx_table_state.cpp +++ b/OdfFile/Reader/Converter/xlsx_table_state.cpp @@ -218,10 +218,22 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri } } -void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName) +void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName, bool bHeader) { for (unsigned int i = 0; i < repeated; ++i) column_default_cell_style_name_.push_back(defaultCellStyleName); + + if (bHeader) + { + if ((false == columnsHeaders_.empty()) && (columnsHeaders_.back().first + columnsHeaders_.back().second == columns_count_)) + { + columnsHeaders_.back().second += repeated; + } + else + { + columnsHeaders_.push_back(std::make_pair(columns_count_, repeated)); + } + } columns_count_ += repeated; columns_.push_back(repeated); @@ -296,16 +308,41 @@ void xlsx_table_state::end_table_column_group() { group_columns_.pop_back(); } -void xlsx_table_state::add_empty_row(int count) +void xlsx_table_state::add_empty_row(int count, bool bHeader) { + if (bHeader) + { + if ((false == rowsHeaders_.empty()) && (rowsHeaders_.back().first + rowsHeaders_.back().second == current_table_row_)) + { + rowsHeaders_.back().second += count; + } + else + { + rowsHeaders_.push_back(std::make_pair(current_table_row_ + 1, count)); + } + } current_table_row_ += count; } -void xlsx_table_state::start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName) +void xlsx_table_state::start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName, bool bHeader) { empty_row_ = true; // reset column num, column spanned style - current_table_column_ = -1; + current_table_row_++; + + if (bHeader) + { + if ((false == rowsHeaders_.empty()) && (rowsHeaders_.back().first + rowsHeaders_.back().second == current_table_row_)) + { + rowsHeaders_.back().second += 1; + } + else + { + rowsHeaders_.push_back(std::make_pair(current_table_row_, 1)); + } + } + + current_table_column_ = -1; columns_spanned_style_ = L""; row_default_cell_style_name_ = defaultCellStyleName; @@ -539,8 +576,8 @@ void xlsx_table_state::serialize_header_footer (std::wostream & strm) { CP_XML_ATTR(L"differentOddEven", 1); } - if ((header_first && header_first->attlist_.style_display_ && !header_first->content_.empty()) || - (footer_first && footer_first->attlist_.style_display_ && !footer_first->content_.empty())) + if ((header_first && header_first->attlist_.style_display_ /*&& !header_first->content_.empty()*/) || + (footer_first && footer_first->attlist_.style_display_/* && !footer_first->content_.empty()*/)) { CP_XML_ATTR(L"differentFirst", 1); } diff --git a/OdfFile/Reader/Converter/xlsx_table_state.h b/OdfFile/Reader/Converter/xlsx_table_state.h index b0ca244f7b..2d73d0285b 100644 --- a/OdfFile/Reader/Converter/xlsx_table_state.h +++ b/OdfFile/Reader/Converter/xlsx_table_state.h @@ -146,8 +146,8 @@ public: void set_protection_delete_columns(bool val); void set_protection_delete_rows(bool val); - void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName); - void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName); + void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName, bool bHeader = false); + void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName, bool bHeader = false); void set_column_break_before(); void set_column_break_after(); @@ -159,7 +159,7 @@ public: bool is_empty_row () const; void end_row (); - void add_empty_row(int count); + void add_empty_row(int count, bool bHeader = false); void set_end_table(){ bEndTable = true; } bool get_end_table(){ return bEndTable; } @@ -269,9 +269,13 @@ private: std::wstring columns_spanned_style_; std::vector rows_spanned_; + std::vector columns_; unsigned int columns_count_; double table_column_last_width_; + + std::vector> columnsHeaders_; // start, repeate + std::vector> rowsHeaders_; std::vector column_breaks_; std::vector row_breaks_; diff --git a/OdfFile/Reader/Converter/xlsx_tablecontext.cpp b/OdfFile/Reader/Converter/xlsx_tablecontext.cpp index 86ca45dda7..e15c13079d 100644 --- a/OdfFile/Reader/Converter/xlsx_tablecontext.cpp +++ b/OdfFile/Reader/Converter/xlsx_tablecontext.cpp @@ -342,6 +342,20 @@ namespace oox { { xlsx_table_states_.back()->set_protection(val, key, algorithm); } + void xlsx_table_context::set_print_area(const std::wstring& range) + { + formulasconvert::odf2oox_converter convert; + std::wstring oox_ref = convert.convert_named_ref(range, true, L" ", true); + + xlsx_conversion_context_->get_xlsx_defined_names().add(L"_xlnm.Print_Area", oox_ref, false, xlsx_table_states_.size() - 1); + } + void xlsx_table_context::set_print_titles(const std::wstring& range) + { + formulasconvert::odf2oox_converter convert; + std::wstring oox_ref = convert.convert_named_ref(range, true, L" ", true); + + xlsx_conversion_context_->get_xlsx_defined_names().add(L"_xlnm.Print_Titles", oox_ref, false, xlsx_table_states_.size() - 1); + } void xlsx_table_context::end_table() { xlsx_conversion_context_->get_dataValidations_context().clear(); @@ -386,9 +400,9 @@ namespace oox { return state()->end_covered_cell(); } - void xlsx_table_context::start_column(unsigned int repeated, const std::wstring& defaultCellStyleName) + void xlsx_table_context::start_column(unsigned int repeated, const std::wstring& defaultCellStyleName, bool bHeader) { - return state()->start_column(repeated, defaultCellStyleName); + return state()->start_column(repeated, defaultCellStyleName, bHeader); } unsigned int xlsx_table_context::columns_count() diff --git a/OdfFile/Reader/Converter/xlsx_tablecontext.h b/OdfFile/Reader/Converter/xlsx_tablecontext.h index a52a82fff4..083e160a0c 100644 --- a/OdfFile/Reader/Converter/xlsx_tablecontext.h +++ b/OdfFile/Reader/Converter/xlsx_tablecontext.h @@ -50,7 +50,9 @@ public: void start_table(const std::wstring &tableName, const std::wstring & tableStyleName, int id); void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm); - void end_table(); + void set_print_area(const std::wstring& range); + void set_print_titles(const std::wstring& range); + void end_table(); void start_cell(size_t columnsSpanned, size_t rowsSpanned); @@ -72,7 +74,7 @@ public: int current_column(); int current_row(); - void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName); + void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName, bool bHeader = false); unsigned int columns_count(); diff --git a/OdfFile/Reader/Converter/xlsxconversioncontext.cpp b/OdfFile/Reader/Converter/xlsxconversioncontext.cpp index 79bad92535..56d45d6488 100644 --- a/OdfFile/Reader/Converter/xlsxconversioncontext.cpp +++ b/OdfFile/Reader/Converter/xlsxconversioncontext.cpp @@ -546,6 +546,15 @@ bool xlsx_conversion_context::start_table(const std::wstring& tableName, const s void xlsx_conversion_context::end_table() { + if (false == get_table_context().state()->rowsHeaders_.empty()) + {//first only ??? + int header_start = get_table_context().state()->rowsHeaders_.front().first + 1; + int header_end = get_table_context().state()->rowsHeaders_.front().first + get_table_context().state()->rowsHeaders_.front().second; + + std::wstring ref = L"'" + get_table_context().state()->tableName_ + L"'!$" + std::to_wstring(header_start) + L":$" + std::to_wstring(header_end); + get_table_context().set_print_titles(ref); + } + const std::wstring external_ref = current_sheet().external_ref(); if (false == external_ref.empty()) @@ -662,10 +671,10 @@ void xlsx_conversion_context::add_control_props(const std::wstring & rid, const L"../ctrlProps/" + target)); } -void xlsx_conversion_context::start_table_column(unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax) +void xlsx_conversion_context::start_table_column(unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax, bool bHeader) { cMin = get_table_context().columns_count(); - get_table_context().start_column(repeated, defaultCellStyleName); + get_table_context().start_column(repeated, defaultCellStyleName, bHeader); cMax = get_table_context().columns_count(); } diff --git a/OdfFile/Reader/Converter/xlsxconversioncontext.h b/OdfFile/Reader/Converter/xlsxconversioncontext.h index 9b09fbb9b9..5fa236a3f0 100644 --- a/OdfFile/Reader/Converter/xlsxconversioncontext.h +++ b/OdfFile/Reader/Converter/xlsxconversioncontext.h @@ -108,7 +108,7 @@ public: int find_sheet_by_name(std::wstring tableName); xlsx_xml_worksheet & current_sheet(int index = -1); - void start_table_column (unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax); + void start_table_column (unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax, bool bHeader = false); void table_column_last_width (double w); double table_column_last_width (); void end_table_column (); diff --git a/OdfFile/Reader/Format/chart_build_oox.cpp b/OdfFile/Reader/Format/chart_build_oox.cpp index 11d35aa9f0..82eaa078a4 100644 --- a/OdfFile/Reader/Format/chart_build_oox.cpp +++ b/OdfFile/Reader/Format/chart_build_oox.cpp @@ -1178,7 +1178,7 @@ void process_build_object::visit(table_table& val) } void process_build_object::visit(table_table_rows& val) { - ACCEPT_ALL_CONTENT(val.table_table_row_); + ACCEPT_ALL_CONTENT(val.content_); } void process_build_object::visit(table_table_row & val) @@ -1203,7 +1203,7 @@ void process_build_object::visit(table_table_column_group& val) } void process_build_object::visit(table_table_columns& val) { - ACCEPT_ALL_CONTENT(val.table_table_column_); + ACCEPT_ALL_CONTENT(val.content_); } void process_build_object::visit(table_columns_no_group& val) { @@ -1288,11 +1288,11 @@ void process_build_object::visit(table_covered_table_cell& val) } void process_build_object::visit(table_table_header_columns& val) { - ACCEPT_ALL_CONTENT(val.table_table_column_); + ACCEPT_ALL_CONTENT(val.content_); } void process_build_object::visit(table_table_header_rows& val) { - ACCEPT_ALL_CONTENT(val.table_table_row_); + ACCEPT_ALL_CONTENT(val.content_); } } } diff --git a/OdfFile/Reader/Format/search_table_cell.cpp b/OdfFile/Reader/Format/search_table_cell.cpp index dde8d877d4..9fe2fa17e1 100644 --- a/OdfFile/Reader/Format/search_table_cell.cpp +++ b/OdfFile/Reader/Format/search_table_cell.cpp @@ -143,12 +143,12 @@ public: virtual void visit(const table_table_columns& val) { - ACCEPT_ALL_CONTENT_CONST(val.table_table_column_, stop_); + ACCEPT_ALL_CONTENT_CONST(val.content_, stop_); } virtual void visit(const table_table_header_columns& val) { - ACCEPT_ALL_CONTENT_CONST(val.table_table_column_, stop_); + ACCEPT_ALL_CONTENT_CONST(val.content_, stop_); } virtual void visit(const table_table_column_group& val) @@ -191,12 +191,12 @@ public: virtual void visit(const table_table_header_rows& val) { - ACCEPT_ALL_CONTENT_CONST(val.table_table_row_, stop_); + ACCEPT_ALL_CONTENT_CONST(val.content_, stop_); } virtual void visit(const table_table_rows& val) { - ACCEPT_ALL_CONTENT_CONST(val.table_table_row_, stop_); + ACCEPT_ALL_CONTENT_CONST(val.content_, stop_); } virtual void visit(const table_table_row& val) diff --git a/OdfFile/Reader/Format/table.cpp b/OdfFile/Reader/Format/table.cpp index 4182e9a6a0..edc0cdfc40 100644 --- a/OdfFile/Reader/Format/table.cpp +++ b/OdfFile/Reader/Format/table.cpp @@ -59,8 +59,7 @@ void table_table_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu CP_APPLY_ATTR(L"table:protection-key-digest-algorithm", table_protection_key_digest_algorithm_); CP_APPLY_ATTR(L"table:print", table_print_, true); - CP_APPLY_ATTR(L"table:print-ranges", table_print_ranges_); - + CP_APPLY_ATTR(L"table:print-ranges", table_print_ranges_); CP_APPLY_ATTR(L"table:use-first-row-styles", table_use_first_row_styles_, false); CP_APPLY_ATTR(L"table:use-last-row-styles", table_use_last_row_styles_, false); @@ -263,7 +262,7 @@ void table_table_columns::add_child_element( xml::sax * Reader, const std::wstri { if CP_CHECK_NAME(L"table", L"table-column") { - CP_CREATE_ELEMENT(table_table_column_); + CP_CREATE_ELEMENT(content_); } else CP_NOT_APPLICABLE_ELM(); @@ -282,7 +281,12 @@ void table_table_header_columns::add_child_element( xml::sax * Reader, const std { if CP_CHECK_NAME(L"table", L"table-column") { - CP_CREATE_ELEMENT(table_table_column_); + CP_CREATE_ELEMENT(content_); + table_table_column* col = dynamic_cast(content_.back().get()); + if (col) + { + col->bHeader = true; + } } else CP_NOT_APPLICABLE_ELM(); @@ -549,7 +553,7 @@ const wchar_t * table_table_rows::name = L"table-rows"; std::wostream & table_table_rows::text_to_stream(std::wostream & _Wostream, bool bXmlEncode) const { - return CP_SERIALIZE_TEXT(table_table_row_, bXmlEncode); + return CP_SERIALIZE_TEXT(content_, bXmlEncode); } void table_table_rows::add_attributes( const xml::attributes_wc_ptr & Attributes ) @@ -558,7 +562,7 @@ void table_table_rows::add_attributes( const xml::attributes_wc_ptr & Attributes void table_table_rows::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - CP_CREATE_ELEMENT(table_table_row_); + CP_CREATE_ELEMENT(content_); } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -568,7 +572,7 @@ const wchar_t * table_table_header_rows::name = L"table-header-rows"; std::wostream & table_table_header_rows::text_to_stream(std::wostream & _Wostream, bool bXmlEncode) const { - return serialize_elements_text(_Wostream, table_table_row_, bXmlEncode); + return serialize_elements_text(_Wostream, content_, bXmlEncode); } void table_table_header_rows::add_attributes( const xml::attributes_wc_ptr & Attributes ) @@ -579,9 +583,9 @@ void table_table_header_rows::add_child_element( xml::sax * Reader, const std::w { if CP_CHECK_NAME(L"table", L"table-row") { - CP_CREATE_ELEMENT(table_table_row_); + CP_CREATE_ELEMENT(content_); - table_table_row* row = dynamic_cast(table_table_row_.back().get()); + table_table_row* row = dynamic_cast(content_.back().get()); if (row) row->bHeader = true; } diff --git a/OdfFile/Reader/Format/table.h b/OdfFile/Reader/Format/table.h index cffff2c6be..da8db4eab8 100644 --- a/OdfFile/Reader/Format/table.h +++ b/OdfFile/Reader/Format/table.h @@ -252,8 +252,8 @@ private: virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); public: - table_table_column_attlist attlist_; - + bool bHeader = false; + table_table_column_attlist attlist_; }; CP_REGISTER_OFFICE_ELEMENT2(table_table_column); @@ -275,7 +275,7 @@ private: virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); public: - office_element_ptr_array table_table_column_; + office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_table_columns); @@ -298,7 +298,7 @@ private: virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); public: - office_element_ptr_array table_table_column_; + office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_table_header_columns); @@ -454,7 +454,6 @@ public: table_table_cell_attlist attlist_; table_table_cell_content content_; - }; CP_REGISTER_OFFICE_ELEMENT2(table_covered_table_cell); @@ -483,8 +482,7 @@ private: virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); public: - office_element_ptr_array table_table_row_; - + office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_table_rows); @@ -510,8 +508,7 @@ private: virtual void add_text(const std::wstring & Text); public: - office_element_ptr_array table_table_row_; - + office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_table_header_rows); @@ -562,8 +559,7 @@ public: table_rows table_rows_1_; office_element_ptr table_table_header_rows_; - table_rows table_rows_2_; - + table_rows table_rows_2_; }; class table_rows_and_groups @@ -578,7 +574,7 @@ public: void xlsx_convert(oox::xlsx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context); - office_element_ptr_array content_; + office_element_ptr_array content_; }; class table_table_row_group_attlist @@ -586,8 +582,7 @@ class table_table_row_group_attlist public: void add_attributes( const xml::attributes_wc_ptr & Attributes ); - bool table_display_; // default true - + bool table_display_; // default true }; //-------------------------------------------------------------------------------------------- class table_table_row_group : public office_element_impl @@ -613,7 +608,6 @@ private: public: table_table_row_group_attlist attlist_; table_rows_and_groups table_rows_and_groups_; - }; CP_REGISTER_OFFICE_ELEMENT2(table_table_row_group); //-------------------------------------------------------------------------------------------- diff --git a/OdfFile/Reader/Format/table_docx.cpp b/OdfFile/Reader/Format/table_docx.cpp index 42771a3e5a..91ef79017a 100644 --- a/OdfFile/Reader/Format/table_docx.cpp +++ b/OdfFile/Reader/Format/table_docx.cpp @@ -136,17 +136,17 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context) void table_table_rows::docx_convert(oox::docx_conversion_context & Context) { - for (size_t i = 0; i < table_table_row_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_row_[i]->docx_convert(Context); + content_[i]->docx_convert(Context); } } void table_table_header_rows::docx_convert(oox::docx_conversion_context & Context) { - for (size_t i = 0; i < table_table_row_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_row_[i]->docx_convert(Context); + content_[i]->docx_convert(Context); } } @@ -248,9 +248,9 @@ void table_columns::docx_convert(oox::docx_conversion_context & Context) void table_table_columns::docx_convert(oox::docx_conversion_context & Context) { - for (size_t i = 0; i < table_table_column_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_column_[i]->docx_convert(Context); + content_[i]->docx_convert(Context); } } @@ -278,9 +278,9 @@ void table_columns_and_groups::docx_convert(oox::docx_conversion_context & Conte void table_table_header_columns::docx_convert(oox::docx_conversion_context & Context) { - for (size_t i = 0; i < table_table_column_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_column_[i]->docx_convert(Context); + content_[i]->docx_convert(Context); } } diff --git a/OdfFile/Reader/Format/table_pptx.cpp b/OdfFile/Reader/Format/table_pptx.cpp index 8689f96959..25c1e6bb4b 100644 --- a/OdfFile/Reader/Format/table_pptx.cpp +++ b/OdfFile/Reader/Format/table_pptx.cpp @@ -119,17 +119,17 @@ void table_table_row::pptx_convert(oox::pptx_conversion_context & Context) void table_table_rows::pptx_convert(oox::pptx_conversion_context & Context) { - for (size_t i = 0; i < table_table_row_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_row_[i]->pptx_convert(Context); + content_[i]->pptx_convert(Context); } } void table_table_header_rows::pptx_convert(oox::pptx_conversion_context & Context) { - for (size_t i = 0; i < table_table_row_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_row_[i]->pptx_convert(Context); + content_[i]->pptx_convert(Context); } } @@ -300,9 +300,9 @@ void table_columns::pptx_convert(oox::pptx_conversion_context & Context) void table_table_columns::pptx_convert(oox::pptx_conversion_context & Context) { - for (size_t i = 0; i < table_table_column_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_column_[i]->pptx_convert(Context); + content_[i]->pptx_convert(Context); } } @@ -326,9 +326,9 @@ void table_columns_and_groups::pptx_convert(oox::pptx_conversion_context & Conte void table_table_header_columns::pptx_convert(oox::pptx_conversion_context & Context) { - for (size_t i = 0; i < table_table_column_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_column_[i]->pptx_convert(Context); + content_[i]->pptx_convert(Context); } } diff --git a/OdfFile/Reader/Format/table_xlsx.cpp b/OdfFile/Reader/Format/table_xlsx.cpp index 9be071da12..a441aa0eeb 100644 --- a/OdfFile/Reader/Format/table_xlsx.cpp +++ b/OdfFile/Reader/Format/table_xlsx.cpp @@ -87,13 +87,13 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context) if (attlist_.table_number_rows_repeated_ > 1 && empty()) { - Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_); + Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_, bHeader); return; } if (attlist_.table_number_rows_repeated_ > 0x0f00 && empty_content_cells(false) || bEndTable)//0xf000 - conv_KDZO3J3xLIbZ5fC0HR0__xlsx.ods { Context.get_table_context().state()->set_end_table(); - Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_); + Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_, bHeader); return; //conv_hSX8n3lVbhALjt0aafg__xlsx.ods, conv_MA2CauoNfX_7ejKS5eg__xlsx.ods } @@ -176,7 +176,7 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context) for (unsigned int i = 0; i < attlist_.table_number_rows_repeated_; ++i) { - Context.get_table_context().state()->start_row(rowStyleName, defaultCellStyleName); + Context.get_table_context().state()->start_row(rowStyleName, defaultCellStyleName, bHeader); if (bBreakBefore) Context.get_table_context().state()->set_row_break_before(); if (bBreakAfter) Context.get_table_context().state()->set_row_break_after(); @@ -266,17 +266,17 @@ void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context) void table_table_rows::xlsx_convert(oox::xlsx_conversion_context & Context) { - for (size_t i = 0; i < table_table_row_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_row_[i]->xlsx_convert(Context); + content_[i]->xlsx_convert(Context); } } void table_table_header_rows::xlsx_convert(oox::xlsx_conversion_context & Context) { - for (size_t i = 0; i < table_table_row_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_row_[i]->xlsx_convert(Context); + content_[i]->xlsx_convert(Context); } } @@ -393,6 +393,10 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context) } } + if (attlist_.table_print_ranges_) + { + Context.get_table_context().set_print_area(*attlist_.table_print_ranges_); + } table_columns_and_groups_.xlsx_convert(Context); // check last rows for equal style and empties - collapsed @@ -468,9 +472,9 @@ void table_columns_and_groups::xlsx_convert(oox::xlsx_conversion_context & Conte void table_table_header_columns::xlsx_convert(oox::xlsx_conversion_context & Context) { - for (size_t i = 0; i < table_table_column_.size(); i++) + for (size_t i = 0; i < content_.size(); i++) { - table_table_column_[i]->xlsx_convert(Context); + content_[i]->xlsx_convert(Context); } } @@ -503,7 +507,7 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context) int cMin = 0, cMax = 0; - Context.start_table_column(columnsRepeated, defaultCellStyleName, cMin, cMax); + Context.start_table_column(columnsRepeated, defaultCellStyleName, cMin, cMax, bHeader); if ( cMin > 16384 ) return; if ( cMax > 16384 ) return; From 2cc56a9f9fed519f69ad79221cdc1301d8dd86a5 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 9 Jul 2025 20:56:05 +0300 Subject: [PATCH 27/33] fix bug #75880 --- OdfFile/Reader/Format/table.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OdfFile/Reader/Format/table.cpp b/OdfFile/Reader/Format/table.cpp index edc0cdfc40..8e484517d8 100644 --- a/OdfFile/Reader/Format/table.cpp +++ b/OdfFile/Reader/Format/table.cpp @@ -642,7 +642,8 @@ void table_rows::remove_equals_empty() table_table_row *prev = dynamic_cast(table_table_row_[i-1].get()); table_table_row *next = dynamic_cast(table_table_row_[i].get()); - if (prev->content_.size() > 1 || next->content_.size() > 1) break; + if (prev->content_.size() > 1 || next->content_.size() > 1 ) break; + if (prev->content_.empty() || next->content_.empty()) break; if (prev->attlist_.table_style_name_.get_value_or(L"") != next->attlist_.table_style_name_.get_value_or(L"")) break; From 689eaddd5b16d5fcac0e928e6e4875a41ed7ec6b Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 9 Jul 2025 21:05:46 +0300 Subject: [PATCH 28/33] fix bug #75885 --- OdfFile/Reader/Converter/docx_conversion_context.cpp | 4 +++- OdfFile/Reader/Format/paragraph_elements.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OdfFile/Reader/Converter/docx_conversion_context.cpp b/OdfFile/Reader/Converter/docx_conversion_context.cpp index eb7eff2c8a..ba6722355e 100644 --- a/OdfFile/Reader/Converter/docx_conversion_context.cpp +++ b/OdfFile/Reader/Converter/docx_conversion_context.cpp @@ -1877,7 +1877,9 @@ static _CP_PTR(odf_reader::text_list_style) create_restarted_list_style(docx_con odf_reader::list_style_container& lists = context.root()->odf_context().listStyleContainer(); odf_reader::text_list_style* curStyle = lists.list_style_by_name(curStyleName); - _CP_PTR(odf_reader::text_list_style) newStyle = boost::make_shared(*curStyle); + + _CP_PTR(odf_reader::text_list_style) newStyle = curStyle ? boost::make_shared(*curStyle) : + boost::make_shared(); newStyle->attr_.style_name_ = newStyleName; diff --git a/OdfFile/Reader/Format/paragraph_elements.cpp b/OdfFile/Reader/Format/paragraph_elements.cpp index a146a0dd44..ce407f82e3 100644 --- a/OdfFile/Reader/Format/paragraph_elements.cpp +++ b/OdfFile/Reader/Format/paragraph_elements.cpp @@ -616,7 +616,7 @@ void span::docx_convert(oox::docx_conversion_context & Context) style_text_properties *text_props = styleContent->get_style_text_properties(); std::wstring parent = styleInst->parent_name(); - if (false == parent.empty()) + if (text_props && false == parent.empty()) { text_props->content_.r_style_ = Context.styles_map_.get(parent, styleInst->type()); } From a84491cf74071b6bcce4389b5babb6a42b1d6fb3 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Thu, 10 Jul 2025 13:36:06 +0300 Subject: [PATCH 29/33] Fix param type --- DesktopEditor/common/File.cpp | 2 +- DesktopEditor/common/File.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DesktopEditor/common/File.cpp b/DesktopEditor/common/File.cpp index 87c33c51a4..1f90016839 100644 --- a/DesktopEditor/common/File.cpp +++ b/DesktopEditor/common/File.cpp @@ -1868,7 +1868,7 @@ namespace NSFile namespace NSFile { - bool CBase64Converter::Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags) + bool CBase64Converter::Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags) { if (!pDataSrc || nLenSrc < 1) return false; diff --git a/DesktopEditor/common/File.h b/DesktopEditor/common/File.h index b232ef680d..187a3d20fa 100644 --- a/DesktopEditor/common/File.h +++ b/DesktopEditor/common/File.h @@ -212,7 +212,7 @@ namespace NSFile class KERNEL_DECL CBase64Converter { public: - static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE); + static bool Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE); static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst); }; From 5e9f0d762aa26209eaa3f8a3babd8bb1eb76045b Mon Sep 17 00:00:00 2001 From: Viktor Andreev Date: Thu, 10 Jul 2025 21:41:22 +0600 Subject: [PATCH 30/33] Fix metadata xlst conversion --- OOXML/XlsxFormat/Worksheets/SheetData.cpp | 43 ++++++++++++----------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/OOXML/XlsxFormat/Worksheets/SheetData.cpp b/OOXML/XlsxFormat/Worksheets/SheetData.cpp index 1045e7688f..161352ad3a 100644 --- a/OOXML/XlsxFormat/Worksheets/SheetData.cpp +++ b/OOXML/XlsxFormat/Worksheets/SheetData.cpp @@ -577,6 +577,7 @@ namespace OOX m_oType.SetValue(SimpleTypes::Spreadsheet::celltypeNumber); m_oShowPhonetic.FromBool(false); + m_oCellMetadata.reset(); m_oValue.Clean(); m_oFormula.Clean(); m_oRichText.reset(NULL); @@ -698,22 +699,26 @@ namespace OOX nLen += m_oRichText->getXLSBSize(); } - oStream.XlsbStartRecord(nType, nLen); - oStream.WriteULONG(m_nCol & 0x3FFF); - _UINT32 nFlags2 = m_nStyle; if (m_oShowPhonetic.ToBool()) { nFlags2 |= 0x1000000; } - //if (m_oCellMetadata.IsInit()) - //{ - // nFlags2 |= 0x2000000; - //} - //if (m_oValueMetadata.IsInit()) - //{ - // nFlags2 |= 0x4000000; - //} + if (m_oCellMetadata.IsInit()) + { + nFlags2 |= 0x2000000; + nLen += 4; + } + if (m_oValueMetadata.IsInit()) + { + nFlags2 |= 0x4000000; + nLen += 4; + } + + oStream.XlsbStartRecord(nType, nLen); + oStream.WriteULONG(m_nCol & 0x3FFF); + + oStream.WriteULONG(nFlags2); //todo RkNumber switch(nType) @@ -755,15 +760,13 @@ namespace OOX { m_oRichText->toXLSBExt(oStream); } - //it's not by XLSB format - //if (m_oCellMetadata.IsInit()) - //{ - // oStream.WriteULONG(*m_oCellMetadata); - //} - //if (m_oValueMetadata.IsInit()) - //{ - // oStream.WriteULONG(*m_oValueMetadata); - //} + + if (m_oCellMetadata.IsInit()) + { + oStream.WriteULONG(*m_oCellMetadata); + } + if (m_oValueMetadata.IsInit()) + oStream.WriteULONG(*m_oValueMetadata); oStream.XlsbEndRecord(); } From 381daebcb9b7f9d6377cd0238f23b76b13fe47ec Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Thu, 10 Jul 2025 19:21:27 +0300 Subject: [PATCH 31/33] . --- OOXML/Common/SimpleTypes_Word.cpp | 22 ++-------------------- OOXML/Common/SimpleTypes_Word.h | 1 - 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/OOXML/Common/SimpleTypes_Word.cpp b/OOXML/Common/SimpleTypes_Word.cpp index c8184b6fb5..284db1b0e7 100644 --- a/OOXML/Common/SimpleTypes_Word.cpp +++ b/OOXML/Common/SimpleTypes_Word.cpp @@ -2432,32 +2432,14 @@ namespace SimpleTypes // LongHexNumber 17.18.50 (Part 1) //-------------------------------------------------------------------------------- - int CLongHexNumber::HexToInt(int nHex, bool &bResult) - { - if ( nHex >= '0' && nHex <= '9' ) return (nHex - '0'); - if ( nHex >= 'a' && nHex <= 'f' ) return (nHex - 'a' + 10); - if ( nHex >= 'A' && nHex <= 'F' ) return (nHex - 'A' + 10); - - bResult = false; - - return 0; - } - bool CLongHexNumber::Parse(const std::wstring &sValue) { - if ( sValue.length() < 8 ) + if ( sValue.empty()) return false; bool bResult = true; - this->m_eValue = HexToInt( (int)sValue[7], bResult ); - this->m_eValue += HexToInt( (int)sValue[6], bResult ) << 4; - this->m_eValue += HexToInt( (int)sValue[5], bResult ) << 8; - this->m_eValue += HexToInt( (int)sValue[4], bResult ) << 12; - this->m_eValue += HexToInt( (int)sValue[3], bResult ) << 16; - this->m_eValue += HexToInt( (int)sValue[2], bResult ) << 20; - this->m_eValue += HexToInt( (int)sValue[1], bResult ) << 24; - this->m_eValue += HexToInt( (int)sValue[0], bResult ) << 28; + this->m_eValue = XmlUtils::GetHex(sValue); return bResult; } diff --git a/OOXML/Common/SimpleTypes_Word.h b/OOXML/Common/SimpleTypes_Word.h index cc5ce6b646..77da5b9ff8 100644 --- a/OOXML/Common/SimpleTypes_Word.h +++ b/OOXML/Common/SimpleTypes_Word.h @@ -1078,7 +1078,6 @@ namespace SimpleTypes DEFINE_SIMPLE_TYPE_START(CLongHexNumber, unsigned int, 0) private: bool Parse(const std::wstring &sValue); - int HexToInt(int nHex, bool &bResult); }; //-------------------------------------------------------------------------------- From 7e5d3bb3eb3b672b3da30075653fd0e04bde67cf Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Fri, 11 Jul 2025 09:20:57 +0300 Subject: [PATCH 32/33] fix bug #75841 --- OdfFile/Writer/Format/table.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OdfFile/Writer/Format/table.cpp b/OdfFile/Writer/Format/table.cpp index dda9e3a081..7eb00f658b 100644 --- a/OdfFile/Writer/Format/table.cpp +++ b/OdfFile/Writer/Format/table.cpp @@ -473,9 +473,13 @@ void table_columns_no_group::serialize(std::wostream & _Wostream) table_columns_1_.serialize(_Wostream); if (table_table_header_columns_) + { table_table_header_columns_->serialize(_Wostream); + } else - CP_XML_NODE(L"table:table-header-columns"); + { + //CP_XML_NODE(L"table:table-header-columns"); + } table_columns_2_.serialize(_Wostream); } From 407993cd402805f9ed3d7371e19f0344ff8d1006 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Fri, 11 Jul 2025 11:05:39 +0300 Subject: [PATCH 33/33] fix bug #73585 --- OdfFile/Writer/Converter/DocxConverter.cpp | 98 +++++++++++++------ OdfFile/Writer/Converter/DocxConverter.h | 3 +- .../Writer/Format/odt_conversion_context.cpp | 9 +- 3 files changed, 72 insertions(+), 38 deletions(-) diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index 57c514c159..db8b8ff7fb 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -739,7 +739,7 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) current_font_size.erase(current_font_size.begin() + 1, current_font_size.end()); } - bool bStyled = false; + bool bStyled = false; bool bStartNewParagraph = !odt_context->text_context()->get_KeepNextParagraph(); bool list_present = false; @@ -750,7 +750,9 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) //--------------------------------------------------------------------------------------------------------------------- std::vector> id_change_properties; - + + current_bidi_set = (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oBidi.IsInit() && oox_paragraph->m_oParagraphProperty->m_oBidi->m_oVal.ToBool()); + if (oox_paragraph->m_oParagraphProperty) {//цепочка изменений форматов в удаленных кусках либрой (и оо) не поддерживается - int id; @@ -980,7 +982,9 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) { odt_context->end_change(id_change_properties[i].second, id_change_properties[i].first); } -} + + current_bidi_set = false; + } void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87 math 17.3.2.25 { if (oox_run == NULL) return; @@ -1612,8 +1616,11 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, //if (oox_paragraph_pr->m_oRtl.IsInit()) //{ //} - - convert(oox_paragraph_pr->m_oJc.GetPointer(), paragraph_properties->fo_text_align_); + if (oox_paragraph_pr->m_oBidi.IsInit() || oox_paragraph_pr->m_oJc.IsInit()) + { + convert(oox_paragraph_pr->m_oJc.GetPointer(), oox_paragraph_pr->m_oBidi.IsInit() ? oox_paragraph_pr->m_oBidi->m_oVal.ToBool() : false, + paragraph_properties->fo_text_align_); + } if (oox_paragraph_pr->m_oTextAlignment.IsInit() && oox_paragraph_pr->m_oTextAlignment->m_oVal.IsInit()) { @@ -2623,25 +2630,33 @@ void DocxConverter::convert(ComplexTypes::Word::CBorder *borderProp, std::wstrin odf_border_prop = border_style.str() + L" #" + border_color; } -void DocxConverter::convert(ComplexTypes::Word::CJc * oox_jc, _CP_OPT(odf_types::text_align) & align) +void DocxConverter::convert(ComplexTypes::Word::CJc * oox_jc, bool bidi, _CP_OPT(odf_types::text_align) & align) { - if (oox_jc == NULL) return; - if (oox_jc->m_oVal.IsInit() == false) return; + SimpleTypes::EJc jc = SimpleTypes::jcStart; - switch(oox_jc->m_oVal->GetValue()) + if (oox_jc && oox_jc->m_oVal.IsInit()) + { + jc = oox_jc->m_oVal->GetValue(); + } + + switch(jc) { case SimpleTypes::jcBoth : align = odf_types::text_align(odf_types::text_align::Justify);break; case SimpleTypes::jcCenter : align = odf_types::text_align(odf_types::text_align::Center); break; case SimpleTypes::jcThaiDistribute : case SimpleTypes::jcDistribute : align = odf_types::text_align(odf_types::text_align::Justify);break; - case SimpleTypes::jcEnd : align = odf_types::text_align(odf_types::text_align::End); break; + case SimpleTypes::jcEnd : align = bidi ? odf_types::text_align(odf_types::text_align::Start) : + odf_types::text_align(odf_types::text_align::End); break; case SimpleTypes::jcHighKashida : break; case SimpleTypes::jcLowKashida : break; case SimpleTypes::jcMediumKashida : break; case SimpleTypes::jcNumTab : break; - case SimpleTypes::jcStart : align = odf_types::text_align(odf_types::text_align::Start); break; - case SimpleTypes::jcLeft : align = odf_types::text_align(odf_types::text_align::Left); break; - case SimpleTypes::jcRight : align = odf_types::text_align(odf_types::text_align::Right); break; + case SimpleTypes::jcStart : align = bidi ? odf_types::text_align(odf_types::text_align::End) : + odf_types::text_align(odf_types::text_align::Start); break; + case SimpleTypes::jcLeft : align = bidi ? odf_types::text_align(odf_types::text_align::Right) : + odf_types::text_align(odf_types::text_align::Left); break; + case SimpleTypes::jcRight : align = bidi ? odf_types::text_align(odf_types::text_align::Left) : + odf_types::text_align(odf_types::text_align::Right); break; } } void DocxConverter::convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf_types::length) & odf_size) @@ -2868,13 +2883,46 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::te else text_properties->fo_font_style_ = odf_types::font_style(odf_types::font_style::Normal); } + if (oox_run_pr->m_oLang.IsInit()) + { + if (oox_run_pr->m_oLang->m_oBidi.IsInit()) + { + std::wstring lang = *oox_run_pr->m_oLang->m_oBidi; + size_t split = lang.find(L"-"); + if (split != std::wstring::npos) + { + text_properties->style_language_complex_ = lang.substr(0, split); + text_properties->style_country_complex_ = lang.substr(split + 1); + } + } + + if (oox_run_pr->m_oLang->m_oVal.IsInit()) + { + std::wstring lang = *oox_run_pr->m_oLang->m_oVal; + size_t split = lang.find(L"-"); + if (split != std::wstring::npos) + { + text_properties->fo_language_ = lang.substr(0, split); + text_properties->fo_country_ = lang.substr(split + 1); + } + } + } if (oox_run_pr->m_oSz.IsInit() && oox_run_pr->m_oSz->m_oVal.IsInit() && !odt_context->in_drop_cap()) { double font_size_pt = oox_run_pr->m_oSz->m_oVal->ToPoints(); - current_font_size.push_back(font_size_pt); + + if (!current_bidi_set) current_font_size.push_back(font_size_pt); OoxConverter::convert(font_size_pt, text_properties->fo_font_size_); } + if (oox_run_pr->m_oSzCs.IsInit() && oox_run_pr->m_oSzCs->m_oVal.IsInit() && !odt_context->in_drop_cap()) + { + double font_size_pt = oox_run_pr->m_oSzCs->m_oVal->ToPoints(); + + if (current_bidi_set) current_font_size.push_back(font_size_pt); + + OoxConverter::convert(font_size_pt, text_properties->style_font_size_complex_); + } if (oox_run_pr->m_oKern.IsInit() && oox_run_pr->m_oKern->m_oVal.IsInit()) { //OoxConverter::convert(oox_run_pr->m_oSz->m_oVal->ToPoints(), text_properties->fo_font_size_); @@ -2991,20 +3039,6 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::te if (oox_run_pr->m_oVanish.IsInit()) text_properties->text_display_ = odf_types::text_display(odf_types::text_display::None); - - if (oox_run_pr->m_oLang.IsInit()) - { - if (oox_run_pr->m_oLang->m_oVal.IsInit()) - { - std::wstring lang = *oox_run_pr->m_oLang->m_oVal; - size_t split = lang.find(L"-"); - if (split != std::wstring::npos) - { - text_properties->fo_language_ = lang.substr(0, split); - text_properties->fo_country_ = lang.substr(split + 1); - } - } - } } void DocxConverter::convert(SimpleTypes::CTheme* oox_font_theme, _CP_OPT(std::wstring) & odf_font_name) @@ -3708,8 +3742,8 @@ void DocxConverter::convert_lists_styles() void DocxConverter::convert_styles() { if (!odt_context) return; - - OOX::CStyles *styles = docx_document ? docx_document->m_oMain.styles : (docx_flat_document ? docx_flat_document->m_pStyles.GetPointer() : NULL); + + OOX::CStyles* styles = docx_document ? docx_document->m_oMain.styles : (docx_flat_document ? docx_flat_document->m_pStyles.GetPointer() : NULL); if (!styles)return; //nullable m_oLatentStyles; @@ -3719,14 +3753,14 @@ void DocxConverter::convert_styles() for (size_t i = 0; i < styles->m_arrStyle.size(); i++) { if (styles->m_arrStyle[i] == NULL) continue; - + if (!current_font_size.empty()) { current_font_size.erase(current_font_size.begin() + 1, current_font_size.end()); } convert(styles->m_arrStyle[i]); - + //if (i == 0 && styles->m_arrStyle[i]->m_oDefault.IsInit() && styles->m_arrStyle[i]->m_oDefault->ToBool()) //{ // //NADIE_COMO_TU.docx тут дефолтовый стиль не прописан явно, берем тот что Normal diff --git a/OdfFile/Writer/Converter/DocxConverter.h b/OdfFile/Writer/Converter/DocxConverter.h index b5326ade41..bccf707cb5 100644 --- a/OdfFile/Writer/Converter/DocxConverter.h +++ b/OdfFile/Writer/Converter/DocxConverter.h @@ -167,6 +167,7 @@ namespace Oox2Odf void convert (OOX::WritingElement *oox_unknown); std::wstring dump_text (OOX::WritingElement *oox_unknown); private: + bool current_bidi_set = false; struct _section { OOX::Logic::CSectionProperty *props = NULL; @@ -241,7 +242,7 @@ namespace Oox2Odf void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf_types::length) & odf_size); void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf_types::length_or_percent) & odf_size); void convert(ComplexTypes::Word::CTblWidth *oox_size, _CP_OPT(odf_types::length) & odf_size); - void convert(ComplexTypes::Word::CJc *oox_jc, _CP_OPT(odf_types::text_align) & align); + void convert(ComplexTypes::Word::CJc *oox_jc, bool bidi, _CP_OPT(odf_types::text_align) & align); void convert(ComplexTypes::Word::CBorder *borderProp, std::wstring & odf_border_prop); void convert(ComplexTypes::Word::CPageBorder *borderProp, std::wstring & odf_border_prop); diff --git a/OdfFile/Writer/Format/odt_conversion_context.cpp b/OdfFile/Writer/Format/odt_conversion_context.cpp index 677cabf8af..052bb5cb45 100644 --- a/OdfFile/Writer/Format/odt_conversion_context.cpp +++ b/OdfFile/Writer/Format/odt_conversion_context.cpp @@ -79,11 +79,10 @@ odt_conversion_context::odt_conversion_context(package::odf_document * outputDoc comment_context_(this), notes_context_(this), main_text_context_(NULL), table_context_(this), controls_context_(this) { - is_hyperlink_ = false; - - is_header_ = false; - is_footer_ = false; - + is_hyperlink_ = false; + is_header_ = false; + is_footer_ = false; + is_background_ = false; is_paragraph_in_current_section_ = false; text_changes_state_.main_text_context = NULL; //header, footer, drawing, main, ..