diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-23 15:24:38 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-23 16:09:02 +0100 |
commit | 12ef6bd2a37e2a3e27123c0f796b0e7f4e14f051 (patch) | |
tree | fa314b85cc530a303fb197af796655e85e00d3ab | |
parent | aad8e562765b2981e76a008e3eca04058279469f (diff) |
sfx2 classification: update infobar after setting category name
So one doesn't need to reload the document to see an up to date infobar.
Change-Id: I42b0b8c2d7e4953157d73f06b724ba23f6b79cab
-rw-r--r-- | include/sfx2/classificationhelper.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/classificationhelper.cxx | 26 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 11 |
3 files changed, 29 insertions, 10 deletions
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx index 1a19ee92583a..c8892dc1a955 100644 --- a/include/sfx2/classificationhelper.hxx +++ b/include/sfx2/classificationhelper.hxx @@ -16,6 +16,7 @@ #include <sfx2/dllapi.h> class SfxObjectShell; +class SfxViewFrame; namespace basegfx { class BColor; @@ -40,6 +41,7 @@ public: bool HasImpactLevel(); basegfx::BColor GetImpactLevelColor(); OUString GetDocumentWatermark(); + void UpdateInfobar(SfxViewFrame& rViewFrame); }; #endif diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx index 19325859a0a8..ec9ea45ec6eb 100644 --- a/sfx2/source/view/classificationhelper.cxx +++ b/sfx2/source/view/classificationhelper.cxx @@ -25,6 +25,9 @@ #include <unotools/ucbstreamhelper.hxx> #include <unotools/streamwrap.hxx> #include <cppuhelper/implbase.hxx> +#include <sfx2/sfx.hrc> +#include <sfx2/sfxresid.hxx> +#include <sfx2/viewfrm.hxx> #include <config_folders.h> using namespace com::sun::star; @@ -286,6 +289,8 @@ public: void parsePolicy(); /// Synchronize m_aLabels back to the object shell. void pushToObjectShell(); + /// Updates infobar if necessary for an already loaded document. + void updateViewFrame(); }; SfxClassificationHelper::Impl::Impl(SfxObjectShell& rObjectShell) @@ -486,6 +491,27 @@ void SfxClassificationHelper::SetBACName(const OUString& rName) m_pImpl->m_aLabels = it->second.m_aLabels; m_pImpl->pushToObjectShell(); + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + if (!pViewFrame) + return; + + UpdateInfobar(*pViewFrame); +} + +void SfxClassificationHelper::UpdateInfobar(SfxViewFrame& rViewFrame) +{ + OUString aBACName = GetBACName(); + bool bImpactLevel = HasImpactLevel(); + if (!aBACName.isEmpty() && bImpactLevel) + { + OUString aMessage = SfxResId(STR_CLASSIFIED_DOCUMENT); + aMessage = aMessage.replaceFirst("%1", aBACName); + basegfx::BColor aBackgroundColor = GetImpactLevelColor(); + basegfx::BColor aForegroundColor(1.0, 1.0, 1.0); + + rViewFrame.RemoveInfoBar("classification"); + rViewFrame.AppendInfoBar("classification", aMessage, &aBackgroundColor, &aForegroundColor, &aForegroundColor, WB_CENTER); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index f7315c7428a4..0f49b8cc9628 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1348,16 +1348,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { // Document has BAILS properties, display an infobar accordingly. SfxClassificationHelper aHelper(*xObjSh.get()); - OUString aBACName = aHelper.GetBACName(); - bool bImpactLevel = aHelper.HasImpactLevel(); - if (!aBACName.isEmpty() && bImpactLevel) - { - OUString aMessage = SfxResId(STR_CLASSIFIED_DOCUMENT); - aMessage = aMessage.replaceFirst("%1", aBACName); - basegfx::BColor aBackgroundColor = aHelper.GetImpactLevelColor(); - basegfx::BColor aForegroundColor(1.0, 1.0, 1.0); - AppendInfoBar("classification", aMessage, &aBackgroundColor, &aForegroundColor, &aForegroundColor, WB_CENTER); - } + aHelper.UpdateInfobar(*this); } break; |