sw/qa/extras/uiwriter/uiwriter2.cxx | 43 ++++++++++++++--- sw/qa/extras/ww8export/data/image-comment-at-char.doc |binary sw/qa/extras/ww8export/ww8export3.cxx | 17 ++++++ sw/source/filter/basflt/fltshell.cxx | 11 ++++ sw/source/filter/ww8/wrtw8sty.cxx | 23 +++++++-- sw/source/filter/ww8/wrtww8.cxx | 3 - sw/source/filter/ww8/wrtww8.hxx | 7 ++ sw/source/uibase/frmdlg/frmmgr.cxx | 5 ++ sw/source/uibase/wrtsh/delete.cxx | 45 ++++++++++++++++++ sw/source/uibase/wrtsh/wrtsh1.cxx | 33 +++++++------ 10 files changed, 158 insertions(+), 29 deletions(-)
New commits: commit 2ff1f67270a94cfb797bed3dd521f9dd11d339fb Author: Miklos Vajna <[email protected]> AuthorDate: Thu Jul 4 17:40:09 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 5 10:39:50 2019 +0200 sw comments on frames: fix comment insert for as-char frame at para start This adapts SwWrtShell::InsertPostIt() to behave similar to commit 86fd893e32ef7a737b2c4b60e0938146b102fc07 (sw comments on frames: delete comment of frame when deleting frame, 2019-07-03), i.e. instead of hoping that the cursor will be at the end of paragraph and traveling back, just set the cursor to the remembered anchor position. This is cleaner, and as a side-effect also fixes the scenario when creating a comment on an as-char image, which happens to be at the start of the paragraph. Change-Id: Iedca0feb62242677b6e8b69ef7b813d6da72c8eb Reviewed-on: https://gerrit.libreoffice.org/75093 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins (cherry picked from commit b382025abcd05ff75dd2cbe46df76213d4913f00) diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index a2c8743bb481..58eb30a3953d 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1122,6 +1122,12 @@ void SwUiWriterTest2::testImageComment() SwDoc* pDoc = createDoc("image-comment.odt"); SwView* pView = pDoc->GetDocShell()->GetView(); + // Test document has "before<image>after", remove the content before the image. + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->SttEndDoc(/*bStart=*/true); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 6, /*bBasicCall=*/false); + pWrtShell->Delete(); + // Select the image. pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); @@ -1131,17 +1137,17 @@ void SwUiWriterTest2::testImageComment() // Verify that the comment is around the image. // Without the accompanying fix in place, this test would have failed, as FN_POSTIT was disabled // in the frame shell. + // Then this test would have failed, as in case the as-char anchored image was at the start of + // the paragraph, the comment of the image covered the character after the image, not the image. uno::Reference<text::XTextRange> xPara = getParagraph(1); - CPPUNIT_ASSERT_EQUAL(OUString("Text"), - getProperty<OUString>(getRun(xPara, 1), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), - getProperty<OUString>(getRun(xPara, 2), "TextPortionType")); + getProperty<OUString>(getRun(xPara, 1), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("Frame"), - getProperty<OUString>(getRun(xPara, 3), "TextPortionType")); + getProperty<OUString>(getRun(xPara, 2), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), - getProperty<OUString>(getRun(xPara, 4), "TextPortionType")); + getProperty<OUString>(getRun(xPara, 3), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("Text"), - getProperty<OUString>(getRun(xPara, 5), "TextPortionType")); + getProperty<OUString>(getRun(xPara, 4), "TextPortionType")); // Insert content to the comment, and select the image again. SfxStringItem aItem(FN_INSERT_STRING, "x"); diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index ef8abcb5beb1..6c67f3da69ad 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -1889,6 +1889,21 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, SfxRequest& rReq) { SwFlyFrame* pFly = GetSelectedFlyFrame(); + // Remember the anchor of the selected object before deletion. + std::unique_ptr<SwPosition> pAnchor; + if (pFly) + { + SwFrameFormat* pFormat = pFly->GetFormat(); + if (pFormat) + { + RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId(); + if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR) && pFormat->GetAnchor().GetContentAnchor()) + { + pAnchor.reset(new SwPosition(*pFormat->GetAnchor().GetContentAnchor())); + } + } + } + // A frame is selected, end frame selection. EnterStdMode(); GetView().AttrChangedNotify(this); @@ -1897,6 +1912,7 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, SfxRequest& rReq) // comment. if (pFly) { + *GetCurrentShellCursor().GetPoint() = *pAnchor; SwFrameFormat* pFormat = pFly->GetFormat(); if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR) { @@ -1904,21 +1920,8 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, SfxRequest& rReq) } else if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) { - // Ending the frame selection positions the cursor at the end of the paragraph, - // move it to the anchor position. - sal_Int32 nCursor = GetCurrentShellCursor().GetPoint()->nContent.GetIndex(); - const SwPosition* pAnchor = pFormat->GetAnchor().GetContentAnchor(); - if (pAnchor) - { - sal_Int32 nDiff = nCursor - pAnchor->nContent.GetIndex(); - if (nDiff > 0) - { - Left(CRSR_SKIP_CELLS, /*bSelect=*/false, nDiff, /*bBasicCall=*/false, - /*bVisual=*/true); - aData.m_pAnnotationRange.reset(new SwPaM( - *GetCurrentShellCursor().Start(), *GetCurrentShellCursor().End())); - } - } + aData.m_pAnnotationRange.reset(new SwPaM(*GetCurrentShellCursor().Start(), + *GetCurrentShellCursor().End())); } } } commit 4e55f581dbb94212adf5d12f5016f1d5ba958990 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Jul 4 15:50:31 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 5 10:38:53 2019 +0200 sw: insert image: set anchor to as-char by default See the mailing list thread at https://www.mail-archive.com/search?l=mid&[email protected] (minutes of ESC call ..., 2019-05-09) for motivation, this is meant to improve Word compatibility, by not defaulting to the at-paragraph anchor type, which is unavailable in Word. See tdf#45778 and tdf#87720 for related bugs. (cherry picked from commit 4f40bf6a79de6d60da0a5090cdfeda6242e889f0) [ Testcase not backported, testPasteListener is missing on cp-6.2 and we would extend that. ] Conflicts: sw/qa/extras/unowriter/unowriter.cxx Change-Id: I2699ce04dce02e8436dc3af3b2cc8778f8dc476c diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx index 1debb81ca787..627a5d4ffdd2 100644 --- a/sw/source/uibase/frmdlg/frmmgr.cxx +++ b/sw/source/uibase/frmdlg/frmmgr.cxx @@ -84,6 +84,11 @@ SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nT m_aSet.Put( SwFormatFrameSize( ATT_MIN_SIZE, DFLT_WIDTH, DFLT_HEIGHT )); if ( 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()) ) m_aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::PRINT_AREA ) ); + + if (nType == Frmmgr_Type::GRF || nType == Frmmgr_Type::OLE) + { + m_aSet.Put(SwFormatAnchor(RndStdIds::FLY_AS_CHAR)); + } } else if ( nType == Frmmgr_Type::NONE ) { commit 71d07860b2008bc2bd14fd99622999aae1be8083 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Jul 4 10:23:50 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 5 10:36:31 2019 +0200 sw comments on frames: delete comment of as-char frame when deleting frame Also make sure that we only recognize postit fields as comments, not other fields. Change-Id: I31c8e5d46bb7681710734c5a0b8a26c3a70f417e Reviewed-on: https://gerrit.libreoffice.org/75072 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins (cherry picked from commit dcfe6eaee16cac0aff4a66efbe19c69431579485) diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index a9338af0c5c0..a2c8743bb481 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1142,6 +1142,18 @@ void SwUiWriterTest2::testImageComment() getProperty<OUString>(getRun(xPara, 4), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(xPara, 5), "TextPortionType")); + + // Insert content to the comment, and select the image again. + SfxStringItem aItem(FN_INSERT_STRING, "x"); + pView->GetViewFrame()->GetDispatcher()->ExecuteList(FN_INSERT_STRING, SfxCallMode::SYNCHRON, + { &aItem }); + pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + // Now delete the image. + pView->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE, SfxCallMode::SYNCHRON); + // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual: + // 1', i.e. the comment of the image was not deleted when the image was deleted. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), + pDoc->getIDocumentMarkAccess()->getAnnotationMarksCount()); } void SwUiWriterTest2::testImageCommentAtChar() diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index 3827dbd83c97..6eee53fb3bee 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -26,6 +26,8 @@ #include <fmtanchr.hxx> #include <flyfrm.hxx> #include <ndtxt.hxx> +#include <txtfld.hxx> +#include <docufld.hxx> #include <IDocumentUndoRedo.hxx> #include <rtl/character.hxx> @@ -420,9 +422,11 @@ bool SwWrtShell::DelRight() if (pFly) { SwFrameFormat* pFormat = pFly->GetFormat(); - if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) + if (pFormat) { - if (pFormat->GetAnchor().GetContentAnchor()) + RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId(); + if ((eAnchorId == RndStdIds::FLY_AS_CHAR || eAnchorId == RndStdIds::FLY_AT_CHAR) + && pFormat->GetAnchor().GetContentAnchor()) { pAnchor.reset(new SwPosition(*pFormat->GetAnchor().GetContentAnchor())); } @@ -441,7 +445,8 @@ bool SwWrtShell::DelRight() { const SwTextField* pField( pTextNode->GetFieldTextAttrAt(pAnchor->nContent.GetIndex(), true)); - if (pField) + if (pField + && dynamic_cast<const SwPostItField*>(pField->GetFormatField().GetField())) { // Remove the comment of the deleted object. *GetCurrentShellCursor().GetPoint() = *pAnchor; commit 8d1b56fd1d2f4640059afff8c9a91341cb7f9230 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Jul 3 14:05:05 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 5 10:35:41 2019 +0200 sw comments on frames: delete comment of frame when deleting frame Also group the two actions together, so only 1 undo action is visible to the user, not 2. (cherry picked from commit 86fd893e32ef7a737b2c4b60e0938146b102fc07) Conflicts: sw/qa/extras/uiwriter/uiwriter2.cxx sw/source/uibase/wrtsh/delete.cxx Change-Id: Idba5a63b1653e96db4f9567a38b3f4ca740eb1df diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 2d8eb8049e3a..a9338af0c5c0 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -27,6 +27,7 @@ #include <fmtornt.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/dispatch.hxx> +#include <svl/stritem.hxx> #include <view.hxx> #include <cmdid.h> #include <com/sun/star/style/BreakType.hpp> @@ -1169,6 +1170,18 @@ void SwUiWriterTest2::testImageCommentAtChar() getProperty<OUString>(getRun(xPara, 4), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(xPara, 5), "TextPortionType")); + + // Insert content to the comment, and select the image again. + SfxStringItem aItem(FN_INSERT_STRING, "x"); + pView->GetViewFrame()->GetDispatcher()->ExecuteList(FN_INSERT_STRING, SfxCallMode::SYNCHRON, + { &aItem }); + pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + // Now delete the image. + pView->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE, SfxCallMode::SYNCHRON); + // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual: + // 1', i.e. the comment of the image was not deleted when the image was deleted. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), + pDoc->getIDocumentMarkAccess()->getAnnotationMarksCount()); } void SwUiWriterTest2::testTdf124261() diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index d15a46db78b3..3827dbd83c97 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -23,6 +23,10 @@ #include <view.hxx> #include <drawbase.hxx> #include <unobaseclass.hxx> +#include <fmtanchr.hxx> +#include <flyfrm.hxx> +#include <ndtxt.hxx> +#include <IDocumentUndoRedo.hxx> #include <rtl/character.hxx> inline void SwWrtShell::OpenMark() @@ -410,8 +414,44 @@ bool SwWrtShell::DelRight() // #108205# Remember object's position. Point aTmpPt = GetObjRect().TopLeft(); + // Remember the anchof of the selected object before deletion. + std::unique_ptr<SwPosition> pAnchor; + SwFlyFrame* pFly = GetSelectedFlyFrame(); + if (pFly) + { + SwFrameFormat* pFormat = pFly->GetFormat(); + if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_CHAR) + { + if (pFormat->GetAnchor().GetContentAnchor()) + { + pAnchor.reset(new SwPosition(*pFormat->GetAnchor().GetContentAnchor())); + } + } + } + + // Group deletion of the object and its comment together. + mxDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr); + DelSelectedObj(); + if (pAnchor) + { + SwTextNode* pTextNode = pAnchor->nNode.GetNode().GetTextNode(); + if (pTextNode) + { + const SwTextField* pField( + pTextNode->GetFieldTextAttrAt(pAnchor->nContent.GetIndex(), true)); + if (pField) + { + // Remove the comment of the deleted object. + *GetCurrentShellCursor().GetPoint() = *pAnchor; + DelRight(); + } + } + } + + mxDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr); + // #108205# Set cursor to remembered position. SetCursor(&aTmpPt); commit 6a55cddbfb04c865bed3fbae5b39651819448ef3 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Jul 3 10:35:48 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 5 10:33:25 2019 +0200 sw comments on frames: fix DOC handling The export part didn't use HasFlysAt() to decide what to do with empty annotation marks. Regarding the import side, the only problem was that the start of the annotation range wasn't adjusted to cover the comment anchor, similar to what the UI and the UNO API already does. (cherry picked from commit 132803f99818bffbdc260918ad7a304f228f2843) Conflicts: sw/qa/extras/ww8export/ww8export3.cxx Change-Id: Ibcbaafa9f3f70de95a70b424aca31ebdc9df099d diff --git a/sw/qa/extras/ww8export/data/image-comment-at-char.doc b/sw/qa/extras/ww8export/data/image-comment-at-char.doc new file mode 100644 index 000000000000..e0d5e2cba456 Binary files /dev/null and b/sw/qa/extras/ww8export/data/image-comment-at-char.doc differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index ba99e05deb36..ab03906eaede 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -223,6 +223,23 @@ DECLARE_WW8EXPORT_TEST(testBtlrCell, "btlr-cell.doc") CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, "WritingMode")); } +DECLARE_WW8EXPORT_TEST(testImageCommentAtChar, "image-comment-at-char.doc") +{ + uno::Reference<text::XTextRange> xPara = getParagraph(1); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), + getProperty<OUString>(getRun(xPara, 1), "TextPortionType")); + // Without the accompanying fix in place, this test would have failed with 'Expected: + // Annotation; Actual: Frame', i.e. the comment start before the image was lost. + CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), + getProperty<OUString>(getRun(xPara, 2), "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("Frame"), + getProperty<OUString>(getRun(xPara, 3), "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), + getProperty<OUString>(getRun(xPara, 4), "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), + getProperty<OUString>(getRun(xPara, 5), "TextPortionType")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index bfd9d621a8e2..ee4d46bbc833 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -662,6 +662,17 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, if (pPostIt) { assert(pPostIt->GetName().isEmpty()); + + if (!aRegion.HasMark()) + { + // Annotation range was found in the file, but start/end is the same, + // pointing after the postit placeholder (see assert above). + // Adjust the start of the range to actually cover the comment, similar + // to what the UI and the UNO API does. + aRegion.SetMark(); + --aRegion.Start()->nContent; + } + pDoc->getIDocumentMarkAccess()->makeAnnotationMark(aRegion, OUString()); } else diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index af39bf4ef063..9aa5621ab3fc 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -1961,9 +1961,20 @@ WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline) maDateTime = pRedline->GetTimeStamp(); } -void WW8_WrPlcAnnotations::AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp) +bool WW8_Annotation::HasRange() const { - m_aRangeStartPositions[rName] = nStartCp; + if (m_nRangeStart != m_nRangeEnd) + { + return true; + } + + return !m_bIgnoreEmpty; +} + +void WW8_WrPlcAnnotations::AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp, + bool bIgnoreEmpty) +{ + m_aRangeStartPositions[rName] = std::make_pair(nStartCp, bIgnoreEmpty); } void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt ) @@ -1972,7 +1983,9 @@ void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt ) WW8_Annotation* p; if( m_aRangeStartPositions.find(pPostIt->GetName()) != m_aRangeStartPositions.end() ) { - p = new WW8_Annotation(pPostIt, m_aRangeStartPositions[pPostIt->GetName()], nCp); + auto [nStartCp, bIgnoreEmpty] = m_aRangeStartPositions[pPostIt->GetName()]; + p = new WW8_Annotation(pPostIt, nStartCp, nCp); + p->m_bIgnoreEmpty = bIgnoreEmpty; m_aRangeStartPositions.erase(pPostIt->GetName()); } else @@ -2177,7 +2190,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(aContent[i]); aStrArr.emplace_back(rAtn.msOwner,rAtn.m_sInitials); // record start and end positions for ranges - if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd ) + if (rAtn.HasRange()) { aRangeStartPos.emplace_back(rAtn.m_nRangeStart, nIdx); aRangeEndPos.emplace_back(rAtn.m_nRangeEnd, nIdx); @@ -2402,7 +2415,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos ); SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); - if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd ) + if (rAtn.HasRange()) { SwWW8Writer::WriteLong( *rWrt.pTableStrm, nlTag ); ++nlTag; diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 8d41ab508441..8ab70eb01ddc 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -1491,7 +1491,8 @@ void WW8Export::AppendAnnotationMarks(const SwWW8AttrIter& rAttrs, sal_Int32 nCu const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex(); if (nStart == nCurrentPos) { - m_pAtn->AddRangeStartPosition(pMark->GetName(), Fc2Cp(Strm().Tell())); + m_pAtn->AddRangeStartPosition(pMark->GetName(), Fc2Cp(Strm().Tell()), + !rAttrs.HasFlysAt(nCurrentPos)); } } } diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 3541fe242bdf..4d7a465c9696 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1228,8 +1228,11 @@ struct WW8_Annotation OUString m_sInitials; DateTime maDateTime; WW8_CP m_nRangeStart, m_nRangeEnd; + bool m_bIgnoreEmpty = true; WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd); explicit WW8_Annotation(const SwRedlineData* pRedline); + /// An annotation has a range if start != end or the m_bIgnoreEmpty flag is cleared. + bool HasRange() const; }; class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc // double Plc for Postits @@ -1239,12 +1242,12 @@ private: WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations const &) = delete; std::set<const SwRedlineData*> maProcessedRedlines; - std::map<const OUString, WW8_CP> m_aRangeStartPositions; + std::map<const OUString, std::pair<WW8_CP, bool>> m_aRangeStartPositions; public: WW8_WrPlcAnnotations() {} virtual ~WW8_WrPlcAnnotations() override; - void AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp); + void AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp, bool bIgnoreEmpty); void Append( WW8_CP nCp, const SwPostItField* pPostIt ); void Append( WW8_CP nCp, const SwRedlineData* pRedLine ); bool IsNewRedlineComment( const SwRedlineData* pRedLine ); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
