[Libreoffice-commits] core.git: Branch 'libreoffice-5-4-7' - include/sfx2 sfx2/source

Katarina Behrens Katarina.Behrens at cib.de
Mon May 7 12:10:12 UTC 2018


 include/sfx2/infobar.hxx       |    4 ++++
 include/sfx2/viewfrm.hxx       |    2 ++
 sfx2/source/dialog/infobar.cxx |   34 ++++++++++++++++++++++++++--------
 sfx2/source/doc/objserv.cxx    |   33 ++++++++++++++++++++-------------
 sfx2/source/view/viewfrm.cxx   |   21 +++++++++++++++++++++
 5 files changed, 73 insertions(+), 21 deletions(-)

New commits:
commit caf1019dd2b575e6dcfe46d05af5e444393d05ab
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Apr 26 16:30:48 2018 +0200

    tdf#117039: update infobar instead of removing and re-adding it
    
    Apparently AppendInfoBar ends up calling back into SID_SIGNATURE
    status function at some point, creating an endless recursion. I'm
    too lazy to debug why so I'm cowardly avoiding it
    
    Reviewed-on: https://gerrit.libreoffice.org/53519
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    (cherry picked from commit 43459bac67363f49aadd851e686d4a74b8ddc256)
    Reviewed-on: https://gerrit.libreoffice.org/53648
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit 8853067a29e091a230a6397bd7c100494ae9f5bf)
    Reviewed-on: https://gerrit.libreoffice.org/53672
    (cherry picked from commit 65936059966f92e983ac0d3553ade9ff37884a4e)
    
    Change-Id: Ib1e4b7f12fea197887b099e9a9f03b4e58884ec1
    Reviewed-on: https://gerrit.libreoffice.org/53741
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 4e49213c19f6..9382bf0fcb45 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -50,11 +50,14 @@ class SfxInfoBarWindow : public vcl::Window
 {
     private:
         OUString                           m_sId;
+        InfoBarType m_eType;
         VclPtr<FixedImage>        m_pImage;
         VclPtr<FixedText>           m_pMessage;
         VclPtr<Button>                m_pCloseBtn;
         std::vector< VclPtr<PushButton> >  m_aActionBtns;
 
+        void SetForeAndBackgroundColors( InfoBarType eType );
+
     public:
         SfxInfoBarWindow( vcl::Window* parent, const OUString& sId,
                           const OUString& sMessage,
@@ -66,6 +69,7 @@ class SfxInfoBarWindow : public vcl::Window
         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;
         basegfx::BColor                m_aForegroundColor;
 
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index e4392d590f34..6276f411485b 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -176,6 +176,8 @@ public:
                                     const OUString& sMessage,
                                     InfoBarType aInfoBarType);
     void              RemoveInfoBar(const OUString& sId);
+    void              UpdateInfoBar(const OUString& sId,
+                               const OUString& sMessage, InfoBarType eType);
     bool              HasInfoBarWithID(const OUString& sId);
 
     SAL_DLLPRIVATE void GetDocNumber_Impl();
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index 2d03bf01e20b..90157f781030 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -175,19 +175,13 @@ SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
        WinBits nMessageStyle = WB_LEFT|WB_VCENTER) :
     Window(pParent, 0),
     m_sId(sId),
+    m_eType(ibType),
     m_pImage(VclPtr<FixedImage>::Create(this, nMessageStyle)),
     m_pMessage(VclPtr<FixedText>::Create(this, nMessageStyle)),
     m_pCloseBtn(VclPtr<SfxCloseButton>::Create(this)),
     m_aActionBtns()
 {
-    basegfx::BColor aBackgroundColor;
-    basegfx::BColor aForegroundColor;
-    basegfx::BColor aMessageColor;
-    GetInfoBarColors(ibType,aBackgroundColor,aForegroundColor,aMessageColor);
-    static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setBackgroundColor(aBackgroundColor);
-    static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setForegroundColor(aForegroundColor);
-    m_pMessage->SetControlForeground(Color(aMessageColor));
-
+    SetForeAndBackgroundColors(m_eType);
     float fScaleFactor = GetDPIScaleFactor();
     long nWidth = pParent->GetSizePixel().getWidth();
     SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * fScaleFactor));
@@ -219,6 +213,16 @@ SfxInfoBarWindow::~SfxInfoBarWindow()
     disposeOnce();
 }
 
+void SfxInfoBarWindow::SetForeAndBackgroundColors(InfoBarType eType)
+{
+    basegfx::BColor aMessageColor;
+    GetInfoBarColors(eType,m_aBackgroundColor,m_aForegroundColor,aMessageColor);
+
+    static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setBackgroundColor(m_aBackgroundColor);
+    static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setForegroundColor(m_aForegroundColor);
+    m_pMessage->SetControlForeground(Color(aMessageColor));
+}
+
 void SfxInfoBarWindow::dispose()
 {
     for ( auto it = m_aActionBtns.begin( ); it != m_aActionBtns.end( ); ++it )
@@ -298,6 +302,20 @@ void SfxInfoBarWindow::Resize()
 
 }
 
+void SfxInfoBarWindow::Update( const OUString &sNewMessage, InfoBarType eType )
+{
+    if (m_eType != eType)
+    {
+        m_eType = eType;
+        SetForeAndBackgroundColors(m_eType);
+        m_pImage->SetImage(Image(BitmapEx(GetInfoBarIconName(eType))));
+    }
+
+    m_pMessage->SetText( sNewMessage );
+    Resize();
+    Invalidate();
+}
+
 IMPL_LINK_NOARG(SfxInfoBarWindow, CloseHandler, Button*, void)
 {
     static_cast<SfxInfoBarContainerWindow*>(GetParent())->removeInfoBar(this);
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 16265c2510d5..29b44dabafb7 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1070,21 +1070,28 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
                         break;
                     }
 
-                    if ( pFrame->HasInfoBarWithID("signature") )
-                        pFrame->RemoveInfoBar("signature");
-
-                    if ( eState != SignatureState::NOSIGNATURES )
+                    // new info bar
+                    if ( !pFrame->HasInfoBarWithID("signature") )
+                    {
+                        if ( !sMessage.isEmpty() )
+                        {
+                            auto pInfoBar = pFrame->AppendInfoBar("signature", sMessage, aInfoBarType);
+                            if (pInfoBar == nullptr || pInfoBar->isDisposed())
+                                return;
+                            VclPtrInstance<PushButton> xBtn(&(pFrame->GetWindow()));
+                            xBtn->SetText(SfxResId(STR_SIGNATURE_SHOW));
+                            xBtn->SetSizePixel(xBtn->GetOptimalSize());
+                            xBtn->SetClickHdl(LINK(this, SfxObjectShell, SignDocumentHandler));
+                            pInfoBar->addButton(xBtn);
+                        }
+                    }
+                    else // info bar exists already
                     {
-                        auto pInfoBar = pFrame->AppendInfoBar("signature", sMessage, aInfoBarType);
-                        if (pInfoBar == nullptr)
-                            return;
-                        VclPtrInstance<PushButton> xBtn(&(pFrame->GetWindow()));
-                        xBtn->SetText(SfxResId(STR_SIGNATURE_SHOW));
-                        xBtn->SetSizePixel(xBtn->GetOptimalSize());
-                        xBtn->SetClickHdl(LINK(this, SfxObjectShell, SignDocumentHandler));
-                        pInfoBar->addButton(xBtn);
+                        if ( eState == SignatureState::NOSIGNATURES )
+                            pFrame->RemoveInfoBar("signature");
+                        else
+                            pFrame->UpdateInfoBar("signature", sMessage, aInfoBarType);
                     }
-
                 }
 
                 rSet.Put( SfxUInt16Item( SID_SIGNATURE, static_cast<sal_uInt16>(GetDocumentSignatureState()) ) );
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 3a7a62394d80..89070eb4e591 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3001,6 +3001,27 @@ VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar(const OUString& sId,
     return pInfoBar;
 }
 
+void SfxViewFrame::UpdateInfoBar( const OUString& sId,
+                           const OUString& sMessage,
+                           InfoBarType eType )
+{
+    const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
+
+    // Make sure the InfoBar container is visible
+    if (!HasChildWindow(nId))
+        ToggleChildWindow(nId);
+
+    SfxChildWindow* pChild = GetChildWindow(nId);
+    if (pChild)
+    {
+        SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
+        auto pInfoBar = pInfoBarContainer->getInfoBar(sId);
+
+        if (pInfoBar)
+             pInfoBar->Update(sMessage, eType);
+    }
+}
+
 void SfxViewFrame::RemoveInfoBar( const OUString& sId )
 {
     const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();


More information about the Libreoffice-commits mailing list