sw/qa/extras/uiwriter/uiwriter2.cxx | 12 ++++++++++++ sw/source/uibase/frmdlg/frmmgr.cxx | 5 +++++ sw/source/uibase/wrtsh/delete.cxx | 11 ++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-)
New commits: commit a59cec34225893f352b4fb6d6c416ade0717eccd Author: Miklos Vajna <[email protected]> AuthorDate: Thu Jul 4 15:50:31 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Jul 8 10:32:38 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 Reviewed-on: https://gerrit.libreoffice.org/75122 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx index 2bf04a3cce44..184b4177fbb3 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 a878adbe0f5e032e34b43d3fdc0c6a7c7659dc6c Author: Miklos Vajna <[email protected]> AuthorDate: Thu Jul 4 10:23:50 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Jul 8 10:32:25 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) Reviewed-on: https://gerrit.libreoffice.org/75121 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 7a6ccec9adfc..bc1fe510dc03 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -512,6 +512,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 0d060586645c..9bbf81bf21c0 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> inline void SwWrtShell::OpenMark() @@ -377,9 +379,11 @@ long 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())); } @@ -398,7 +402,8 @@ long 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; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
