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 d309bb98618391c78a73177c5af16e23a2631cb4 Author: Miklos Vajna <[email protected]> AuthorDate: Fri Jul 5 12:48:07 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Jul 8 13:46:04 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) Conflicts: sw/source/ui/frmdlg/frmpage.cxx Change-Id: I6b9205ef3df8a7bc15fbcf787d134743c09e98da Reviewed-on: https://gerrit.libreoffice.org/75196 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 93ff00e5eb84..9b2984b7af9f 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -43,6 +43,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/"; @@ -113,6 +114,7 @@ public: void testVisCursorInvalidation(); void testDeselectCustomShape(); void testSemiTransparent(); + void testAnchorTypes(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -170,6 +172,7 @@ public: CPPUNIT_TEST(testVisCursorInvalidation); CPPUNIT_TEST(testDeselectCustomShape); CPPUNIT_TEST(testSemiTransparent); + CPPUNIT_TEST(testAnchorTypes); CPPUNIT_TEST_SUITE_END(); private: @@ -2438,6 +2441,23 @@ void SwTiledRenderingTest::testSemiTransparent() CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetBlue())); } +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 a69f8c59d6d8..815bf8b21d59 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -69,6 +69,7 @@ #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <vcl/graphicfilter.hxx> #include <vcl/builderfactory.hxx> +#include <comphelper/lok.hxx> #include <memory> using namespace ::com::sun::star; @@ -718,6 +719,13 @@ SwFramePage::SwFramePage(vcl::Window *pParent, const SfxItemSet &rSet) m_pAutoWidthCB->SetClickHdl( LINK( this, SwFramePage, AutoWidthClickHdl ) ); m_pAutoHeightCB->SetClickHdl( LINK( this, SwFramePage, AutoHeightClickHdl ) ); + + if (comphelper::LibreOfficeKit::isActive()) + { + m_pAnchorAtPageRB->Hide(); + m_pAnchorAtParaRB->Hide(); + m_pAnchorAtFrameRB->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 3d418e58070b..f3820f141fa9 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -108,6 +108,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 != FN_TOOL_ANCHOR) 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 [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
