diff options
author | Tibor Nagy <tibor.nagy.extern@allotropia.de> | 2025-01-29 11:46:56 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2025-01-31 13:38:39 +0100 |
commit | 5f81c84e9b5d4bc9eb5ba05aa1aad5eeaa4eb89a (patch) | |
tree | 69b92f8a3f7a38667ab541102a581c0f98f8255a /sw/qa/uibase/uiview/uiview.cxx | |
parent | d2280c07bfc0887d8784aff04ac5ea20981b17b8 (diff) |
tdf#146549 sw: Make the formatting toolbar visible
when moving the cursor to an editable section in read-only mode.
Change-Id: I7ed5837eb627a3db00b1b64516b790cc7a3aea01
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180890
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw/qa/uibase/uiview/uiview.cxx')
-rw-r--r-- | sw/qa/uibase/uiview/uiview.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx index 5f41aa920c02..3733fcd5dc68 100644 --- a/sw/qa/uibase/uiview/uiview.cxx +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -17,6 +17,7 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/dispatch.hxx> +#include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/frame/XDispatchHelper.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> @@ -354,6 +355,54 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testEditInReadonly) //status default in editable section CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, eState); } + +CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testShowTextobjectbarInReadonly) +{ + createSwDoc("tdf146549.odt"); + + SwDocShell* pDocShell = getSwDocShell(); + SwView* pView = pDocShell->GetView(); + + pView->GetViewFrame().GetDispatcher()->Execute(SID_EDITDOC, SfxCallMode::SYNCHRON); + + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XParagraphCursor> xParaCursor(xTextDocument->getText()->createTextCursor(), + uno::UNO_QUERY); + + uno::Reference<view::XSelectionSupplier> xSelSupplier(xModel->getCurrentController(), + uno::UNO_QUERY_THROW); + + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + SfxViewFrame& rViewFrame = pWrtShell->GetView().GetViewFrame(); + uno::Reference<com::sun::star::frame::XLayoutManager> xLayoutManager; + uno::Reference<beans::XPropertySet> xPropSet(rViewFrame.GetFrame().GetFrameInterface(), + uno::UNO_QUERY); + xLayoutManager.set(xPropSet->getPropertyValue(u"LayoutManager"_ustr), uno::UNO_QUERY); + + // move the cursor to the non-editable section + xSelSupplier->select(css::uno::Any(xParaCursor)); + + bool bShow; + bShow = xLayoutManager->isElementVisible(u"private:resource/toolbar/drawtextobjectbar"_ustr); + CPPUNIT_ASSERT_EQUAL(false, bShow); // the formatting toolbar should be hidden + + // move the cursor to the editable section + xParaCursor->gotoNextParagraph(false); + xSelSupplier->select(css::uno::Any(xParaCursor)); + + bShow = xLayoutManager->isElementVisible(u"private:resource/toolbar/drawtextobjectbar"_ustr); + CPPUNIT_ASSERT_EQUAL(true, bShow); // the formatting toolbar should be shown + + // move the cursor to the non-editable section + xParaCursor->gotoPreviousParagraph(false); + xSelSupplier->select(css::uno::Any(xParaCursor)); + + bShow = xLayoutManager->isElementVisible(u"private:resource/toolbar/drawtextobjectbar"_ustr); + CPPUNIT_ASSERT_EQUAL(false, bShow); // the formatting toolbar should be hidden +} CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |