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 <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna
2019-07-05 16:11:20 +02:00
parent e553b3698f
commit 4154d281fb
4 changed files with 39 additions and 1 deletions
@@ -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();
+8
View File
@@ -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()
+1 -1
View File
@@ -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;
+10
View File
@@ -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 );