summaryrefslogtreecommitdiff
path: root/sw/qa/extras/tiledrendering/tiledrendering.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/extras/tiledrendering/tiledrendering.cxx')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 2f52c97efec1..d5d638e9b4ca 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -14,6 +14,7 @@
#include <com/sun/star/frame/XDispatchResultListener.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <swmodeltestbase.hxx>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <test/helper/transferable.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/dispatchcommand.hxx>
@@ -132,6 +133,7 @@ public:
void testDropDownFormFieldButtonNoItem();
void testSpellOnlineRenderParameter();
void testTablePaintInvalidate();
+ void testExtTextInputReadOnly();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -202,6 +204,7 @@ public:
CPPUNIT_TEST(testDropDownFormFieldButtonNoItem);
CPPUNIT_TEST(testSpellOnlineRenderParameter);
CPPUNIT_TEST(testTablePaintInvalidate);
+ CPPUNIT_TEST(testExtTextInputReadOnly);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2793,6 +2796,36 @@ void SwTiledRenderingTest::testTablePaintInvalidate()
CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations);
}
+void SwTiledRenderingTest::testExtTextInputReadOnly()
+{
+ // Create a document with a protected section + a normal paragraph after it.
+ SwXTextDocument* pXTextDocument = createDoc();
+ uno::Reference<text::XTextViewCursorSupplier> xController(
+ pXTextDocument->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursor> xCursor = xController->getViewCursor();
+ uno::Reference<text::XText> xText = xCursor->getText();
+ uno::Reference<text::XTextContent> xSection(
+ pXTextDocument->createInstance("com.sun.star.text.TextSection"), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xSectionProps(xSection, uno::UNO_QUERY);
+ xSectionProps->setPropertyValue("IsProtected", uno::Any(true));
+ xText->insertTextContent(xCursor, xSection, /*bAbsorb=*/true);
+
+ // First paragraph is the protected section, is it empty?
+ VclPtr<vcl::Window> pEditWin = pXTextDocument->getDocWindow();
+ CPPUNIT_ASSERT(pEditWin);
+ CPPUNIT_ASSERT(getParagraph(1)->getString().isEmpty());
+
+ // Try to type into the protected section, is it still empty?
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ SfxLokHelper::postExtTextEventAsync(pEditWin, LOK_EXT_TEXTINPUT, "x");
+ SfxLokHelper::postExtTextEventAsync(pEditWin, LOK_EXT_TEXTINPUT_END, "x");
+ Scheduler::ProcessEventsToIdle();
+ // Without the accompanying fix in place, this test would have failed, as it was possible to
+ // type into the protected section.
+ CPPUNIT_ASSERT(getParagraph(1)->getString().isEmpty());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();