sw/qa/extras/tiledrendering/tiledrendering.cxx | 20 ++++++++++++++++++++ sw/source/ui/frmdlg/frmpage.cxx | 8 ++++++++ sw/source/uibase/inc/basesh.hxx | 2 +- sw/source/uibase/shells/basesh.cxx | 10 ++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-)
New commits: commit 4154d281fbecaadf6cd118c00cc6cff929e339a4 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Jul 5 12:48:07 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Jul 5 16:11:20 2019 +0200 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 <vmik...@collabora.com> Tested-by: Jenkins 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 <vcl/vclevent.hxx> #include <vcl/bitmapaccess.hxx> #include <flddat.hxx> +#include <basesh.hxx> 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<int>(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<FN_TOOL_ANCHOR_PAGE, FN_TOOL_ANCHOR_PAGE>{}); + SfxBoolItem aItem(FN_TOOL_ANCHOR_PAGE); + aSet.Put(aItem); + auto pShell = dynamic_cast<SwBaseShell*>(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(); diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 7d99d3b0fcf9..d904ff0ec964 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -72,6 +72,7 @@ #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <vcl/graphicfilter.hxx> #include <svtools/embedhlp.hxx> +#include <comphelper/lok.hxx> #include <memory> using namespace ::com::sun::star; @@ -703,6 +704,13 @@ SwFramePage::SwFramePage(TabPageParent pParent, const SfxItemSet &rSet) m_xAutoWidthCB->connect_toggled(LINK(this, SwFramePage, AutoWidthClickHdl)); m_xAutoHeightCB->connect_toggled(LINK(this, SwFramePage, AutoHeightClickHdl)); + + if (comphelper::LibreOfficeKit::isActive()) + { + m_xAnchorAtPageRB->hide(); + m_xAnchorAtParaRB->hide(); + m_xAnchorAtFrameRB->hide(); + } } SwFramePage::~SwFramePage() diff --git a/sw/source/uibase/inc/basesh.hxx b/sw/source/uibase/inc/basesh.hxx index 17d0a8336601..41efce245c32 100644 --- a/sw/source/uibase/inc/basesh.hxx +++ b/sw/source/uibase/inc/basesh.hxx @@ -36,7 +36,7 @@ class SfxItemSet; class SwCursorShell; struct DBTextStruct_Impl; -class SAL_DLLPUBLIC_RTTI SwBaseShell: public SfxShell +class SW_DLLPUBLIC SwBaseShell: public SfxShell { SwView &rView; diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 58593a92ff69..0e95f814d29b 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -110,6 +110,7 @@ #include <svx/unobrushitemhelper.hxx> #include <comphelper/scopeguard.hxx> +#include <comphelper/lok.hxx> #include <SwStyleNameMapper.hxx> #include <poolfmt.hxx> @@ -1656,6 +1657,15 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) rSet.DisableItem(nWhich); else if(nWhich != SID_ANCHOR_MENU) rSet.Put(SfxBoolItem(nWhich, bSet)); + + if (comphelper::LibreOfficeKit::isActive()) + { + if (nWhich == FN_TOOL_ANCHOR_PAGE || nWhich == FN_TOOL_ANCHOR_PARAGRAPH + || nWhich == FN_TOOL_ANCHOR_FRAME) + { + rSet.DisableItem(nWhich); + } + } } else rSet.DisableItem( nWhich ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits