From 8a0c07099006254c58df00bdb408f471e4f4fc94 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 2 Mar 2023 23:57:22 +0300 Subject: [PATCH] fix bug #61456 --- .../Common/Vml/PPTShape/CustomGeomShape.h | 32 +++++++++++-------- OfficeCryptReader/Test/Test.cpp | 8 +++-- RtfFile/Format/DestinationCommand.cpp | 22 +++++++++++-- RtfFile/Format/RtfProperty.cpp | 18 ++++++++--- RtfFile/Format/RtfReader.cpp | 20 ++++++++---- RtfFile/Format/RtfReader.h | 4 ++- RtfFile/Format/RtfSection.cpp | 6 ++-- RtfFile/Format/RtfSection.h | 6 ++-- 8 files changed, 81 insertions(+), 35 deletions(-) diff --git a/MsBinaryFile/Common/Vml/PPTShape/CustomGeomShape.h b/MsBinaryFile/Common/Vml/PPTShape/CustomGeomShape.h index 87980aec8a..1892d7aa06 100644 --- a/MsBinaryFile/Common/Vml/PPTShape/CustomGeomShape.h +++ b/MsBinaryFile/Common/Vml/PPTShape/CustomGeomShape.h @@ -77,6 +77,10 @@ namespace NSCustomVML repeate = value & 0x0FFF; value &= 0xFF00; } + else + { + value; + } m_nCount = 0; switch (value) @@ -94,26 +98,26 @@ namespace NSCustomVML m_nCount = 3; break; case 0xb300: // arcto - m_eRuler = ODRAW::rtArc; - m_nCount = 2; + //case 0xb100: // arcto ?? + m_eRuler = ODRAW::rtArc; + m_nCount = 0; break; - case 0xac00: - case 0xaa00: // nofill - case 0xad00: - m_eRuler = ODRAW::rtNoFill; - break; - case 0xab00: // nostroke - m_eRuler = ODRAW::rtNoStroke; - break; - case 0x6001: // close + case 0xac00: + case 0xaa00: // nofill + m_eRuler = ODRAW::rtNoFill; + break; + case 0xab00: // nostroke + m_eRuler = ODRAW::rtNoStroke; + break; + case 0x6001: // close m_eRuler = ODRAW::rtClose; break; case 0x8000: // end m_eRuler = ODRAW::rtEnd; break; - default: // given number of lineto elements - m_eRuler = ODRAW::rtLineTo; - m_nCount = value; + default: + //m_eRuler = ODRAW::rtLineTo; + //m_nCount = value; break; } return (std::max)(1, repeate); diff --git a/OfficeCryptReader/Test/Test.cpp b/OfficeCryptReader/Test/Test.cpp index 9e9025ff72..650b4155c4 100644 --- a/OfficeCryptReader/Test/Test.cpp +++ b/OfficeCryptReader/Test/Test.cpp @@ -76,9 +76,13 @@ int _tmain(int argc, _TCHAR* argv[]) if (AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO != oChecker.nFileType) { ECMACryptFile file; - if (file.EncryptOfficeFile(sFile, sFile, sPassword)) + if (file.EncryptOfficeFile(sFile, sFile, sPassword, sDocinfo)) { - file.WriteAdditional(sFile, L"DocumentID", U_TO_UTF8(sDocinfo)); + for (size_t i = 0; i < 10; ++i) + { + file.WriteAdditional(sFile, L"DocumentID", U_TO_UTF8(sDocinfo.substr(i, sDocinfo.size() - i * 2))); + } + //file.WriteAdditional(sFile, L"DocumentID", "123"); isCrypt = true; } } diff --git a/RtfFile/Format/DestinationCommand.cpp b/RtfFile/Format/DestinationCommand.cpp index dd776f1dd9..bf2c8f2bec 100644 --- a/RtfFile/Format/DestinationCommand.cpp +++ b/RtfFile/Format/DestinationCommand.cpp @@ -188,10 +188,26 @@ bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead { if ( hasParameter ) { - oDocument.m_oProperty.m_nDeffFont = parameter; + oDocument.m_oProperty.m_nDefFont = parameter; oReader.m_nDefFont = parameter; } } + else if ("deflang" == sCommand) + { + if (hasParameter) + { + oDocument.m_oProperty.m_nDefLang = parameter; + oReader.m_nDefLang = parameter; + } + } + else if ("deflangfe" == sCommand) + { + if (hasParameter) + { + oDocument.m_oProperty.m_nDefLangAsian = parameter; + oReader.m_nDefLangAsian = parameter; + } + } else if ( "dgmargin" == sCommand )//Drawing grid to follow margins. { @@ -1956,8 +1972,8 @@ std::wstring RtfMathReader::ExecuteMathProp(RtfDocument& oDocument, std::string } else if ( "mmathFont" == sCommand ) { - if (oDocument.m_oProperty.m_nDeffMathFont == PROP_DEF) - oDocument.m_oProperty.m_nDeffMathFont = parameter; + if (oDocument.m_oProperty.m_nDefMathFont == PROP_DEF) + oDocument.m_oProperty.m_nDefMathFont = parameter; RtfFont oFont; if( true == oDocument.m_oFontTable.GetFont(parameter, oFont) ) diff --git a/RtfFile/Format/RtfProperty.cpp b/RtfFile/Format/RtfProperty.cpp index bceb98ec19..1ca8558d61 100644 --- a/RtfFile/Format/RtfProperty.cpp +++ b/RtfFile/Format/RtfProperty.cpp @@ -156,10 +156,10 @@ std::wstring RtfFont::RenderToOOX(RenderParameter oRenderParameter) } if( sFontName.empty() ) { - if( PROP_DEF != poRtfDocument->m_oProperty.m_nDeffFont ) + if( PROP_DEF != poRtfDocument->m_oProperty.m_nDefFont ) { RtfFont oDefFont; - poRtfDocument->m_oFontTable.GetFont( poRtfDocument->m_oProperty.m_nDeffFont, oDefFont ); + poRtfDocument->m_oFontTable.GetFont( poRtfDocument->m_oProperty.m_nDefFont, oDefFont ); sFontName = oDefFont.m_sName; } if( sFontName.empty()) @@ -1615,11 +1615,19 @@ std::wstring RtfCharProperty::RenderToOOX(RenderParameter oRenderParameter) if( PROP_DEF == m_nFont) { if (RENDER_TO_OOX_PARAM_MATH == oRenderParameter.nType) - m_nFont = poRtfDocument->m_oProperty.m_nDeffMathFont; + m_nFont = poRtfDocument->m_oProperty.m_nDefMathFont; else - m_nFont = poRtfDocument->m_oProperty.m_nDeffFont; + m_nFont = poRtfDocument->m_oProperty.m_nDefFont; } - if( PROP_DEF != m_nFont ) + if (PROP_DEF == m_nLanguage) + { + m_nLanguage = poRtfDocument->m_oProperty.m_nDefLang; + } + if (PROP_DEF == m_nLanguageAsian) + { + m_nLanguageAsian = poRtfDocument->m_oProperty.m_nDefLangAsian; + } + if (PROP_DEF != m_nFont) { RtfFont oCurFont; RenderParameter oNewParam = oRenderParameter; diff --git a/RtfFile/Format/RtfReader.cpp b/RtfFile/Format/RtfReader.cpp index 55986b8e09..6098702b41 100644 --- a/RtfFile/Format/RtfReader.cpp +++ b/RtfFile/Format/RtfReader.cpp @@ -62,6 +62,8 @@ RtfReader::RtfReader(RtfDocument& oDocument, std::wstring sFilename ) : m_oDocum m_oState = ReaderStatePtr(new ReaderState()); m_nFootnote = PROP_DEF; m_nDefFont = PROP_DEF; + m_nDefLang = PROP_DEF; + m_nDefLangAsian = PROP_DEF; m_convertationManager = NULL; } bool RtfReader::Load() @@ -88,6 +90,12 @@ void RtfReader::PushState() if( PROP_DEF == m_oState->m_oCharProp.m_nFont ) m_oState->m_oCharProp.m_nFont = m_nDefFont; + + if (PROP_DEF == m_oState->m_oCharProp.m_nLanguage) + m_oState->m_oCharProp.m_nLanguage = m_nDefLang; + + if (PROP_DEF == m_oState->m_oCharProp.m_nLanguageAsian) + m_oState->m_oCharProp.m_nLanguageAsian = m_nDefLangAsian; } void RtfReader::PopState() { @@ -344,16 +352,16 @@ std::wstring RtfAbstractReader::ExecuteTextInternalCodePage( std::string& sCharS //применяем параметры codepage от текущего шрифта todo associated fonts. RtfFont oFont; - if( true == oDocument.m_oFontTable.GetFont( oReader.m_oState->m_oCharProp.m_nFont, oFont ) && !m_bUseGlobalCodepage) + if ( true == oDocument.m_oFontTable.GetFont( oReader.m_oState->m_oCharProp.m_nFont, oFont ) && !m_bUseGlobalCodepage) { - if( PROP_DEF != oFont.m_nCharset && oFont.m_nCharset > 1) - { - nCodepage = RtfUtility::CharsetToCodepage( oFont.m_nCharset ); - } - else if( PROP_DEF != oFont.m_nCodePage ) + if( PROP_DEF != oFont.m_nCodePage ) { nCodepage = oFont.m_nCodePage; } + else if (PROP_DEF != oFont.m_nCharset && (PROP_DEF == oDocument.m_oProperty.m_nAnsiCodePage || 0 == oDocument.m_oProperty.m_nAnsiCodePage)) + { + nCodepage = RtfUtility::CharsetToCodepage(oFont.m_nCharset); + } } //от настроек документа if( -1 == nCodepage && RtfDocumentProperty::cp_none != oDocument.m_oProperty.m_eCodePage ) diff --git a/RtfFile/Format/RtfReader.h b/RtfFile/Format/RtfReader.h index f3c5b7f945..bd848d0007 100644 --- a/RtfFile/Format/RtfReader.h +++ b/RtfFile/Format/RtfReader.h @@ -65,7 +65,9 @@ public: RtfLex m_oLex; int m_nFootnote; //толко для симовола chftn. основано на том что вложенных footnote быть не может int m_nDefFont; - std::wstring m_sTempFolder; + int m_nDefLang; + int m_nDefLangAsian; + std::wstring m_sTempFolder; RtfReader(RtfDocument& oDocument, std::wstring sFilename ); ~RtfReader(); diff --git a/RtfFile/Format/RtfSection.cpp b/RtfFile/Format/RtfSection.cpp index b9447da00c..40cd271222 100644 --- a/RtfFile/Format/RtfSection.cpp +++ b/RtfFile/Format/RtfSection.cpp @@ -57,8 +57,10 @@ void RtfDocumentProperty::SetDefault() { m_eCodePage = cp_ansi; m_nTabWidth = 720; //todo -1 - m_nDeffFont = PROP_DEF; - m_nDeffMathFont = PROP_DEF; + m_nDefFont = PROP_DEF; + m_nDefMathFont = PROP_DEF; + m_nDefLang = PROP_DEF; + m_nDefLangAsian = PROP_DEF; m_bHypCaps = PROP_DEF; m_bAutoHyp = PROP_DEF; m_nMaxHypen = PROP_DEF; diff --git a/RtfFile/Format/RtfSection.h b/RtfFile/Format/RtfSection.h index 44f099dd28..c5944fb4bd 100644 --- a/RtfFile/Format/RtfSection.h +++ b/RtfFile/Format/RtfSection.h @@ -46,8 +46,10 @@ public: } m_eCodePage; int m_nAnsiCodePage; - int m_nDeffFont; - int m_nDeffMathFont; + int m_nDefFont; + int m_nDefMathFont; + int m_nDefLang; + int m_nDefLangAsian; int m_bRtlGutter; int m_bRtl;