summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2020-04-28 15:51:02 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2020-05-08 14:06:04 +0200
commit7aedeab27cbef89fd3f831b4a1ef2c06f24c9790 (patch)
treeee7565d4839e9e7c89ea13fe70d997c847ac626a /sw/qa
parent6751a89552f6d739b4e1563143fd3a019478f513 (diff)
lok: MSForms: Add callback for form field button.
Show and hide the button and send the button area, where it should be displayed. Change-Id: I5922eb9f5e544483dd4efd12e4218d2e51270632 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93657 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/tiledrendering/data/drop_down_form_field.odtbin0 -> 8596 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx81
2 files changed, 81 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/data/drop_down_form_field.odt b/sw/qa/extras/tiledrendering/data/drop_down_form_field.odt
new file mode 100644
index 000000000000..7793aff4e91b
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/drop_down_form_field.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 355ae56cc29f..efe714d74388 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -128,6 +128,7 @@ public:
void testRedlineNotificationDuringSave();
void testHyperlink();
void testFieldmark();
+ void testDropDownFormFieldButton();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -194,6 +195,7 @@ public:
CPPUNIT_TEST(testRedlineNotificationDuringSave);
CPPUNIT_TEST(testHyperlink);
CPPUNIT_TEST(testFieldmark);
+ CPPUNIT_TEST(testDropDownFormFieldButton);
CPPUNIT_TEST_SUITE_END();
private:
@@ -214,6 +216,7 @@ private:
int m_nTrackedChangeIndex;
OString m_sHyperlinkText;
OString m_sHyperlinkLink;
+ OString m_aFormFieldButton;
};
SwTiledRenderingTest::SwTiledRenderingTest()
@@ -365,6 +368,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
}
}
break;
+ case LOK_CALLBACK_FORM_FIELD_BUTTON:
+ {
+ m_aFormFieldButton = OString(pPayload);
+ }
+ break;
}
}
@@ -2537,6 +2545,79 @@ void SwTiledRenderingTest::testFieldmark()
createDoc("fieldmark.docx");
}
+void SwTiledRenderingTest::testDropDownFormFieldButton()
+{
+ SwXTextDocument* pXTextDocument = createDoc("drop_down_form_field.odt");
+ pXTextDocument->setClientVisibleArea(tools::Rectangle(0, 0, 10000, 4000));
+
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this);
+
+ // Move the cursor to trigger displaying of the field button.
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+
+ CPPUNIT_ASSERT(!m_aFormFieldButton.isEmpty());
+
+ // First we have a button with an empty text area.
+ {
+ std::stringstream aStream(m_aFormFieldButton.getStr());
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+
+ OString sAction = aTree.get_child("action").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("show"), sAction);
+
+ OString sType = aTree.get_child("type").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("drop-down"), sType);
+
+ OString sTextArea = aTree.get_child("textArea").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("0, 0, -1, -1"), sTextArea);
+ }
+
+ // Do a tile rendering to trigger the button message with a valide text area
+ size_t nCanvasWidth = 1024;
+ size_t nCanvasHeight = 512;
+ std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0);
+ ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
+ pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+ pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight),
+ Fraction(1.0), Point(), aPixmap.data());
+ pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0,
+ /*nTilePosY=*/0, /*nTileWidth=*/10000, /*nTileHeight=*/4000);
+
+ CPPUNIT_ASSERT(!m_aFormFieldButton.isEmpty());
+ {
+ std::stringstream aStream(m_aFormFieldButton.getStr());
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+
+ OString sAction = aTree.get_child("action").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("show"), sAction);
+
+ OString sType = aTree.get_child("type").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("drop-down"), sType);
+
+ OString sTextArea = aTree.get_child("textArea").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("1538, 1418, 1026, 275"), sTextArea);
+ }
+
+ // Move the cursor back so the button becomes hidden.
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+
+ CPPUNIT_ASSERT(!m_aFormFieldButton.isEmpty());
+ {
+ std::stringstream aStream(m_aFormFieldButton.getStr());
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+
+ OString sAction = aTree.get_child("action").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("hide"), sAction);
+
+ OString sType = aTree.get_child("type").get_value<std::string>().c_str();
+ CPPUNIT_ASSERT_EQUAL(OString("drop-down"), sType);
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();