summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-18 09:08:03 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-11-22 14:29:04 +0100
commitfa070a798536d4017baada1e8f036b0e18dad9c7 (patch)
tree3e34754fb883a8d46cc8e42e8c0f494f5a26f977 /include
parent54239c99b7f9d82ec14492aff29e450abdafc61d (diff)
tdf#97926 Add UNO API for Infobar
This allows creating, updating and removing infobars from macros/extensions. It also extends the infobar with a primary and a secondary text, so there can be a bold summary at the beginning at the infobar with a longer text following in normal letters. Macro sample: ------------------------------------------------------------ Sub AddInfobar dim buttons(1) as new com.sun.star.beans.StringPair buttons(0).first = "Close doc" buttons(0).second = ".uno:CloseDoc" buttons(1).first = "Paste into doc" buttons(1).second = ".uno:Paste" ThisComponent.getCurrentController().appendInfobar("my", "Hello world", "Things happened. What now?", com.sun.star.frame.InfobarType.INFO, buttons, true) End Sub Sub UpdateInfobar ThisComponent.getCurrentController().updateInfobar("my", "WARNING","Do not read this message.", com.sun.star.frame.InfobarType.WARNING) End Sub Sub RemoveInfobar ThisComponent.getCurrentController().removeInfobar("my") End Sub ------------------------------------------------------------ Change-Id: I5d0a223525845d23ffab17acdaa431e0eb783fec Reviewed-on: https://gerrit.libreoffice.org/29816 Reviewed-by: Serge Krot (CIB) <Serge.Krot@cib.de> Tested-by: Serge Krot (CIB) <Serge.Krot@cib.de> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit 9e3ba7c3036c4d21e01d6f75ed29a1e8c4208141) Reviewed-on: https://gerrit.libreoffice.org/83405 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'include')
-rw-r--r--include/sfx2/classificationhelper.hxx2
-rw-r--r--include/sfx2/infobar.hxx38
-rw-r--r--include/sfx2/sfxbasecontroller.hxx13
-rw-r--r--include/sfx2/viewfrm.hxx13
4 files changed, 44 insertions, 22 deletions
diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index b372c8df20fd..ed55fe9c04ca 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -73,7 +73,7 @@ public:
OUString GetHigherClass(const OUString& first, const OUString& second);
/// If GetImpactScale() and GetImpactLevel*() will return something meaningful.
bool HasImpactLevel();
- InfoBarType GetImpactLevelType();
+ InfobarType GetImpactLevelType();
/// Larger value means more confidential.
sal_Int32 GetImpactLevel();
/// Comparing the GetImpactLevel() result is only meaningful when the impact scale is the same.
diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 4543189c0373..a0dcdbd00f1d 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -18,11 +18,12 @@
#include <sfx2/dllapi.h>
#include <sfx2/childwin.hxx>
-enum class InfoBarType {
- Info,
- Success,
- Warning,
- Danger
+// These must match the values in offapi/com/sun/star/frame/InfobarType.idl
+enum class InfobarType {
+ INFO = 0,
+ SUCCESS = 1,
+ WARNING = 2,
+ DANGER = 3
};
/** SfxChildWindow for positioning the InfoBar in the view.
@@ -50,27 +51,30 @@ class SFX2_DLLPUBLIC SfxInfoBarWindow final : public vcl::Window
{
private:
OUString const m_sId;
- InfoBarType m_eType;
+ InfobarType m_eType;
VclPtr<FixedImage> m_pImage;
- VclPtr<FixedText> m_pMessage;
+ VclPtr<FixedText> m_pPrimaryMessage;
+ VclPtr<FixedText> m_pSecondaryMessage;
VclPtr<Button> m_pCloseBtn;
std::vector< VclPtr<PushButton> > m_aActionBtns;
- void SetForeAndBackgroundColors( InfoBarType eType );
+ void SetForeAndBackgroundColors( InfobarType eType );
public:
SfxInfoBarWindow( vcl::Window* parent, const OUString& sId,
- const OUString& sMessage,
- InfoBarType infoBarType,
- WinBits nMessageStyle);
+ const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage,
+ InfobarType InfobarType,
+ bool bShowCloseButton, WinBits nMessageStyle);
virtual ~SfxInfoBarWindow( ) override;
virtual void dispose() override;
const OUString& getId() const { return m_sId; }
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
virtual void Resize( ) override;
- void Update( const OUString& sNewMessage, InfoBarType eType );
- basegfx::BColor m_aBackgroundColor;
+ void Update(const OUString& sPrimaryMessage, const OUString& sSecondaryMessage,
+ InfobarType eType);
+ basegfx::BColor m_aBackgroundColor;
basegfx::BColor m_aForegroundColor;
/** Add button to Infobar.
@@ -95,9 +99,11 @@ class SfxInfoBarContainerWindow final : public vcl::Window
virtual void dispose() override;
VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId,
- const OUString& sMessage,
- InfoBarType ibType,
- WinBits nMessageStyle);
+ const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage,
+ InfobarType ibType,
+ WinBits nMessageStyle,
+ bool bShowCloseButton);
VclPtr<SfxInfoBarWindow> getInfoBar(const OUString& sId);
bool hasInfoBarWithID(const OUString& sId);
void removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar);
diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx
index 4b7237fd4386..95a082cdae32 100644
--- a/include/sfx2/sfxbasecontroller.hxx
+++ b/include/sfx2/sfxbasecontroller.hxx
@@ -28,6 +28,7 @@
#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
#include <com/sun/star/frame/XController2.hpp>
#include <com/sun/star/frame/XControllerBorder.hpp>
+#include <com/sun/star/frame/XInfobarProvider.hpp>
#include <com/sun/star/frame/XTitle.hpp>
#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -70,6 +71,7 @@ typedef ::cppu::WeakImplHelper < css::frame::XController2
, css::ui::XContextMenuInterception
, css::awt::XUserInputInterception
, css::frame::XDispatchInformationProvider
+ , css::frame::XInfobarProvider
, css::frame::XTitle
, css::frame::XTitleChangeBroadcaster
, css::lang::XInitialization
@@ -175,6 +177,17 @@ public:
// css::lang::XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
+ // XInfobarProvider
+ virtual void SAL_CALL
+ appendInfobar(const OUString& sId, const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage, sal_Int32 aInfobarType,
+ const css::uno::Sequence<css::beans::StringPair>& actionButtons,
+ sal_Bool bShowCloseButton) override;
+ virtual void SAL_CALL updateInfobar(const OUString& sId, const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage,
+ sal_Int32 aInfobarType) override;
+ virtual void SAL_CALL removeInfobar(const OUString& sId) override;
+
// FIXME: TL needs this in sw/source/ui/uno/unotxdoc.cxx now;
// either the _Impl name should vanish or there should be an "official" API
SfxViewShell* GetViewShell_Impl() const;
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index 0b65d90857fd..fe336ba5f091 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -39,7 +39,7 @@ class Point;
class Size;
class SfxChildWindow;
class SfxInfoBarWindow;
-enum class InfoBarType;
+enum class InfobarType;
class SFX2_DLLPUBLIC SfxViewFrame: public SfxShell, public SfxListener
{
@@ -153,11 +153,14 @@ public:
and position of each button will be changed: only the width will remain unchanged.
*/
VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId,
- const OUString& sMessage,
- InfoBarType aInfoBarType);
+ const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage,
+ InfobarType aInfobarType,
+ bool bShowCloseButton=true);
void RemoveInfoBar(const OUString& sId);
- void UpdateInfoBar(const OUString& sId,
- const OUString& sMessage, InfoBarType eType);
+ void UpdateInfoBar(const OUString& sId, const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage,
+ InfobarType eType);
bool HasInfoBarWithID(const OUString& sId);
SAL_DLLPRIVATE void GetDocNumber_Impl();