summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/strings.hrc2
-rw-r--r--include/sfx2/viewfrm.hxx1
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs6
-rw-r--r--sfx2/source/dialog/infobar.cxx2
-rw-r--r--sfx2/source/view/viewfrm.cxx109
-rw-r--r--sw/inc/strings.hrc4
-rw-r--r--sw/source/uibase/uiview/viewstat.cxx29
7 files changed, 111 insertions, 42 deletions
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 14e1066447ba..c5d3c003e313 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -292,6 +292,8 @@
#define STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK NC_("STR_SIGNATURE_NOTVALIDATED_PARTIAL_OK", "The certificate could not be validated and the document is only partially signed.")
#define STR_SIGNATURE_OK NC_("STR_SIGNATURE_OK", "This document is digitally signed and the signature is valid.")
#define STR_SIGNATURE_SHOW NC_("STR_SIGNATURE_SHOW", "Show Signatures")
+#define STR_TRACK_CHANGES_BUTTON NC_("STR_TRACK_CHANGES_BUTTON", "Show Toolbar")
+#define STR_TRACK_CHANGES_BUTTON_HIDE NC_("STR_TRACK_CHANGES_BUTTON_HIDE", "Hide Toolbar")
#define STR_CLOSE_PANE NC_("STR_CLOSE_PANE", "Close Pane")
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index 7692636fd24c..c01da176b847 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -67,6 +67,7 @@ protected:
DECL_LINK(WhatsNewHandler, weld::Button&, void);
DECL_LINK(SwitchReadOnlyHandler, weld::Button&, void);
DECL_LINK(SignDocumentHandler, weld::Button&, void);
+ DECL_LINK(HiddenTrackChangesHandler, weld::Button&, void);
SAL_DLLPRIVATE void KillDispatcher_Impl();
virtual ~SfxViewFrame() override;
diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs
index a7f996dc4ed8..6b29f0b47e6a 100644
--- a/officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/UI/Infobar.xcs
@@ -54,6 +54,12 @@
</info>
<value>true</value>
</prop>
+ <prop oor:name="HiddenTrackChanges" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Whether an Infobar is shown when hidden Track Changes settings or data are there in a document</desc>
+ </info>
+ <value>true</value>
+ </prop>
</group>
</component>
</oor:component-schema>
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() )
{
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index b4017a06cc80..bb1c568a09bb 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -404,6 +404,10 @@
#define STR_HYPH_TITLE NC_("STR_HYPH_TITLE", "Hyphenation")
#define STR_HYPH_MISSING NC_("STR_HYPH_MISSING", "Missing hyphenation data")
#define STR_HYPH_MISSING_DETAIL NC_("STR_HYPH_MISSING", "Please install the hyphenation package for locale “%1”.")
+#define STR_HIDDEN_CHANGES NC_("STR_HIDDEN_CHANGES", "Track Changes")
+#define STR_HIDDEN_CHANGES_DETAIL NC_("STR_HIDDEN_CHANGES_DETAIL", "Document contains tracked changes and recording is enabled.")
+#define STR_HIDDEN_CHANGES_DETAIL2 NC_("STR_HIDDEN_CHANGES_DETAIL2", "Recording of changes is enabled.")
+#define STR_HIDDEN_CHANGES_DETAIL3 NC_("STR_HIDDEN_CHANGES_DETAIL3", "Document contains tracked changes.")
// Undo
#define STR_CANT_UNDO NC_("STR_CANT_UNDO", "not possible")
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index 30c18bdc0180..06b740042bb0 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -49,6 +49,9 @@
#include <redline.hxx>
#include <rootfrm.hxx>
#include <docary.hxx>
+#include <sfx2/infobar.hxx>
+#include <docsh.hxx>
+#include <strings.hrc>
#include <cmdid.h>
#include <IDocumentRedlineAccess.hxx>
@@ -324,13 +327,27 @@ void SwView::GetState(SfxItemSet &rSet)
break;
case FN_REDLINE_ON:
rSet.Put( SfxBoolItem( nWhich, GetDocShell()->IsChangeRecording() ) );
- // switch on the disabled Tracked Changes toolbar if the view is
- // new (e.g. on load), and if recording of changes is enabled
- // or if it contains tracked changes.
- if ( m_bForceChangesToolbar && ( GetDocShell()->IsChangeRecording() ||
- m_pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable().size() ) )
+ // When the view is new (e.g. on load), show the Hidden Track Changes infobar
+ // if Show Changes is disabled, but recording of changes is enabled
+ // or hidden tracked changes are there already in the document.
+ // Note: the infobar won't be shown, if the Track Changes toolbar is already
+ // enabled, see in sfx2.
+ if ( m_bForceChangesToolbar && m_pWrtShell->GetLayout()->IsHideRedlines() )
{
- ShowUIElement("private:resource/toolbar/changes");
+ bool isRecording = GetDocShell()->IsChangeRecording();
+ bool hasRecorded =
+ m_pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable().size();
+ if ( isRecording || hasRecorded )
+ {
+ GetDocShell()->AppendInfoBarWhenReady(
+ "hiddentrackchanges", SwResId(STR_HIDDEN_CHANGES),
+ SwResId( (isRecording && hasRecorded)
+ ? STR_HIDDEN_CHANGES_DETAIL
+ : isRecording
+ ? STR_HIDDEN_CHANGES_DETAIL2
+ : STR_HIDDEN_CHANGES_DETAIL3 ),
+ InfobarType::INFO);
+ }
}
m_bForceChangesToolbar = false;
break;