diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp index fa9bd0b4fb..c4ad457196 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp @@ -2852,8 +2852,8 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead oAbstrReader.StartSubReader( oAnnotElemReader, oDocument, oReader ); - //if ( pNewAnnotElem->IsValid() ) - // m_oCurParagraph->AddItem( pNewAnnotElem ); + if ( pNewAnnotElem->IsValid() ) + m_oCurParagraph->AddItem( pNewAnnotElem ); } else if ( "atnauthor" == sCommand ) { @@ -2862,8 +2862,8 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead oAbstrReader.StartSubReader( oAnnotElemReader, oDocument, oReader ); - //if ( pNewAnnotElem->IsValid() ) - // m_oCurParagraph->AddItem( pNewAnnotElem ); + if ( pNewAnnotElem->IsValid() ) + m_oCurParagraph->AddItem( pNewAnnotElem ); } else if ( "atnref" == sCommand ) { diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp index 0f7b3bd66d..c2d3618396 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfBookmark.cpp @@ -132,31 +132,50 @@ std::wstring RtfAnnotElem::RenderToRtf(RenderParameter oRenderParameter) std::wstring RtfAnnotElem::RenderToOOX(RenderParameter oRenderParameter) { - if (m_nType > 3 || m_nType < 1) return L""; + if (m_nType > 8 || m_nType < 1) return L""; std::wstring sResult; OOXWriter* poOOXWriter = static_cast (oRenderParameter.poWriter); OOXCommentsWriter* poCommentsWriter = static_cast( poOOXWriter->m_poCommentsWriter ); - std::map::iterator pFind = poCommentsWriter->m_mapRefs.find(m_sValue); - - int id = -1; - if (pFind == poCommentsWriter->m_mapRefs.end()) + if (m_nType == 4) { - id = poCommentsWriter->m_mapRefs.size() ;//+ 1; - poCommentsWriter->m_mapRefs.insert(std::make_pair(m_sValue, id)); + poCommentsWriter->AddCommentAuthor(m_sValue); + } + else if (m_nType == 5) + { + poCommentsWriter->AddCommentID(m_sValue); } else { - id = pFind->second; - } - if (m_nType == 1) sResult += L""; - else if (m_nType == 3) sResult += L""; - else if (m_nType == 2) - { - sResult += L""; - sResult += L""; + std::map::iterator pFind = poCommentsWriter->m_mapComments.find(m_sValue); + + int id = -1; + if (pFind == poCommentsWriter->m_mapComments.end()) + { + id = poCommentsWriter->m_mapComments.size() ;//+ 1; + poCommentsWriter->AddComment(m_sValue, id); + } + else + { + id = pFind->second.nID; + } + if (m_nType == 1) + { + sResult += L""; + } + else if (m_nType == 3) + { + sResult += L""; + } + else if (m_nType == 2) + { + poCommentsWriter->SetCommentEnd(m_sValue); + + sResult += L""; + sResult += L""; + } } return sResult; @@ -180,33 +199,14 @@ std::wstring RtfAnnotation::RenderToOOX(RenderParameter oRenderParameter) OOXWriter* poOOXWriter = static_cast (oRenderParameter.poWriter); OOXCommentsWriter* poCommentsWriter = static_cast( poOOXWriter->m_poCommentsWriter ); - std::wstring sResult; - - sResult += L"::iterator pFind = poCommentsWriter->m_mapRefs.find(m_oRef->m_sValue); + if (!m_oRef) return L""; - if (pFind == poCommentsWriter->m_mapRefs.end()) - { - id = poCommentsWriter->m_mapRefs.size();// + 1; - poCommentsWriter->m_mapRefs.insert(std::make_pair(m_oRef->m_sValue, id)); - } - else - { - id = pFind->second; - } - sResult += L" w:id=\"" + std::to_wstring(id) + L"\""; - } - sResult += L" w:author=\"Elena S\""; if (m_oDate) { int nValue = boost::lexical_cast(m_oDate->m_sValue); - sResult += L" w:date=\"" + RtfUtility::convertDateTime(nValue) + L"\""; + + poCommentsWriter->AddCommentDate(m_oRef->m_sValue, RtfUtility::convertDateTime(nValue)); } - sResult += L" w:initials=\"ES\""; - sResult += L">"; if (m_oContent) { RenderParameter oNewParameter = oRenderParameter; @@ -214,13 +214,16 @@ std::wstring RtfAnnotation::RenderToOOX(RenderParameter oRenderParameter) oNewParameter.nType = RENDER_TO_OOX_PARAM_COMMENT; oNewParameter.poRels = poCommentsWriter->m_oRelsWriter.get(); - sResult += m_oContent->RenderToOOX(oNewParameter); + std::wstring content = m_oContent->RenderToOOX(oNewParameter); + + std::wstring sParaId = XmlUtils::IntToString(poOOXWriter->m_nextParaId, L"%08X");//last para id in comment + + poCommentsWriter->AddCommentContent(m_oRef->m_sValue, sParaId, content); + } + if (m_oParent) + { + poCommentsWriter->AddCommentParent(m_oRef->m_sValue, m_oParent->m_sValue); } - sResult += L""; - - std::wstring sParaId = XmlUtils::IntToString(poOOXWriter->m_nextParaId, L"%08X");//last para id in comment - poCommentsWriter->AddComment(id, sResult, sParaId, m_oParent ? boost::lexical_cast(m_oParent->m_sValue) : 0); - return L""; } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXCommentsWriter.h b/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXCommentsWriter.h index 9166ab84f1..3ba05f2941 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXCommentsWriter.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXCommentsWriter.h @@ -43,30 +43,66 @@ public: m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("comments.xml"), oDocument ) ); oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter ); } - void AddComment( int nID, std::wstring sText, const std::wstring & paraId, int nParentID) + void SetCommentEnd(const std::wstring & ref) //for author { - m_sComments += sText; - - m_mapCommentsParent.insert(std::make_pair(nID, paraId)); - - m_sCommentsExtended += L"::iterator pFind = m_mapCommentsParent.find(nParentID); - - if (pFind != m_mapCommentsParent.end()) - { - m_sCommentsExtended += L" w15:paraIdParent=\"" + pFind->second + L"\""; - } - } - m_sCommentsExtended += L" w15:done=\"0\"/>"; + m_sCurrent_ref = ref; } - - bool Save( std::wstring sFolder ) + void AddComment( const std::wstring & ref, int nID) { - if( m_sComments.empty() ) return false; + _comment comment(nID); + m_mapComments.insert(std::make_pair(ref, comment)); + } + void AddCommentID( const std::wstring & id) + { + std::map::iterator pFind = m_mapComments.find(m_sCurrent_ref); + + if (pFind != m_mapComments.end()) + { + pFind->second.authorId = id; + } + } + void AddCommentAuthor( const std::wstring & author) + { + std::map::iterator pFind = m_mapComments.find(m_sCurrent_ref); + + if (pFind != m_mapComments.end()) + { + pFind->second.author = author; + } + } + void AddCommentContent( const std::wstring & ref, const std::wstring & paraId, const std::wstring & content) + { + std::map::iterator pFind = m_mapComments.find(ref); + + if (pFind != m_mapComments.end()) + { + pFind->second.content = content; + pFind->second.paraId = paraId; + + m_mapCommentsParent.insert(std::make_pair(pFind->second.nID, paraId)); + } + } + void AddCommentParent( const std::wstring & ref, const std::wstring & parent) + { + std::map::iterator pFind = m_mapComments.find(ref); + + if (pFind != m_mapComments.end()) + { + pFind->second.nParentID = boost::lexical_cast(parent); + } + } + void AddCommentDate( const std::wstring & ref, const std::wstring & date) + { + std::map::iterator pFind = m_mapComments.find(ref); + + if (pFind != m_mapComments.end()) + { + pFind->second.date = date; + } + } + bool Save( std::wstring sFolder ) + { + if( m_mapComments.empty() ) return false; CFile file; if (file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("comments.xml"))) return false; @@ -82,8 +118,6 @@ public: file.CloseFile(); //------------------------------------------------------------------------------------------------------------------------- - if( m_sCommentsExtended.empty() ) return true; - if (file.CreateFile(sFolder + FILE_SEPARATOR_STR + L"commentsExtended.xml")) return false; m_oWriter.m_oDocRels.AddRelationship( L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml" ); @@ -98,46 +132,82 @@ public: file.CloseFile(); return true; } - std::map m_mapRefs; - std::map m_mapCommentsParent; + struct _comment + { + _comment(int id) : nID(id) {} + int nID = 0; + int nParentID = 0; + std::wstring author; + std::wstring date; + std::wstring content; + std::wstring authorId; + std::wstring paraId; + + }; + std::map m_mapComments; private: RtfDocument& m_oDocument; OOXWriter& m_oWriter; - std::wstring m_sComments; - std::wstring m_sCommentsExtended; + std::wstring m_sCurrent_ref; + std::wstring m_sCommentsExtended; + std::map m_mapCommentsParent; std::wstring CreateXml() { - std::wstring sResult; - sResult += _T("\n"); + std::wstring sResult = L"\n"; - sResult += _T(""); - sResult += m_sComments; - sResult += _T(""); +xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \ +mc:Ignorable=\"w14 w15 wp14\">"; + + for (std::map::iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it) + { + sResult += L"second.nID) + L"\" w:author=\"" + + it->second.author + L"\" w:date=\"" + it->second.date + L"\" w:initials=\"" + it->second.authorId + L"\">"; + sResult += it->second.content; + + sResult += L""; +//-------------------------------------------------------- + m_sCommentsExtended += L"second.paraId + L"\""; + if (it->second.nParentID != 0) + { + it->second.nParentID = it->second.nID + it->second.nParentID; + + std::map::iterator pFind = m_mapCommentsParent.find(it->second.nParentID); + + if (pFind != m_mapCommentsParent.end()) + { + m_sCommentsExtended += L" w15:paraIdParent=\"" + pFind->second + L"\""; + } + } + m_sCommentsExtended += L" w15:done=\"0\"/>"; + + } + sResult += L""; return sResult; } std::wstring CreateXmlExtended() { std::wstring sResult; - sResult += _T("\n"); + sResult += L"\n"; - sResult += _T(""); +mc:Ignorable=\"w14 w15 w16se wp14\">"; sResult += m_sCommentsExtended; - sResult += _T(""); + sResult += L""; return sResult; } diff --git a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h index febbe6c19a..64196119fd 100644 --- a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h +++ b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h @@ -515,6 +515,9 @@ namespace MetaFile else //if (WINDING == unFillMode) unClipMode |= c_nClipRegionTypeWinding; + if (RGN_COPY == unMode) + ResetClip(); + m_pRenderer->put_ClipMode(unClipMode); m_pRenderer->BeginCommand(c_nClipType); m_pRenderer->BeginCommand(c_nPathType); diff --git a/DesktopEditor/raster/Metafile/Emf/EmfFile.cpp b/DesktopEditor/raster/Metafile/Emf/EmfFile.cpp index c5abce5cc3..d6573ce89a 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfFile.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfFile.cpp @@ -232,7 +232,7 @@ static const struct ActionNamesEmf //----------------------------------------------------------- // 2.3.2 Clipping //----------------------------------------------------------- - case EMR_EXCLUDECLIPRECT: Read_EMR_EXCLUDECLIPRECT(); break; + case EMR_EXCLUDECLIPRECT: Read_EMR_EXCLUDECLIPRECT(); break; case EMR_EXTSELECTCLIPRGN: Read_EMR_EXTSELECTCLIPRGN(); break; case EMR_INTERSECTCLIPRECT: Read_EMR_INTERSECTCLIPRECT(); break; case EMR_SELECTCLIPPATH: Read_EMR_SELECTCLIPPATH(); break;