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 c393afd00abcff65ce091baff83541e8a65348d9 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Jul 5 12:48:07 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 8 10:01:34 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. (cherry picked from commit 4154d281fbecaadf6cd118c00cc6cff929e339a4) Change-Id: I6b9205ef3df8a7bc15fbcf787d134743c09e98da diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index ef15c30f8e79..bd7d3c6b0b87 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -42,6 +42,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/"; @@ -110,6 +111,7 @@ public: void testDeleteNodeRedlineCallback(); void testVisCursorInvalidation(); void testSemiTransparent(); + void testAnchorTypes(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -166,6 +168,7 @@ public: CPPUNIT_TEST(testDeleteNodeRedlineCallback); CPPUNIT_TEST(testVisCursorInvalidation); CPPUNIT_TEST(testSemiTransparent); + CPPUNIT_TEST(testAnchorTypes); CPPUNIT_TEST_SUITE_END(); private: @@ -2409,6 +2412,23 @@ void SwTiledRenderingTest::testSemiTransparent() comphelper::LibreOfficeKit::setActive(false); } +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 163c8a80b582..e3451afbbef3 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -71,6 +71,7 @@ #include <vcl/graphicfilter.hxx> #include <vcl/builderfactory.hxx> #include <svtools/embedhlp.hxx> +#include <comphelper/lok.hxx> #include <memory> using namespace ::com::sun::star; @@ -702,6 +703,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 1b885e9a635f..eb1fa1a53c83 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -107,6 +107,7 @@ #include <svx/unobrushitemhelper.hxx> #include <comphelper/scopeguard.hxx> +#include <comphelper/lok.hxx> #include <SwStyleNameMapper.hxx> #include <poolfmt.hxx> @@ -1650,6 +1651,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