diff options
author | László Németh <nemeth@numbertext.org> | 2021-04-08 10:20:02 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-04-12 10:44:49 +0200 |
commit | d89786054715b44aa983d0752484216825c74ae2 (patch) | |
tree | 55e4a6e4c771eae960af6754a27eac003d3fc3be /sfx2 | |
parent | 02529315289b8a5ef546e5df33283a424d68d8fd (diff) |
tdf#125909 tdf#141298 sw: show (Hidden) Track Changes infobar
instead of enabling Track Changes toolbar automatically,
when there are hidden track changes data or settings in
the document, i.e. Track Changes toolbar and Show Changes
are disabled, but
– the document contains (not visible) recorded changes, or
– Record Track Changes is enabled (which will result hidden
recording, e.g. unintended publishing of the deletions of
the document); or
– both of them.
Messages of the infobar show these cases.
Button of the Track Changes infobar allows to show/hide the
Track Changes toolbar. Hiding the Track Changes toolbar with
button of the Track Changes infobar closes the infobar, too.
Regression from commit afbbfb3b55beb937555a972d9edbb47ede91001a
"tdf#83958: sw: enable Track Changes toolbar automatically" and
commit 1989201c56c03b1ef13a282cfd09af69620040ea
"tdf#138870 sw: fix Track Changes toolbar reappearing".
Change-Id: I9162102d63d671b412fa0228e6bbfb5c356ee03e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113792
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 109 |
2 files changed, 75 insertions, 36 deletions
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 4844e8eb88df..3af15ee3f62c 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -434,6 +434,8 @@ bool SfxInfoBarContainerWindow::isInfobarEnabled(std::u16string_view sId) return officecfg::Office::UI::Infobar::Enabled::HyphenationMissing::get(); if (sId == u"whatsnew") return officecfg::Office::UI::Infobar::Enabled::WhatsNew::get(); + if (sId == u"hiddentrackchanges") + return officecfg::Office::UI::Infobar::Enabled::HiddenTrackChanges::get(); return true; } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 596d8ab3d9fb..09c54757986d 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -133,6 +133,8 @@ using ::com::sun::star::container::XIndexContainer; #define ShellClass_SfxViewFrame #include <sfxslots.hxx> +#define CHANGES_STR "private:resource/toolbar/changes" + SFX_IMPL_SUPERCLASS_INTERFACE(SfxViewFrame,SfxShell) void SfxViewFrame::InitInterface_Impl() @@ -1280,6 +1282,28 @@ void SfxViewFrame::AppendReadOnlyInfobar() } } +namespace +{ +css::uno::Reference<css::frame::XLayoutManager> getLayoutManager(const SfxFrame& rFrame) +{ + css::uno::Reference<css::frame::XLayoutManager> xLayoutManager; + css::uno::Reference<css::beans::XPropertySet> xPropSet(rFrame.GetFrameInterface(), + uno::UNO_QUERY); + if (xPropSet.is()) + { + try + { + xLayoutManager.set(xPropSet->getPropertyValue("LayoutManager"), uno::UNO_QUERY); + } + catch (const Exception& e) + { + SAL_WARN("sfx.view", "Failure getting layout manager: " + e.Message); + } + } + return xLayoutManager; +} +} + void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { if(m_pImpl->bIsDowning) @@ -1437,9 +1461,34 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) while (!aPendingInfobars.empty()) { InfobarData& aInfobarData = aPendingInfobars.back(); - AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage, + + // don't show Track Changes infobar, if Track Changes toolbar is visible + if (aInfobarData.msId == "hiddentrackchanges") + { + if (auto xLayoutManager = getLayoutManager(GetFrame())) + { + if ( xLayoutManager->getElement(CHANGES_STR).is() ) + { + aPendingInfobars.pop_back(); + continue; + } + } + } + + VclPtr<SfxInfoBarWindow> pInfoBar = + AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage, aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType, aInfobarData.mbShowCloseButton); + + // Track Changes infobar: add a button to show/hide Track Changes functions + if ( pInfoBar && aInfobarData.msId == "hiddentrackchanges" ) + { + weld::Button& rTrackChangesButton = pInfoBar->addButton(); + rTrackChangesButton.set_label(SfxResId(STR_TRACK_CHANGES_BUTTON)); + rTrackChangesButton.connect_clicked(LINK(this, + SfxViewFrame, HiddenTrackChangesHandler)); + } + aPendingInfobars.pop_back(); } @@ -1559,6 +1608,27 @@ IMPL_LINK_NOARG(SfxViewFrame, SignDocumentHandler, weld::Button&, void) GetDispatcher()->Execute(SID_SIGNATURE); } +IMPL_LINK(SfxViewFrame, HiddenTrackChangesHandler, weld::Button&, rButton, void) +{ + // enable Track Changes toolbar, if it is disabled. + // Otherwise disable the toolbar, and close the infobar + if (auto xLayoutManager = getLayoutManager(GetFrame())) + { + if (!xLayoutManager->getElement(CHANGES_STR).is()) + { + xLayoutManager->createElement(CHANGES_STR); + xLayoutManager->showElement(CHANGES_STR); + rButton.set_label(SfxResId(STR_TRACK_CHANGES_BUTTON_HIDE)); + } + else + { + xLayoutManager->hideElement(CHANGES_STR); + xLayoutManager->destroyElement(CHANGES_STR); + RemoveInfoBar(u"hiddentrackchanges"); + } + } +} + void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh ) { m_pImpl->bResizeInToOut = true; @@ -2876,24 +2946,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) case SID_TOGGLESTATUSBAR: { - css::uno::Reference< css::frame::XFrame > xFrame = - GetFrame().GetFrameInterface(); - - Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); - Reference< css::frame::XLayoutManager > xLayoutManager; - if ( xPropSet.is() ) - { - try - { - Any aValue = xPropSet->getPropertyValue("LayoutManager"); - aValue >>= xLayoutManager; - } - catch ( Exception& ) - { - } - } - - if ( xLayoutManager.is() ) + if ( auto xLayoutManager = getLayoutManager(GetFrame()) ) { static const OUStringLiteral aStatusbarResString( u"private:resource/statusbar/statusbar" ); // Evaluate parameter. @@ -2929,23 +2982,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) WorkWindow* pWork = static_cast<WorkWindow*>( pTop->GetFrame().GetTopWindow_Impl() ); if ( pWork ) { - css::uno::Reference< css::frame::XFrame > xFrame = - GetFrame().GetFrameInterface(); - - Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); - Reference< css::frame::XLayoutManager > xLayoutManager; - if ( xPropSet.is() ) - { - try - { - Any aValue = xPropSet->getPropertyValue("LayoutManager"); - aValue >>= xLayoutManager; - } - catch ( Exception& ) - { - } - } - + Reference< css::frame::XLayoutManager > xLayoutManager = getLayoutManager(GetFrame()); bool bNewFullScreenMode = pItem ? pItem->GetValue() : !pWork->IsFullScreenMode(); if ( bNewFullScreenMode != pWork->IsFullScreenMode() ) { |