From c252512786ef0e93362986b6c654975d6a6f3df5 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Tue, 7 Mar 2023 11:43:50 +0300 Subject: [PATCH 1/8] fix checker for binary --- Common/OfficeFileFormatChecker2.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index 1eb2575753..76de008438 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -515,26 +515,26 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) bEmptyFile = (dwReadBytes < 1); - if (isOOXFlatFormatFile(buffer, sizeRead)) + if (isBinaryDoctFormatFile(buffer, sizeRead)) // min size - 4 + { + nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_WORD; + } + else if (isBinaryXlstFormatFile(buffer, sizeRead))// min size - 4 + { + nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET; + } + else if (isBinaryPpttFormatFile(buffer, sizeRead))// min size - 4 + { + nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION; + } + else if (isOOXFlatFormatFile(buffer, sizeRead)) { //nFileType; } else if ( isRtfFormatFile(buffer,sizeRead) ) // min size - 5 { nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF; - } - else if ( isBinaryDoctFormatFile(buffer,sizeRead) ) // min size - 4 - { - nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_WORD; - } - else if ( isBinaryXlstFormatFile(buffer,sizeRead) )// min size - 4 - { - nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_SPREADSHEET; - } - else if ( isBinaryPpttFormatFile(buffer,sizeRead) )// min size - 4 - { - nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION; - } + } else if (isPdfFormatFile(buffer,sizeRead, sDocumentID) )// min size - 5 { nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF; From ad72c997f233dfb9be83432d2c871b451325c050 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Fri, 10 Mar 2023 12:18:14 +0300 Subject: [PATCH 2/8] fix bug #61459 --- MsBinaryFile/PptFile/PPTXWriter/Converter.cpp | 14 ++++++++------ MsBinaryFile/PptFile/PPTXWriter/ShapeWriter.cpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/MsBinaryFile/PptFile/PPTXWriter/Converter.cpp b/MsBinaryFile/PptFile/PPTXWriter/Converter.cpp index 5512990e2a..b66a723fd0 100644 --- a/MsBinaryFile/PptFile/PPTXWriter/Converter.cpp +++ b/MsBinaryFile/PptFile/PPTXWriter/Converter.cpp @@ -1349,13 +1349,15 @@ void CPPTXWriter::WriteColorScheme(CStringWriter& oStringWriter, const std::wstr void CPPTXWriter::WriteBackground(CStringWriter& oWriter, CRelsGenerator& oRels, CBrush& oBackground) { - oWriter.WriteString(std::wstring(L"")); - m_pShapeWriter->SetRelsGenerator(&oRels); - { - oWriter.WriteString(m_pShapeWriter->ConvertBrush(oBackground)); - } - oWriter.WriteString(std::wstring(L"")); + std::wstring sBg = m_pShapeWriter->ConvertBrush(oBackground); + + if (false == sBg.empty()) + { + oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(sBg); + oWriter.WriteString(std::wstring(L"")); + } } void CPPTXWriter::WriteGroup(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) { diff --git a/MsBinaryFile/PptFile/PPTXWriter/ShapeWriter.cpp b/MsBinaryFile/PptFile/PPTXWriter/ShapeWriter.cpp index 9d88f96ea9..15f687d573 100644 --- a/MsBinaryFile/PptFile/PPTXWriter/ShapeWriter.cpp +++ b/MsBinaryFile/PptFile/PPTXWriter/ShapeWriter.cpp @@ -2132,13 +2132,17 @@ std::wstring PPT::CShapeWriter::ConvertImage() std::to_wstring(pImageElement->m_bChildAnchorEnabled ? (int)pImageElement->m_rcChildAnchor.top : (int)pImageElement->m_rcAnchor.top) + L"\"/>"); - double width = pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetWidth() : pImageElement->m_rcAnchor.GetWidth(); - double height = pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetHeight() : pImageElement->m_rcAnchor.GetHeight(); + _INT64 width = (_INT64)(pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetWidth() : pImageElement->m_rcAnchor.GetWidth()); + _INT64 height = (_INT64)(pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetHeight() : pImageElement->m_rcAnchor.GetHeight()); - if ( width > 0 || height > 0 ) + if (( width > 0 || height > 0 ) && ((_UINT64)width) < 0xffffffffffff && ((_UINT64)height) < 0xffffffffffff) { - m_oWriter.WriteString(L""); + m_oWriter.WriteString(L""); } + else + { + m_oWriter.WriteString(L""); + } m_oWriter.WriteString(std::wstring(L"")); } m_oWriter.WriteString(std::wstring(L"")); From 12326b3a4f9d43377669bd612a21bf261501b123 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Fri, 10 Mar 2023 14:09:39 +0300 Subject: [PATCH 3/8] fix bug #61456 --- RtfFile/Format/Basic.h | 1 + RtfFile/Format/DestinationCommand.cpp | 10 +++++----- RtfFile/Format/RtfGlobalTables.cpp | 15 +++++++++------ RtfFile/Format/RtfGlobalTables.h | 4 ++-- RtfFile/Format/RtfProperty.cpp | 7 +------ RtfFile/Format/RtfProperty.h | 10 ++++++---- RtfFile/Format/RtfReader.cpp | 11 +++++++++-- .../OOXml/Reader/OOXParagraphElementReaders.cpp | 2 +- 8 files changed, 34 insertions(+), 26 deletions(-) diff --git a/RtfFile/Format/Basic.h b/RtfFile/Format/Basic.h index 4330d337f9..17e44bdcc4 100644 --- a/RtfFile/Format/Basic.h +++ b/RtfFile/Format/Basic.h @@ -203,6 +203,7 @@ public: template class ItemSingleContainer: public ItemContainer { public: + //todooo -> to map with hash int AddItem( T piRend) { for( int i = 0; i < (int)ItemContainer::m_aArray.size(); i++ ) diff --git a/RtfFile/Format/DestinationCommand.cpp b/RtfFile/Format/DestinationCommand.cpp index bf2c8f2bec..fbab984526 100644 --- a/RtfFile/Format/DestinationCommand.cpp +++ b/RtfFile/Format/DestinationCommand.cpp @@ -2345,7 +2345,7 @@ void RtfFieldReader::TryToPepairResult( RtfDocument& oDocument, RtfReader& oRead oSymbolFont.m_nID = oDocument.m_oFontTable.GetCount() + 1; oSymbolFont.m_nCodePage = CP_SYMBOL; oReader.m_oState->m_oCharProp.m_nFont = oSymbolFont.m_nID; - oDocument.m_oFontTable.DirectAddItem( oSymbolFont ); + oDocument.m_oFontTable.AddFont( oSymbolFont ); } int nSkipChar = 0; @@ -3298,7 +3298,7 @@ void RtfFontTableReader::ExecuteTextInternal2( RtfDocument& oDocument, RtfReader oDocument.m_oProperty.m_nAnsiCodePage = m_oFont.m_nCodePage; } - if (m_oFont.m_nCharset > 2 && oDocument.m_oProperty.m_nAnsiCodePage == 0) + if (m_oFont.m_nCharset != PROP_DEF && m_oFont.m_nCharset >= 0 && oDocument.m_oProperty.m_nAnsiCodePage == 0) { oDocument.m_oProperty.m_nAnsiCodePage = RtfUtility::CharsetToCodepage(m_oFont.m_nCharset); } @@ -3345,7 +3345,7 @@ void RtfFontTableReader::ExecuteText(RtfDocument& oDocument, RtfReader& oReader, } //todooo при добавлении могут быть повторы - убрать нннадо - goldwingSetting.rtf - oDocument.m_oFontTable.DirectAddItem( m_oFont ); + oDocument.m_oFontTable.AddFont( m_oFont ); m_oFont.SetDefaultRtf(); } @@ -3414,7 +3414,7 @@ void RtfColorTableReader::ExecuteText( RtfDocument& oDocument, RtfReader& oReade { if( true == m_bIsSet ) { - oDocument.m_oColorTable.DirectAddItem( oCurColor ); + oDocument.m_oColorTable.AddColor( oCurColor ); } else { @@ -3422,7 +3422,7 @@ void RtfColorTableReader::ExecuteText( RtfDocument& oDocument, RtfReader& oReade //{\colortbl\red0\blue159\green82;\red0\blue0\green0;\red255\blue255\green255;\red0\blue156\green90;\red169\blue86\green0;} //{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255; oCurColor.SetAuto(); - oDocument.m_oColorTable.DirectAddItem( oCurColor ); + oDocument.m_oColorTable.AddColor( oCurColor ); } oCurColor.SetDefaultRtf(); m_bIsSet = false; diff --git a/RtfFile/Format/RtfGlobalTables.cpp b/RtfFile/Format/RtfGlobalTables.cpp index 4527a0f187..a7915e7369 100644 --- a/RtfFile/Format/RtfGlobalTables.cpp +++ b/RtfFile/Format/RtfGlobalTables.cpp @@ -32,10 +32,9 @@ #include "RtfGlobalTables.h" #include "RtfDocument.h" -int RtfFontTable::DirectAddItem( RtfFont piRend) +void RtfFontTable::AddFont( RtfFont piRend) { m_aArray.push_back(piRend); - return (int)m_aArray.size() - 1; } bool RtfFontTable::GetFont( int nId, RtfFont& oFont) { @@ -43,6 +42,7 @@ bool RtfFontTable::GetFont( int nId, RtfFont& oFont) { if( nId == m_aArray[i].m_nID ) { + m_aArray[i].m_bUsed = true; oFont = m_aArray[i]; return true; } @@ -55,6 +55,7 @@ bool RtfFontTable::GetFont( std::wstring sName, RtfFont& oFont ) { if( sName == m_aArray[i].m_sName ) { + m_aArray[i].m_bUsed = true; oFont = m_aArray[i]; return true; } @@ -66,8 +67,11 @@ std::wstring RtfFontTable::RenderToOOX(RenderParameter oRenderParameter) std::wstring sResult; if( !m_aArray.empty()) { - for (size_t i = 0; i < m_aArray.size(); i++ ) - sResult += m_aArray[i].RenderToOOX(oRenderParameter); + for (size_t i = 0; i < m_aArray.size(); i++) + { + if (m_aArray[i].m_bUsed) + sResult += m_aArray[i].RenderToOOX(oRenderParameter); + } } return sResult; @@ -106,10 +110,9 @@ std::wstring RtfFontTable::RenderToRtf(RenderParameter oRenderParameter) RtfColorTable::RtfColorTable() { } -int RtfColorTable::DirectAddItem( RtfColor piRend) +void RtfColorTable::AddColor( RtfColor piRend) { m_aArray.push_back(piRend); - return (int)m_aArray.size() - 1; } int RtfColorTable::AddItem( RtfColor piRend) { diff --git a/RtfFile/Format/RtfGlobalTables.h b/RtfFile/Format/RtfGlobalTables.h index d2977f0906..6f70c5ad82 100644 --- a/RtfFile/Format/RtfGlobalTables.h +++ b/RtfFile/Format/RtfGlobalTables.h @@ -36,7 +36,7 @@ class RtfFontTable : public IDocumentElement, public ItemSingleContainer { public: - int DirectAddItem( RtfFont piRend); + void AddFont( RtfFont piRend); bool GetFont( int nId, RtfFont& oFont); bool GetFont( std::wstring sName, RtfFont& oFont ); @@ -50,7 +50,7 @@ class RtfColorTable : public IDocumentElement, public ItemSingleContainer(oRenderParameter.poDocument); std::wstring sFontName = m_sName; - if ((sFontName.length() > 0 ) && (sFontName[0] == 0x00b9 || sFontName[0] > 0xff00) )//fondj.rtf - { - if (m_sAltName.length() > 0) sFontName = m_sAltName; - else sFontName.clear(); - } if( sFontName.empty() ) { if( PROP_DEF != poRtfDocument->m_oProperty.m_nDefFont ) diff --git a/RtfFile/Format/RtfProperty.h b/RtfFile/Format/RtfProperty.h index 5a6848e4d0..12db7e4560 100644 --- a/RtfFile/Format/RtfProperty.h +++ b/RtfFile/Format/RtfProperty.h @@ -132,15 +132,17 @@ public: typedef enum {ff_none, ff_fnil ,ff_froman ,ff_fswiss ,ff_fmodern ,ff_fscript ,ff_fdecor ,ff_ftech ,ff_fbidi} FontFamily; + bool m_bUsed = false; + FontTheme m_eFontTheme; FontFamily m_eFontFamily; std::wstring m_sPanose; - _INT32 m_nID; + _INT32 m_nID; std::wstring m_sName; std::wstring m_sAltName; - _INT32 m_nCharset; - _INT32 m_nCodePage; - _INT32 m_nPitch; + _INT32 m_nCharset; + _INT32 m_nCodePage; + _INT32 m_nPitch; RtfFont(); diff --git a/RtfFile/Format/RtfReader.cpp b/RtfFile/Format/RtfReader.cpp index 6098702b41..a876b4f79e 100644 --- a/RtfFile/Format/RtfReader.cpp +++ b/RtfFile/Format/RtfReader.cpp @@ -280,7 +280,7 @@ std::wstring RtfAbstractReader::ExecuteTextInternal(RtfDocument& oDocument, RtfR } void RtfAbstractReader::ExecuteTextInternal2(RtfDocument& oDocument, RtfReader& oReader, std::string & sKey, int& nSkipChars) { - if (oReader.m_oState->m_sCurText.length() > 0) + if (false == oReader.m_oState->m_sCurText.empty()) { std::string str; ExecuteTextInternalSkipChars(oReader.m_oState->m_sCurText, oReader, str, nSkipChars); @@ -393,7 +393,14 @@ std::wstring RtfAbstractReader::ExecuteTextInternalCodePage( std::string& sCharS nCodepage = msLCID2DefCodePage(oDocument.m_nUserLCID); } - sResult = RtfUtility::convert_string_icu(sCharString.begin(), sCharString.end(), nCodepage); + if (m_bUseGlobalCodepage && nCodepage == 0) + { + sResult = std::wstring(sCharString.begin(), sCharString.end()); + } + else + { + sResult = RtfUtility::convert_string_icu(sCharString.begin(), sCharString.end(), nCodepage); + } //if (!sCharString.empty() && sResult.empty()) //{ diff --git a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp index 5ab4deb6d5..5921ffa9f2 100644 --- a/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp +++ b/RtfFile/OOXml/Reader/OOXParagraphElementReaders.cpp @@ -1008,7 +1008,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap { oCurFont.m_nID = oParam.oRtf->m_oFontTable.GetCount() + 1; oCurFont.m_sName = sFont; - oParam.oRtf->m_oFontTable.DirectAddItem( oCurFont ); + oParam.oRtf->m_oFontTable.AddFont( oCurFont ); } RtfFieldPtr oNewField ( new RtfField() ); From deffa006b5b1901d1f78338e33ea5a2005688427 Mon Sep 17 00:00:00 2001 From: Kirill Poljakov Date: Fri, 10 Mar 2023 17:02:48 +0300 Subject: [PATCH 4/8] Fixed bug #61577 --- .../raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp index 1fb754c38c..18837f718b 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp @@ -1015,9 +1015,9 @@ namespace MetaFile { if (unIndex + 2 >= unPathPointCount) break; - pPath->CurveTo(arPoints[unIndex].X, arPoints[unIndex].Y, - arPoints[unIndex].X, arPoints[unIndex].Y, - arPoints[unIndex].X, arPoints[unIndex].Y); + pPath->CurveTo(arPoints[unIndex + 0].X, arPoints[unIndex + 0].Y, + arPoints[unIndex + 1].X, arPoints[unIndex + 1].Y, + arPoints[unIndex + 2].X, arPoints[unIndex + 2].Y); unIndex += 2; break; } From 7afe09ce098c315351b0a08f9fc0ad367af28229 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Fri, 10 Mar 2023 17:18:34 +0300 Subject: [PATCH 5/8] fix bug #59365 --- MsBinaryFile/DocFile/TableMapping.cpp | 74 +++++++++++++++++++++------ MsBinaryFile/DocFile/TableMapping.h | 6 +++ 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/MsBinaryFile/DocFile/TableMapping.cpp b/MsBinaryFile/DocFile/TableMapping.cpp index dde86009d8..eb3390ef52 100644 --- a/MsBinaryFile/DocFile/TableMapping.cpp +++ b/MsBinaryFile/DocFile/TableMapping.cpp @@ -265,12 +265,15 @@ namespace DocFileFormat DocParagraph::~DocParagraph() { } - + void DocParagraph::AddCP(int _cpStart, int _cpEnd) + { + if (_cpStart < cpStart) cpStart = _cpStart; + if (_cpEnd > cpEnd) cpEnd = _cpEnd; + } int DocParagraph::GetCPStart() const { return cpStart; } - void DocParagraph::SetCPStart( int _cpStart ) { cpStart = _cpStart; @@ -342,7 +345,6 @@ namespace DocFileFormat if (papx_1 == papx_2) { bBadMarker = true; - return false; } return true; } @@ -414,6 +416,7 @@ namespace DocFileFormat TableRow tableRow ( documentMapping, _cp ); TableCell tableCell ( documentMapping, _cp ); + bool bBadMarker = false; do { fc = documentMapping->m_document->FindFileCharPos(_cp); @@ -442,18 +445,37 @@ namespace DocFileFormat } else { - bool bBadMarker = false; - if ( IsCellMarker( _cp, bBadMarker) ) + bool bBad = false; + if (IsCellMarker(_cp, bBad)) { - lastCellCP = _cp; - tableCell.SetCP( _cp ); - tableCell.SetDepth( _depth ); + if (bBad) + { + tableCell.AddItem(DocParagraph(documentMapping, paragraphBeginCP, _cp)); + _cp++; + paragraphBeginCP = (_cp + 1); - tableCell.AddItem( DocParagraph( documentMapping, paragraphBeginCP, _cp ) ); + bBadMarker = bBad; + } + else + { + lastCellCP = _cp; + tableCell.SetCP(_cp); + tableCell.SetDepth(_depth); - tableRow.AddCell( tableCell ); - tableCell.Clear(); - paragraphBeginCP = ( _cp + 1 ); + DocParagraph para(documentMapping, paragraphBeginCP, _cp); + //if (bBadMarker && !tableCell.IsEmpty()) + //{ + // tableCell.GetLast()->AddCP(paragraphBeginCP, _cp); + //} + //else + tableCell.AddItem(para); + + bBadMarker = false; + + tableRow.AddCell(tableCell); + tableCell.Clear(); + paragraphBeginCP = (_cp + 1); + } } else if ( IsRowMarker( _cp ) ) { @@ -462,7 +484,15 @@ namespace DocFileFormat tableCell.SetCP(_cp); tableCell.SetDepth(_depth); - tableCell.AddItem(DocParagraph(documentMapping, paragraphBeginCP, _cp)); + DocParagraph para(documentMapping, paragraphBeginCP, _cp); + //if (bBadMarker && !tableCell.IsEmpty()) + //{ + // tableCell.GetLast()->AddCP(paragraphBeginCP, _cp); + //} + //else + tableCell.AddItem(para); + + bBadMarker = false; tableRow.AddCell(tableCell); tableCell.Clear(); @@ -474,10 +504,18 @@ namespace DocFileFormat tableRow.Clear(); paragraphBeginCP++; } - else if ( !bBadMarker && IsParagraphMarker( _cp ) ) + else if ( IsParagraphMarker( _cp ) ) { - tableCell.AddItem( DocParagraph( documentMapping, paragraphBeginCP, _cp ) ); + DocParagraph para(documentMapping, paragraphBeginCP, _cp); + //if (bBadMarker && !tableCell.IsEmpty()) + //{ + // tableCell.GetLast()->AddCP(paragraphBeginCP, _cp); + //} + //else + tableCell.AddItem(para); + paragraphBeginCP = ( _cp + 1 ); + bBadMarker = false; } _cp++; } @@ -500,7 +538,11 @@ namespace DocFileFormat { cpStart = _cpStart; } - + void Table::AddCP(int _cpStart, int _cpEnd) + { + if (_cpStart < cpStart) cpStart = _cpStart; + if (_cpEnd > cpEnd) cpEnd = _cpEnd; + } int Table::GetCPEnd() const { return cpEnd; diff --git a/MsBinaryFile/DocFile/TableMapping.h b/MsBinaryFile/DocFile/TableMapping.h index ea21d68f93..b9d5db6dd0 100644 --- a/MsBinaryFile/DocFile/TableMapping.h +++ b/MsBinaryFile/DocFile/TableMapping.h @@ -41,6 +41,8 @@ namespace DocFileFormat virtual int GetCPStart() const = 0; virtual int GetCPEnd() const = 0; virtual ~ITableCellElement() {} + + virtual void AddCP(int _cpStart = 0, int _cpEnd = 0) = 0; }; typedef NSCommon::smart_ptr ITableCellElementPtr; @@ -61,6 +63,8 @@ namespace DocFileFormat void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector* grid, int& gridIndex, int cellIndex ); ~TableCell(); + ITableCellElementPtr GetLast() { return cellElements.back(); } + private: int cp; @@ -105,6 +109,7 @@ namespace DocFileFormat virtual IVirtualConstructor* Clone() const; virtual void Convert( IMapping* mapping ); virtual ~DocParagraph(); + virtual void AddCP(int _cpStart = 0, int _cpEnd = 0); private: @@ -142,6 +147,7 @@ namespace DocFileFormat virtual IVirtualConstructor* Clone() const; virtual void Convert( IMapping* mapping ); virtual ~Table(); + virtual void AddCP(int _cpStart = 0, int _cpEnd = 0); private: From 3fa6152e696cd2d7c7f584343ffcb0d7cbb0db0f Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Sat, 11 Mar 2023 12:42:23 +0300 Subject: [PATCH 6/8] fix bug #61588 --- OdfFile/Writer/Converter/ConvertDrawing.cpp | 57 ++++++++++--------- OdfFile/Writer/Converter/ConvertVml.cpp | 12 ++-- OdfFile/Writer/Converter/Converter.cpp | 8 ++- OdfFile/Writer/Converter/Converter.h | 4 +- OdfFile/Writer/Converter/DocxConverter.cpp | 15 +++-- OdfFile/Writer/Converter/DocxConverter.h | 2 +- OdfFile/Writer/Converter/PptxConverter.cpp | 13 +++-- OdfFile/Writer/Converter/PptxConverter.h | 2 +- OdfFile/Writer/Converter/XlsxConverter.cpp | 28 +++++---- OdfFile/Writer/Converter/XlsxConverter.h | 2 +- .../Writer/Format/odf_conversion_context.cpp | 30 +++++++--- .../Writer/Format/odf_conversion_context.h | 4 +- 12 files changed, 108 insertions(+), 69 deletions(-) diff --git a/OdfFile/Writer/Converter/ConvertDrawing.cpp b/OdfFile/Writer/Converter/ConvertDrawing.cpp index 7f352dfde9..2a78acf1b3 100644 --- a/OdfFile/Writer/Converter/ConvertDrawing.cpp +++ b/OdfFile/Writer/Converter/ConvertDrawing.cpp @@ -310,24 +310,23 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) } } //-------------------------------------------------------------------------------------- - bool bEmbedded = true; + bool bExternal = false; std::wstring pathImage; + if (oox_picture->blipFill.blip.IsInit()) { if (oox_picture->blipFill.blip->embed.IsInit()) { std::wstring sID = oox_picture->blipFill.blip->embed->get(); - pathImage = find_link_by_id(sID, 1); + pathImage = find_link_by_id(sID, 1, bExternal); } else if (oox_picture->blipFill.blip->link.IsInit()) { std::wstring sID = oox_picture->blipFill.blip->link->get(); - pathImage = find_link_by_id(sID, 1); + pathImage = find_link_by_id(sID, 1, bExternal); if (pathImage.empty()) pathImage = sID; - - bEmbedded = false; } } //-------------------------------------------------------------------------------------- @@ -339,8 +338,8 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) { PPTX::Logic::MediaFile & media = oox_picture->nvPicPr.nvPr.media.as(); - std::wstring sID = media.link.get(); - std::wstring pathMedia = find_link_by_id(sID, 3); + std::wstring sID = media.link.get(); + std::wstring pathMedia = find_link_by_id(sID, 3, bExternal); double start = -1, end = -1; @@ -349,14 +348,14 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) PPTX::Logic::Ext & ext = oox_picture->nvPicPr.nvPr.extLst[i]; if (pathMedia.empty() && ext.link.IsInit()) { - pathMedia = find_link_by_id(ext.link->get(), 3); + pathMedia = find_link_by_id(ext.link->get(), 3, bExternal); //например файлики mp3 } if (ext.st.IsInit()) start = *ext.st; if (ext.end.IsInit()) end = *ext.end; } - std::wstring odf_ref_media = odf_context()->add_media(pathMedia); + std::wstring odf_ref_media = odf_context()->add_media(pathMedia, bExternal); if (!odf_ref_media.empty()) { @@ -366,7 +365,7 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) OoxConverter::convert(&oox_picture->nvPicPr.cNvPr); OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer()); - odf_ref_image = bEmbedded ? odf_context()->add_image(pathImage) : pathImage; + odf_ref_image = bExternal ? pathImage : odf_context()->add_image(pathImage); odf_context()->drawing_context()->set_image_replacement(odf_ref_image); odf_context()->drawing_context()->end_media(); @@ -385,7 +384,7 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) if (oox_picture->oleObject->m_oId.IsInit()) { - pathOle = find_link_by_id(oox_picture->oleObject->m_oId->get(), 4); + pathOle = find_link_by_id(oox_picture->oleObject->m_oId->get(), 4, bExternal); } std::wstring odf_ref_ole = odf_context()->add_oleobject(pathOle); @@ -433,7 +432,7 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) } - odf_ref_image = bEmbedded ? odf_context()->add_imageobject(pathImage) : pathImage; + odf_ref_image = bExternal ? pathImage : odf_context()->add_imageobject(pathImage); odf_context()->drawing_context()->set_image_replacement(odf_ref_image); odf_context()->drawing_context()->end_object_ole(); @@ -441,7 +440,7 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) } } //-------------------------------------------------------------------------------------- - odf_ref_image = bEmbedded ? odf_context()->add_image(pathImage) : pathImage; + odf_ref_image = bExternal ? pathImage : odf_context()->add_image(pathImage); odf_context()->drawing_context()->start_image(odf_ref_image); { @@ -1243,14 +1242,15 @@ void OoxConverter::convert(PPTX::Logic::BlipFill *oox_bitmap_fill) { std::wstring sID, pathImage; + bool bExternal = false; if (oox_bitmap_fill->blip->embed.IsInit()) { sID = oox_bitmap_fill->blip->embed->get(); - pathImage = find_link_by_id(sID, 1); + pathImage = find_link_by_id(sID, 1, bExternal); if (!pathImage.empty()) { - odf_context()->drawing_context()->set_bitmap_link(pathImage); + odf_context()->drawing_context()->set_bitmap_link(pathImage, bExternal); _graphics_utils_::GetResolution(pathImage.c_str(), Width, Height); Width /= 96; //to inch (current dpi file) @@ -1261,12 +1261,12 @@ void OoxConverter::convert(PPTX::Logic::BlipFill *oox_bitmap_fill) { sID = oox_bitmap_fill->blip->link->get(); - pathImage = find_link_by_id(sID, 1); //reconstruction.pptx + pathImage = find_link_by_id(sID, 1, bExternal); //reconstruction.pptx if (pathImage.empty()) pathImage = sID; - odf_context()->drawing_context()->set_bitmap_link(pathImage, true); + odf_context()->drawing_context()->set_bitmap_link(pathImage, bExternal); } for (size_t i = 0 ; i < oox_bitmap_fill->blip->Effects.size(); i++) { @@ -1633,11 +1633,12 @@ void OoxConverter::convert(PPTX::Logic::CNvPr *oox_cnvPr) } if (oox_cnvPr->hlinkClick.IsInit()) { + bool bExternal = false; if (odf_context()->drawing_context()->is_current_empty()) { if (oox_cnvPr->hlinkClick->id.IsInit()) { - std::wstring hlink = find_link_by_id(oox_cnvPr->hlinkClick->id.get(), 2); + std::wstring hlink = find_link_by_id(oox_cnvPr->hlinkClick->id.get(), 2, bExternal); odf_context()->drawing_context()->start_link_object(hlink); } @@ -1648,14 +1649,14 @@ void OoxConverter::convert(PPTX::Logic::CNvPr *oox_cnvPr) if (oox_cnvPr->hlinkClick->snd.IsInit()) { - std::wstring sound = find_link_by_id(oox_cnvPr->hlinkClick->snd->embed.get(), 3); + std::wstring sound = find_link_by_id(oox_cnvPr->hlinkClick->snd->embed.get(), 3, bExternal); - std::wstring href = odf_context()->add_media(sound); + std::wstring href = odf_context()->add_media(sound, bExternal); odf_context()->drawing_context()->add_sound(href); } if (oox_cnvPr->hlinkClick->id.IsInit()) { - std::wstring hlink = find_link_by_id(oox_cnvPr->hlinkClick->id.get(), 2); + std::wstring hlink = find_link_by_id(oox_cnvPr->hlinkClick->id.get(), 2, bExternal); odf_context()->drawing_context()->add_link(hlink); } @@ -1741,23 +1742,23 @@ void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_pro const PPTX::Logic::BuBlip & buBlip = bullet.as(); std::wstring odf_ref; - bool bEmbedded = true; + bool bExternal = false; if (buBlip.blip.embed.IsInit()) { std::wstring sID = buBlip.blip.embed->get(); - std::wstring pathImage = find_link_by_id(sID, 1); + std::wstring pathImage = find_link_by_id(sID, 1, bExternal); if (pathImage.empty()) pathImage = buBlip.blip.GetFullPicName(); // only for presentation merge shapes !! - odf_ref = odf_context()->add_image(pathImage); + odf_ref = odf_context()->add_image(pathImage, bExternal); } else if (buBlip.blip.link.IsInit()) { odf_ref = buBlip.blip.link->get(); - bEmbedded = false; + bExternal = true; } if (!odf_ref.empty()) @@ -2413,7 +2414,8 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run) text_properties->content_.style_text_underline_type_ = odf_types::line_type::Single; text_properties->content_.style_text_underline_style_ = odf_types::line_style::Solid; - std::wstring hlink = find_link_by_id(oox_run->rPr->hlinkClick->id.get(), 2); + bool bExternal = false; + std::wstring hlink = find_link_by_id(oox_run->rPr->hlinkClick->id.get(), 2, bExternal); std::wstring location; text_context->add_hyperlink(hlink, oox_run->GetText(), location); } @@ -2448,7 +2450,8 @@ void OoxConverter::convert(PPTX::Logic::Fld *oox_fld) if ((oox_fld->rPr.IsInit()) && (oox_fld->rPr->hlinkClick.IsInit()) && (oox_fld->rPr->hlinkClick->id.IsInit())) { - std::wstring hlink = find_link_by_id(oox_fld->rPr->hlinkClick->id.get(), 2); + bool bExternal = false; + std::wstring hlink = find_link_by_id(oox_fld->rPr->hlinkClick->id.get(), 2, bExternal); std::wstring location; odf_context()->text_context()->add_hyperlink(hlink, oox_fld->GetText(), location); diff --git a/OdfFile/Writer/Converter/ConvertVml.cpp b/OdfFile/Writer/Converter/ConvertVml.cpp index e24f7d993b..5a8dbb6703 100644 --- a/OdfFile/Writer/Converter/ConvertVml.cpp +++ b/OdfFile/Writer/Converter/ConvertVml.cpp @@ -427,6 +427,8 @@ namespace Oox2Odf std::wstring pathImage; double Width = 0, Height = 0; + bool bExternal = false; + std::wstring sID; if (vml_image_data->m_rId.IsInit()) sID = vml_image_data->m_rId->GetValue(); else if (vml_image_data->m_oRelId.IsInit()) sID = vml_image_data->m_oRelId->GetValue(); @@ -434,7 +436,7 @@ namespace Oox2Odf if (!sID.empty()) { - pathImage = find_link_by_id(sID, 1); + pathImage = find_link_by_id(sID, 1, bExternal); } //что именно нужно заливка объекта или картинка - разрулится внутри drawing_context @@ -445,7 +447,7 @@ namespace Oox2Odf odf_context()->drawing_context()->start_area_properties(); odf_context()->drawing_context()->start_bitmap_style(); - odf_context()->drawing_context()->set_bitmap_link(pathImage); + odf_context()->drawing_context()->set_bitmap_link(pathImage, bExternal); odf_context()->drawing_context()->set_image_style_repeat(1);//stretch double gain = vml_image_data->m_oGain.get_value_or(0); @@ -512,6 +514,8 @@ namespace Oox2Odf std::wstring sID; + bool bExternal = false; + if (vml_fill->m_rId.IsInit()) sID = vml_fill->m_rId->GetValue(); else if (vml_fill->m_oRelId.IsInit()) sID = vml_fill->m_oRelId->GetValue(); else if (vml_fill->m_sId.IsInit()) sID = *vml_fill->m_sId; @@ -523,11 +527,11 @@ namespace Oox2Odf { double Width = 0, Height = 0; - sImagePath = find_link_by_id(sID, 1); + sImagePath = find_link_by_id(sID, 1, bExternal); if (!sImagePath.empty()) { - odf_context()->drawing_context()->set_bitmap_link(sImagePath); + odf_context()->drawing_context()->set_bitmap_link(sImagePath, bExternal); _graphics_utils_::GetResolution(sImagePath.c_str(), Width, Height); } odf_context()->drawing_context()->set_image_style_repeat(1); diff --git a/OdfFile/Writer/Converter/Converter.cpp b/OdfFile/Writer/Converter/Converter.cpp index 250731f6c7..f9f51fb849 100644 --- a/OdfFile/Writer/Converter/Converter.cpp +++ b/OdfFile/Writer/Converter/Converter.cpp @@ -801,8 +801,10 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown) _CP_LOG << L"[error] : no convert element(" << (oox_unknown ? oox_unknown->getType() : -1 ) << L")\n"; } } -std::wstring OoxConverter::find_link_by (smart_ptr & oFile, int type) +std::wstring OoxConverter::find_link_by (smart_ptr & oFile, int type, bool & bExternal) { + bExternal = false; + if (!oFile.IsInit()) return L""; std::wstring ref; @@ -813,6 +815,7 @@ std::wstring OoxConverter::find_link_by (smart_ptr & oFile, int type) if (pImage) { ref = pImage->filename().GetPath(); + bExternal = pImage->IsExternal(); } } if (type == 2 && OOX::FileTypes::HyperLink == oFile->type()) @@ -822,6 +825,7 @@ std::wstring OoxConverter::find_link_by (smart_ptr & oFile, int type) if (pHyperlink && pHyperlink->bHyperlink) { ref = pHyperlink->Uri().GetPath(); + bExternal = true; } } if (type == 3) @@ -831,6 +835,7 @@ std::wstring OoxConverter::find_link_by (smart_ptr & oFile, int type) if (pMedia) { ref = pMedia->filename().GetPath(); + bExternal = pMedia->IsExternal(); } } if (type == 4) @@ -840,6 +845,7 @@ std::wstring OoxConverter::find_link_by (smart_ptr & oFile, int type) if (pOleObject) { ref = pOleObject->filename().GetPath(); + bExternal = pOleObject->IsExternal(); } } return ref; diff --git a/OdfFile/Writer/Converter/Converter.h b/OdfFile/Writer/Converter/Converter.h index 33ad5b76da..f4a07e2c47 100644 --- a/OdfFile/Writer/Converter/Converter.h +++ b/OdfFile/Writer/Converter/Converter.h @@ -473,8 +473,8 @@ public: cpdoccore::odf_writer::package::odf_document *output_document; - std::wstring find_link_by (NSCommon::smart_ptr & oFile, int type); - virtual std::wstring find_link_by_id(const std::wstring & sId, int type) = 0; + std::wstring find_link_by (NSCommon::smart_ptr & oFile, int type, bool & bExternal); + virtual std::wstring find_link_by_id(const std::wstring & sId, int type, bool & bExternal) = 0; virtual NSCommon::smart_ptr find_file_by_id(const std::wstring & sId) = 0; OOX::IFileContainer *oox_current_child_document; diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index f329fcb99e..31ff202406 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -173,8 +173,9 @@ NSCommon::smart_ptr DocxConverter::find_file_by_id(const std::wstring return oFile; } -std::wstring DocxConverter::find_link_by_id (const std::wstring & sId, int type) +std::wstring DocxConverter::find_link_by_id (const std::wstring & sId, int type, bool & bExternal) { + bExternal = false; std::wstring ref; smart_ptr oFile; @@ -182,7 +183,7 @@ std::wstring DocxConverter::find_link_by_id (const std::wstring & sId, int type) if (oox_current_child_document) { oFile = oox_current_child_document->Find(sId); - ref = OoxConverter::find_link_by(oFile, type); + ref = OoxConverter::find_link_by(oFile, type, bExternal); } if (!ref.empty()) return ref; @@ -190,7 +191,7 @@ std::wstring DocxConverter::find_link_by_id (const std::wstring & sId, int type) if (docx_document->m_oMain.document == NULL) return L""; oFile = docx_document->m_oMain.document->Find(sId); - ref = OoxConverter::find_link_by(oFile, type); + ref = OoxConverter::find_link_by(oFile, type, bExternal); return ref; } @@ -3051,10 +3052,11 @@ void DocxConverter::convert(OOX::Logic::CObject* oox_obj) if (oox_obj->m_oOleObject.IsInit()) { std::wstring pathOle; + bool bExternal = false; if (oox_obj->m_oOleObject->m_oId.IsInit()) { - pathOle = find_link_by_id(oox_obj->m_oOleObject->m_oId->GetValue(), 4); + pathOle = find_link_by_id(oox_obj->m_oOleObject->m_oId->GetValue(), 4, bExternal); } std::wstring odf_ref_ole = odf_context()->add_oleobject(pathOle); @@ -3069,7 +3071,7 @@ void DocxConverter::convert(OOX::Logic::CObject* oox_obj) } std::wstring sIdImageFileCache = GetImageIdFromVmlShape(oox_obj->m_oShape.GetPointer()); - std::wstring pathImage = find_link_by_id(sIdImageFileCache, 1); + std::wstring pathImage = find_link_by_id(sIdImageFileCache, 1, bExternal); std::wstring odf_ref_image = odf_context()->add_imageobject(pathImage); odf_context()->drawing_context()->set_image_replacement(odf_ref_image); @@ -3573,10 +3575,11 @@ void DocxConverter::convert(OOX::Logic::CHyperlink *oox_hyperlink) if (oox_hyperlink == NULL)return; std::wstring link, location; + bool bExternal = false; if (oox_hyperlink->m_oId.IsInit()) //гиперлинк { - link = find_link_by_id(oox_hyperlink->m_oId->GetValue(), 2); + link = find_link_by_id(oox_hyperlink->m_oId->GetValue(), 2, bExternal); } else if (oox_hyperlink->m_sDestinition.IsInit()) //гиперлинк { diff --git a/OdfFile/Writer/Converter/DocxConverter.h b/OdfFile/Writer/Converter/DocxConverter.h index e9c619253d..198af1a8d4 100644 --- a/OdfFile/Writer/Converter/DocxConverter.h +++ b/OdfFile/Writer/Converter/DocxConverter.h @@ -157,7 +157,7 @@ namespace Oox2Odf virtual odf_writer::odf_conversion_context *odf_context(); virtual PPTX::Theme *oox_theme(); virtual PPTX::Logic::ClrMap *oox_clrMap(); - virtual std::wstring find_link_by_id (const std::wstring & sId, int t); + virtual std::wstring find_link_by_id (const std::wstring & sId, int t, bool & bExternal); virtual NSCommon::smart_ptr find_file_by_id (const std::wstring & sId); void convert (OOX::WritingElement *oox_unknown); diff --git a/OdfFile/Writer/Converter/PptxConverter.cpp b/OdfFile/Writer/Converter/PptxConverter.cpp index cc1d4c5ea7..34151d3a97 100644 --- a/OdfFile/Writer/Converter/PptxConverter.cpp +++ b/OdfFile/Writer/Converter/PptxConverter.cpp @@ -153,8 +153,10 @@ NSCommon::smart_ptr PptxConverter::find_file_by_id(const std::wstring return oFile; } -std::wstring PptxConverter::find_link_by_id (const std::wstring & sId, int type) +std::wstring PptxConverter::find_link_by_id (const std::wstring & sId, int type, bool & bExternal) { + bExternal = false; + if(!pptx_document) return L""; std::wstring ref; @@ -163,12 +165,12 @@ std::wstring PptxConverter::find_link_by_id (const std::wstring & sId, int type) if (oox_current_child_document) { oFile = oox_current_child_document->Find(sId); - ref = OoxConverter::find_link_by(oFile, type); + ref = OoxConverter::find_link_by(oFile, type, bExternal); } if (!ref.empty()) return ref; oFile = current_slide ? current_slide->Find(sId) : pptx_document->Find(sId); - ref = OoxConverter::find_link_by(oFile, type); + ref = OoxConverter::find_link_by(oFile, type, bExternal); return ref; } @@ -668,9 +670,10 @@ void PptxConverter::convert( PPTX::Logic::Transition *oox_transition ) { std::wstring sID = oox_transition->sndAc->stSnd->embed.get(); - std::wstring pathAudio = find_link_by_id(sID, 3); + bool bExternal = false; + std::wstring pathAudio = find_link_by_id(sID, 3, bExternal); - std::wstring odf_ref = odf_context()->add_media(pathAudio); + std::wstring odf_ref = odf_context()->add_media(pathAudio, bExternal); odp_context->current_slide().set_transition_sound(odf_ref, oox_transition->sndAc->stSnd->loop.get_value_or(false)); } diff --git a/OdfFile/Writer/Converter/PptxConverter.h b/OdfFile/Writer/Converter/PptxConverter.h index c6d26f7cdd..552dbbd39b 100644 --- a/OdfFile/Writer/Converter/PptxConverter.h +++ b/OdfFile/Writer/Converter/PptxConverter.h @@ -123,7 +123,7 @@ namespace Oox2Odf virtual PPTX::Theme *oox_theme(); virtual PPTX::Logic::ClrMap *oox_clrMap(); - virtual std::wstring find_link_by_id (const std::wstring & sId, int t); + virtual std::wstring find_link_by_id (const std::wstring & sId, int t, bool & bExternal); virtual NSCommon::smart_ptr find_file_by_id (const std::wstring & sId); void convert(OOX::WritingElement *oox_unknown); diff --git a/OdfFile/Writer/Converter/XlsxConverter.cpp b/OdfFile/Writer/Converter/XlsxConverter.cpp index 86b1d4a8d1..5ec7d72805 100644 --- a/OdfFile/Writer/Converter/XlsxConverter.cpp +++ b/OdfFile/Writer/Converter/XlsxConverter.cpp @@ -126,22 +126,24 @@ smart_ptr XlsxConverter::find_file_by_id(const std::wstring & sId) return oFile; } -std::wstring XlsxConverter::find_link_by_id (const std::wstring & sId, int type) +std::wstring XlsxConverter::find_link_by_id (const std::wstring & sId, int type, bool & bExternal) { - smart_ptr oFile; + bExternal = false; + + smart_ptr oFile; std::wstring ref; if (oox_current_child_document) { oFile = oox_current_child_document->Find(sId); - ref = OoxConverter::find_link_by(oFile, type); + ref = OoxConverter::find_link_by(oFile, type, bExternal); } if (!ref.empty()) return ref; if (xlsx_current_container) { oFile = xlsx_current_container->Find(sId); - ref = OoxConverter::find_link_by(oFile, type); + ref = OoxConverter::find_link_by(oFile, type, bExternal); } return ref; } @@ -597,9 +599,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CLegacyDrawingHFWorksheet *oox_bac odf_writer::office_element_ptr fill_image_element; std::wstring pathImage, href, sID = pImage->m_oId.IsInit() ? pImage->m_rId->GetValue() : (pImage->m_oRelId.IsInit() ? pImage->m_oRelId->GetValue() : L""); - - pathImage = find_link_by_id(sID, 1); - href = ods_context->add_image(pathImage); + + bool bExternal = false; + pathImage = find_link_by_id(sID, 1, bExternal); + href = ods_context->add_image(pathImage, bExternal); if (false == href.empty()) { @@ -968,8 +971,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPictureWorksheet *oox_background) std::wstring pathImage, href, sID = oox_background->m_oId->GetValue(); - pathImage = find_link_by_id(sID, 1); - href = ods_context->add_image(pathImage); + bool bExternal = false; + + pathImage = find_link_by_id(sID, 1, bExternal); + href = ods_context->add_image(pathImage, bExternal); if (href.empty()) return; @@ -2891,11 +2896,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::COleObjects *oox_objects, OOX::Spr ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1); } } + bool bExternal = false; if (object->m_oRid.IsInit()) { std::wstring sID = object->m_oRid->GetValue(); - std::wstring pathOle = find_link_by_id(sID, 4); + std::wstring pathOle = find_link_by_id(sID, 4, bExternal); odf_ref_object = odf_context()->add_oleobject(pathOle); } @@ -2903,7 +2909,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::COleObjects *oox_objects, OOX::Spr { std::wstring sID = object->m_oObjectPr->m_oRid->GetValue(); - std::wstring pathImage = find_link_by_id(sID, 1); + std::wstring pathImage = find_link_by_id(sID, 1, bExternal); odf_ref_image = odf_context()->add_imageobject(pathImage); } diff --git a/OdfFile/Writer/Converter/XlsxConverter.h b/OdfFile/Writer/Converter/XlsxConverter.h index 490022c4d6..2a18d0aa48 100644 --- a/OdfFile/Writer/Converter/XlsxConverter.h +++ b/OdfFile/Writer/Converter/XlsxConverter.h @@ -153,7 +153,7 @@ namespace Oox2Odf virtual OOX::IFileContainer *current_document(); virtual odf_writer::odf_conversion_context *odf_context(); virtual PPTX::Theme *oox_theme(); - virtual std::wstring find_link_by_id (const std::wstring & sId, int t); + virtual std::wstring find_link_by_id (const std::wstring & sId, int t, bool & bExternal); virtual NSCommon::smart_ptr find_file_by_id (const std::wstring & sId); void convert(OOX::Spreadsheet::WritingElement *oox_unknown); diff --git a/OdfFile/Writer/Format/odf_conversion_context.cpp b/OdfFile/Writer/Format/odf_conversion_context.cpp index a34764591d..fd1311e9b1 100644 --- a/OdfFile/Writer/Format/odf_conversion_context.cpp +++ b/OdfFile/Writer/Format/odf_conversion_context.cpp @@ -481,23 +481,37 @@ office_element_ptr odf_conversion_context::start_tabs() create_element(L"style", L"tab-stops", temporary_.elm, this, true); return temporary_.elm; } -std::wstring odf_conversion_context::add_image(const std::wstring & image_file_name) +std::wstring odf_conversion_context::add_image(const std::wstring & image_file_name, bool bExternal) { if (image_file_name.empty()) return L""; - std::wstring odf_ref_name ; - mediaitems()->add_or_find(image_file_name,_mediaitems::typeImage, odf_ref_name); + if (bExternal) + { + return image_file_name; + } + else + { + std::wstring odf_ref_name; + mediaitems()->add_or_find(image_file_name, _mediaitems::typeImage, odf_ref_name); - return odf_ref_name; + return odf_ref_name; + } } -std::wstring odf_conversion_context::add_media(const std::wstring & file_name) +std::wstring odf_conversion_context::add_media(const std::wstring & file_name, bool bExternal) { if (file_name.empty()) return L""; - std::wstring odf_ref_name ; - mediaitems()->add_or_find(file_name,_mediaitems::typeMedia, odf_ref_name); + if (bExternal) + { + return file_name; + } + else + { + std::wstring odf_ref_name; + mediaitems()->add_or_find(file_name, _mediaitems::typeMedia, odf_ref_name); - return odf_ref_name; + return odf_ref_name; + } } std::wstring odf_conversion_context::add_imageobject(const std::wstring & file_name) { diff --git a/OdfFile/Writer/Format/odf_conversion_context.h b/OdfFile/Writer/Format/odf_conversion_context.h index 4d59132a31..0e0b02fba4 100644 --- a/OdfFile/Writer/Format/odf_conversion_context.h +++ b/OdfFile/Writer/Format/odf_conversion_context.h @@ -116,8 +116,8 @@ public: virtual odf_text_context * text_context() = 0; virtual odf_controls_context * controls_context() = 0; - std::wstring add_image (const std::wstring & image_file_name); - std::wstring add_media (const std::wstring & file_name); + std::wstring add_image (const std::wstring & image_file_name, bool bExternal = false); + std::wstring add_media (const std::wstring & file_name, bool bExternal = false); std::wstring add_oleobject (const std::wstring & ole_file_name); std::wstring add_imageobject(const std::wstring & ole_file_name); From 8ca40a44ce47a86168327a46db91253cf6bb205d Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Sat, 11 Mar 2023 13:38:14 +0300 Subject: [PATCH 7/8] fix bug #61586 --- .../ASCOfficeDrawingConverter.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp index 97bf2ec409..06acfad458 100644 --- a/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp +++ b/OOXML/PPTXFormat/DrawingConverter/ASCOfficeDrawingConverter.cpp @@ -3636,7 +3636,6 @@ void CDrawingConverter::ConvertGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:: else pTree->m_lGroupIndex = 1; XmlUtils::CXmlNodes oNodes; - XmlUtils::CXmlNode oNodeBinData; //сначала shape type if (oNode.GetNodes(L"*", oNodes)) @@ -3665,11 +3664,7 @@ void CDrawingConverter::ConvertGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:: std::wstring strNameP = XmlUtils::GetNameNoNS(oNodeT.GetName()); - if (L"binData" == strNameP) - { - oNodeBinData = oNode; - } - else if (L"shape" == strNameP || + if (L"shape" == strNameP || L"rect" == strNameP || L"oval" == strNameP || L"line" == strNameP || @@ -3677,6 +3672,17 @@ void CDrawingConverter::ConvertGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:: L"background" == strNameP || L"roundrect" == strNameP) { + XmlUtils::CXmlNode oNodeBinData; + + if (i + 1 < nCount) + { + oNodes.GetAt(i + 1, oNodeBinData); + if (L"binData" != XmlUtils::GetNameNoNS(oNodeBinData.GetName())) + { + oNodeBinData.Clear(); + } + } + PPTX::Logic::SpTreeElem _el; if (oNodeBinData.IsValid()) { @@ -5115,7 +5121,7 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils { XmlUtils::CXmlNode oNodeFillID = oNode.ReadNode(L"v:imagedata"); - if (oNodeFillID.IsValid()) + if (oNodeFillID.IsValid() || oElem->m_binaryData.IsInit()) { nullable_string sRid; XmlMacroReadAttributeBase(oNodeFillID, L"r:id", sRid); From 5b8510353dcf21ee2672bdee2c471d44d30d160a Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Sun, 12 Mar 2023 10:26:49 +0300 Subject: [PATCH 8/8] Push changes for base file (pdf/xps/djvu module) --- DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js index 9ff22d254a..b591344762 100644 --- a/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js +++ b/DesktopEditor/graphics/pro/js/wasm/js/drawingfile_base.js @@ -178,6 +178,13 @@ // else - error return error; }; + CFile.prototype["getFileAsBase64"] = function() + { + if (0 >= this.stream) + return ""; + + return new Uint8Array(Module["HEAP8"].buffer, this.stream, this.stream_size); + }; CFile.prototype["isNeedPassword"] = function() { return this._isNeedPassword;