summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/uiwriter/data2/image-comment.odtbin0 -> 9847 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx34
-rw-r--r--sw/sdi/_frmsh.sdi5
-rw-r--r--sw/source/uibase/inc/frmsh.hxx1
-rw-r--r--sw/source/uibase/shells/frmsh.cxx14
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx22
6 files changed, 76 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/image-comment.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index b78454a061b4..cc64ae74c37f 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -24,6 +24,10 @@
#include <xmloff/odffields.hxx>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <fmtornt.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <view.hxx>
+#include <cmdid.h>
namespace
{
@@ -45,6 +49,7 @@ public:
void testDropDownFormFieldInsertion();
void testMixedFormFieldInsertion();
void testTdf122942();
+ void testImageComment();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testTdf101534);
@@ -57,6 +62,7 @@ public:
CPPUNIT_TEST(testDropDownFormFieldInsertion);
CPPUNIT_TEST(testMixedFormFieldInsertion);
CPPUNIT_TEST(testTdf122942);
+ CPPUNIT_TEST(testImageComment);
CPPUNIT_TEST_SUITE_END();
private:
@@ -477,6 +483,34 @@ void SwUiWriterTest2::testTdf122942()
#endif
}
+void 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"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/sdi/_frmsh.sdi b/sw/sdi/_frmsh.sdi
index 734b50c5ebc1..bd15005dc98d 100644
--- a/sw/sdi/_frmsh.sdi
+++ b/sw/sdi/_frmsh.sdi
@@ -400,5 +400,10 @@ interface BaseTextFrame
ExecMethod = Execute ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
+ FN_POSTIT
+ [
+ ExecMethod = ExecField ;
+ StateMethod = NoState ;
+ ]
}
diff --git a/sw/source/uibase/inc/frmsh.hxx b/sw/source/uibase/inc/frmsh.hxx
index f86e0d06501f..cf7ebbb1e139 100644
--- a/sw/source/uibase/inc/frmsh.hxx
+++ b/sw/source/uibase/inc/frmsh.hxx
@@ -35,6 +35,7 @@ public:
virtual ~SwFrameShell() override;
void Execute(SfxRequest &);
+ 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 3bf07359d1f3..d53c993df030 100644
--- a/sw/source/uibase/shells/frmsh.cxx
+++ b/sw/source/uibase/shells/frmsh.cxx
@@ -86,6 +86,7 @@
#include <sfx2/msg.hxx>
#include <swslots.hxx>
#include <grfatr.hxx>
+#include <fldmgr.hxx>
using ::editeng::SvxBorderLine;
using namespace ::com::sun::star;
@@ -114,6 +115,19 @@ void SwFrameShell::InitInterface_Impl()
GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Frame_Toolbox);
}
+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 2ce1783a80b0..40d07646592b 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -89,6 +89,7 @@
#include <IMark.hxx>
#include <sfx2/bindings.hxx>
#include <svx/dialmgr.hxx>
+#include <flyfrm.hxx>
// -> #111827#
#include <SwRewriter.hxx>
@@ -1879,6 +1880,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();