From 4154d281fbecaadf6cd118c00cc6cff929e339a4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 5 Jul 2019 12:48:07 +0200 Subject: sw lok: hide UI to set Word-incompatible anchor types Let's make it a bit harder for users to hurt themselves, at least in Online. Affects the context/popup menu and the dialog of frames. This is similar to how certain border types are hidden on the UI, depending on if MSO supports them. Though that goes a bit further and disables those types even on the desktop. Change-Id: I6b9205ef3df8a7bc15fbcf787d134743c09e98da Reviewed-on: https://gerrit.libreoffice.org/75129 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/qa/extras/tiledrendering/tiledrendering.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sw/qa') diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 965a64fa5191..c06f150ccf32 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -45,6 +45,7 @@ #include #include #include +#include static char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/"; @@ -116,6 +117,7 @@ public: void testVisCursorInvalidation(); void testDeselectCustomShape(); void testSemiTransparent(); + void testAnchorTypes(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -174,6 +176,7 @@ public: CPPUNIT_TEST(testVisCursorInvalidation); CPPUNIT_TEST(testDeselectCustomShape); CPPUNIT_TEST(testSemiTransparent); + CPPUNIT_TEST(testAnchorTypes); CPPUNIT_TEST_SUITE_END(); private: @@ -2484,6 +2487,23 @@ void SwTiledRenderingTest::testSemiTransparent() CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast(aColor.B)); } +void SwTiledRenderingTest::testAnchorTypes() +{ + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + SwView* pView = pXTextDocument->GetDocShell()->GetView(); + pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + SfxItemSet aSet(pDoc->GetAttrPool(), svl::Items{}); + SfxBoolItem aItem(FN_TOOL_ANCHOR_PAGE); + aSet.Put(aItem); + auto pShell = dynamic_cast(pView->GetCurShell()); + pShell->GetState(aSet); + // Without the accompanying fix in place, this test would have failed, setting the anchor type + // to other than as/at-char was possible. + CPPUNIT_ASSERT(!aSet.HasItem(FN_TOOL_ANCHOR_PAGE)); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit