[Libreoffice-commits] core.git: sw/qa sw/sdi sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 18 17:13:09 UTC 2019
sw/qa/extras/uiwriter/data2/image-comment.odt |binary
sw/qa/extras/uiwriter/uiwriter2.cxx | 32 ++++++++++++++++++++++++++
sw/sdi/_frmsh.sdi | 5 ++++
sw/source/uibase/inc/frmsh.hxx | 1
sw/source/uibase/shells/frmsh.cxx | 14 +++++++++++
sw/source/uibase/wrtsh/wrtsh1.cxx | 22 +++++++++++++++++
6 files changed, 74 insertions(+)
New commits:
commit 351b9aefe3de7c68e907fdc7926d9b508560320e
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jun 18 17:44:33 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jun 18 19:11:50 2019 +0200
sw: implement inserting comments when an as-char image is selected
Only the UI was missing in this case: creating a text selection around
the placeholder character does what the user expects.
Change-Id: I1068fcee3e3b6d0a6fa47b37beb1bd1b918a82df
Reviewed-on: https://gerrit.libreoffice.org/74297
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/uiwriter/data2/image-comment.odt b/sw/qa/extras/uiwriter/data2/image-comment.odt
new file mode 100644
index 000000000000..4f0a520bcca3
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/image-comment.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index b283af27b24c..4da4123e3322 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -27,8 +27,12 @@
#include <itabenum.hxx>
#include <fmtfsize.hxx>
#include <xmloff/odffields.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
#include <txtfrm.hxx>
#include <redline.hxx>
+#include <view.hxx>
+#include <cmdid.h>
#include <com/sun/star/style/BreakType.hpp>
namespace
@@ -1357,4 +1361,32 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf125310b)
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageComment)
+{
+ // Load a document with an as-char image in it.
+ SwDoc* pDoc = createDoc("image-comment.odt");
+ SwView* pView = pDoc->GetDocShell()->GetView();
+
+ // Select the image.
+ pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON);
+
+ // Insert a comment while the image is selected.
+ pView->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT, SfxCallMode::SYNCHRON);
+
+ // 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.
+ 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"));
+ 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"));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_frmsh.sdi b/sw/sdi/_frmsh.sdi
index 398cd30a93ff..87df09bb3f5b 100644
--- a/sw/sdi/_frmsh.sdi
+++ b/sw/sdi/_frmsh.sdi
@@ -411,5 +411,10 @@ interface BaseTextFrame
ExecMethod = ExecMove ;
StateMethod = NoState ;
]
+ FN_POSTIT
+ [
+ ExecMethod = ExecField ;
+ StateMethod = NoState ;
+ ]
}
diff --git a/sw/source/uibase/inc/frmsh.hxx b/sw/source/uibase/inc/frmsh.hxx
index 4b8a64c75823..e3e900acce56 100644
--- a/sw/source/uibase/inc/frmsh.hxx
+++ b/sw/source/uibase/inc/frmsh.hxx
@@ -36,6 +36,7 @@ public:
void Execute(SfxRequest &);
void ExecMove(SfxRequest& rReq);
+ void ExecField(SfxRequest& rReq);
void GetState(SfxItemSet &);
void ExecFrameStyle(SfxRequest const & rReq);
void GetLineStyleState(SfxItemSet &rSet);
diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx
index dfb403b9ffcf..41a6994204ed 100644
--- a/sw/source/uibase/shells/frmsh.cxx
+++ b/sw/source/uibase/shells/frmsh.cxx
@@ -87,6 +87,7 @@
#include <sfx2/msg.hxx>
#include <swslots.hxx>
#include <grfatr.hxx>
+#include <fldmgr.hxx>
using ::editeng::SvxBorderLine;
using namespace ::com::sun::star;
@@ -128,6 +129,19 @@ void SwFrameShell::ExecMove(SfxRequest& rReq)
}
}
+void SwFrameShell::ExecField(SfxRequest& rReq)
+{
+ SwWrtShell& rSh = GetShell();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch (nSlot)
+ {
+ case FN_POSTIT:
+ SwFieldMgr aFieldMgr(&rSh);
+ rSh.InsertPostIt(aFieldMgr, rReq);
+ break;
+ }
+}
+
void SwFrameShell::Execute(SfxRequest &rReq)
{
//First those who do not need FrameMgr.
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index f4bf6e00eae8..0b4ae14c8290 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -91,6 +91,7 @@
#include <IMark.hxx>
#include <sfx2/bindings.hxx>
#include <fchrfmt.hxx>
+#include <flyfrm.hxx>
// -> #111827#
#include <SwRewriter.hxx>
@@ -1906,6 +1907,27 @@ void SwWrtShell::InsertPostIt(SwFieldMgr& rFieldMgr, SfxRequest& rReq)
GetView().GetEditWin().StopQuickHelp();
SwInsertField_Data aData(TYP_POSTITFLD, 0, sAuthor, sText, 0);
+
+ if (IsSelFrameMode())
+ {
+ SwFlyFrame* pFly = GetSelectedFlyFrame();
+
+ // A frame is selected, end frame selection.
+ EnterStdMode();
+ GetView().AttrChangedNotify(this);
+
+ // Set up text selection, so the anchor of the frame will be the anchor of the
+ // comment.
+ if (pFly)
+ {
+ SwFrameFormat* pFormat = pFly->GetFormat();
+ if (pFormat && pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ {
+ Right(CRSR_SKIP_CELLS, /*bSelect=*/true, 1, /*bBasicCall=*/false, /*bVisual=*/true);
+ }
+ }
+ }
+
rFieldMgr.InsertField( aData );
Push();
More information about the Libreoffice-commits
mailing list