diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-05-20 13:31:45 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-20 16:55:16 +0200 |
commit | 73ed5e36047b6f46b3777bf6f36591ec4babb1f9 (patch) | |
tree | 904961b0b4dbca06dc3c1e54f444742de9e387f9 /sw/qa/uibase | |
parent | ff0387e726b59e374029d2f635ce00308d99eff6 (diff) |
sw content controls, picture: add insert UI
- handle the picture case in SwWrtShell::InsertContentControl(): insert
a placeholder bitmap & create content control around the as-char image
- expose this as a new .uno:InsertPictureContentControl command
- add the new uno command to the default & MS-compatible menus
- rename the SwWrtShell::Insert() overload taking a Graphic to make this
a bit more readable
Change-Id: I289d6b6a9cd622c585b6cf0ec0c91d6b51ad81ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134681
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/uibase')
-rw-r--r-- | sw/qa/uibase/wrtsh/wrtsh.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index 297e7a2d1ebd..3fd708bf2a48 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -285,6 +285,28 @@ CPPUNIT_TEST_FIXTURE(Test, testReplacePictureContentControl) // killed the image selection. CPPUNIT_ASSERT(pWrtShell->IsFrameSelected()); } + +CPPUNIT_TEST_FIXTURE(Test, testInsertPictureContentControl) +{ + // Given an empty document: + SwDoc* pDoc = createSwDoc(); + + // When inserting a content control: + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->InsertContentControl(SwContentControlType::PICTURE); + + // Then make sure that the matching text attribute is added to the document model: + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode(); + SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); + auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr); + auto& rFormatContentControl + = static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr()); + std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl(); + // Without the accompanying fix in place, this test would have failed, there was no special + // handling for picture content control, no placeholder fly content was inserted. + CPPUNIT_ASSERT(pContentControl->GetPicture()); + CPPUNIT_ASSERT(pTextNode->GetTextAttrForCharAt(1, RES_TXTATR_FLYCNT)); +} } CPPUNIT_PLUGIN_IMPLEMENT(); |