diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/crsr/crsr.cxx | 19 | ||||
-rw-r--r-- | sw/source/core/crsr/pam.cxx | 11 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh3.cxx | 2 |
3 files changed, 31 insertions, 1 deletions
diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx index 759b236d16ac..243abd0e20d1 100644 --- a/sw/qa/core/crsr/crsr.cxx +++ b/sw/qa/core/crsr/crsr.cxx @@ -19,11 +19,13 @@ #include <comphelper/propertysequence.hxx> #include <svl/srchitem.hxx> #include <vcl/scheduler.hxx> +#include <comphelper/propertyvalue.hxx> #include <docsh.hxx> #include <unotxdoc.hxx> #include <wrtsh.hxx> #include <ndtxt.hxx> +#include <formatcontentcontrol.hxx> constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/crsr/data/"; @@ -183,6 +185,23 @@ CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testTdf135451) CPPUNIT_ASSERT_EQUAL(OUString("a"), pWrtShell->GetSelText()); } +CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testDropdownContentControl) +{ + // Given a document with a dropdown content control: + SwDoc* pDoc = createSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->InsertContentControl(SwContentControlType::DROP_DOWN_LIST); + + // When entering the content control: + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); + + // Then make sure that the cursor is read-only: + // Without the accompanying fix in place, this test would have failed, it was possible to type + // into the drop-down content control, providing content that is not one of the list items. + CPPUNIT_ASSERT(pWrtShell->HasReadonlySel()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 5f8f3ec86eb6..2b4e8cc0bf9c 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -957,7 +957,16 @@ bool SwPaM::HasReadonlySel(bool bFormView, bool const isReplace) const = rFormatContentControl.GetContentControl(); if (pContentControl && !pContentControl->GetReadWrite()) { - bRet = pContentControl->GetCheckbox() || pContentControl->GetPicture(); + switch (pContentControl->GetType()) + { + case SwContentControlType::CHECKBOX: + case SwContentControlType::PICTURE: + case SwContentControlType::DROP_DOWN_LIST: + bRet = true; + break; + default: + break; + } } } } diff --git a/sw/source/uibase/wrtsh/wrtsh3.cxx b/sw/source/uibase/wrtsh/wrtsh3.cxx index 27ca0353bac1..58204886933e 100644 --- a/sw/source/uibase/wrtsh/wrtsh3.cxx +++ b/sw/source/uibase/wrtsh/wrtsh3.cxx @@ -172,9 +172,11 @@ bool SwWrtShell::GotoContentControl(const SwFormatContentControl& rContentContro GetIDocumentUndoRedo().StartUndo(SwUndoId::REPLACE, &aRewriter); // Update the content. + pContentControl->SetReadWrite(true); DelLeft(); pContentControl->SetSelectedListItem(std::nullopt); Insert(aNewState); + pContentControl->SetReadWrite(false); GetIDocumentUndoRedo().EndUndo(SwUndoId::REPLACE, &aRewriter); LockView(/*bViewLocked=*/false); |