[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 4 13:34:35 UTC 2019
sw/qa/extras/uiwriter/uiwriter2.cxx | 12 ++++++++++++
sw/source/uibase/wrtsh/delete.cxx | 11 ++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
New commits:
commit dcfe6eaee16cac0aff4a66efbe19c69431579485
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jul 4 10:23:50 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 4 15:33:55 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 <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 24e3f3ddec38..854cb288c617 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1589,6 +1589,18 @@ CPPUNIT_TEST_FIXTURE(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());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageCommentAtChar)
diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx
index 81d088cc2ba1..cbb3fad91b69 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 <i18nutil/unicode.hxx>
#include <rtl/character.hxx>
@@ -404,9 +406,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()));
}
@@ -425,7 +429,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;
More information about the Libreoffice-commits
mailing list