[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Feb 17 12:46:25 UTC 2016


 include/sfx2/infobar.hxx                  |    9 +++-
 include/sfx2/viewfrm.hxx                  |    6 ++-
 sfx2/source/dialog/infobar.cxx            |   56 +++++++++++++++++++++---------
 sfx2/source/view/classificationhelper.cxx |    3 +
 sfx2/source/view/viewfrm.cxx              |    4 +-
 5 files changed, 57 insertions(+), 21 deletions(-)

New commits:
commit 7decc4193028f27354556a007a99088c1ea0b32e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Feb 17 12:21:47 2016 +0100

    sfx2 infobar: allow setting the back/foreground color
    
    It would be easier to set these after the infobar is created, but the
    infobar is shown right after creating it, so that way the infobar would
    be always yellow for a short period of time -> annoying flashing.
    
    Change-Id: Ie23efd2fd1bba624cf2921f11a6fc40014ac4215

diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 71123d0..483c0f8 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -13,6 +13,7 @@
 
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
+#include <basegfx/color/bcolor.hxx>
 
 #include <sfx2/dllapi.h>
 #include <sfx2/childwin.hxx>
@@ -45,10 +46,14 @@ class SfxInfoBarWindow : public vcl::Window
         VclPtr<FixedText>                  m_pMessage;
         VclPtr<Button>                     m_pCloseBtn;
         std::vector< VclPtr<PushButton> >  m_aActionBtns;
+        basegfx::BColor                    m_aBackgroundColor;
+        basegfx::BColor                    m_aForegroundColor;
 
     public:
         SfxInfoBarWindow( vcl::Window* parent, const OUString& sId,
-                          const OUString& sMessage );
+                          const OUString& sMessage,
+                          const basegfx::BColor* pBackgroundColor,
+                          const basegfx::BColor* pForegroundColor );
         virtual ~SfxInfoBarWindow( );
         virtual void dispose() override;
 
@@ -77,7 +82,7 @@ class SfxInfoBarContainerWindow : public vcl::Window
         virtual ~SfxInfoBarContainerWindow( );
         virtual void dispose() override;
 
-        SfxInfoBarWindow* appendInfoBar(const OUString& sId, const OUString& sMessage);
+        SfxInfoBarWindow* appendInfoBar(const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor);
         SfxInfoBarWindow* getInfoBar(const OUString& sId);
         void removeInfoBar(SfxInfoBarWindow* pInfoBar);
 
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index 9497e86..7ea25ef 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -57,6 +57,10 @@ namespace svtools
 {
     class AsynchronLink;
 }
+namespace basegfx
+{
+    class BColor;
+}
 
 #ifndef SFX_DECL_OBJECTSHELL_DEFINED
 #define SFX_DECL_OBJECTSHELL_DEFINED
@@ -176,7 +180,7 @@ public:
         The buttons will be added from Right to Left at the right of the info bar. The parent, size
         and position of each button will be changed: only the width will remain unchanged.
       */
-    SfxInfoBarWindow* AppendInfoBar(const OUString& sId, const OUString& sMessage);
+    SfxInfoBarWindow* AppendInfoBar(const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor = 0, const basegfx::BColor* pForegroundColor = 0);
     void              RemoveInfoBar(const OUString& sId);
 
     SAL_DLLPRIVATE void SetDowning_Impl();
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index a3c7f54..f34f23c 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -54,13 +54,21 @@ void lclDetermineLightDarkColor(BColor& rLightColor, BColor& rDarkColor)
 
 class SfxCloseButton : public PushButton
 {
+    basegfx::BColor m_aBackgroundColor;
+    basegfx::BColor m_aForegroundColor;
+
 public:
     explicit SfxCloseButton(vcl::Window* pParent) : PushButton(pParent, 0)
-    {}
+    {
+        lclDetermineLightDarkColor(m_aBackgroundColor, m_aForegroundColor);
+    }
 
     virtual ~SfxCloseButton() {}
 
     virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
+
+    void setBackgroundColor(const basegfx::BColor& rColor);
+    void setForegroundColor(const basegfx::BColor& rColor);
 };
 
 void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
@@ -73,10 +81,6 @@ void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
 
     drawinglayer::primitive2d::Primitive2DContainer aSeq(2);
 
-    BColor aLightColor;
-    BColor aDarkColor;
-    lclDetermineLightDarkColor(aLightColor, aDarkColor);
-
     // Light background
     B2DPolygon aPolygon;
     aPolygon.append(B2DPoint(aRect.Left(), aRect.Top()));
@@ -86,10 +90,10 @@ void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
     aPolygon.setClosed(true);
 
     PolyPolygonColorPrimitive2D* pBack =
-        new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor);
+        new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), m_aBackgroundColor);
     aSeq[0] = pBack;
 
-    LineAttribute aLineAttribute(aDarkColor, 2.0);
+    LineAttribute aLineAttribute(m_aForegroundColor, 2.0);
 
     // Cross
     B2DPolyPolygon aCross;
@@ -112,16 +116,40 @@ void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
     pProcessor->process(aSeq);
 }
 
+void SfxCloseButton::setBackgroundColor(const basegfx::BColor& rColor)
+{
+    m_aBackgroundColor = rColor;
+}
+
+void SfxCloseButton::setForegroundColor(const basegfx::BColor& rColor)
+{
+    m_aForegroundColor = rColor;
+}
+
 } // anonymous namespace
 
 SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
-       const OUString& sMessage) :
+       const OUString& sMessage,
+       const basegfx::BColor* pBackgroundColor,
+       const basegfx::BColor* pForegroundColor ) :
     Window(pParent, 0),
     m_sId(sId),
     m_pMessage(VclPtr<FixedText>::Create(this, 0)),
     m_pCloseBtn(VclPtr<SfxCloseButton>::Create(this)),
     m_aActionBtns()
 {
+    lclDetermineLightDarkColor(m_aBackgroundColor, m_aForegroundColor);
+    if (pBackgroundColor)
+    {
+        m_aBackgroundColor = *pBackgroundColor;
+        static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setBackgroundColor(m_aBackgroundColor);
+    }
+    if (pForegroundColor)
+    {
+        m_aForegroundColor = *pForegroundColor;
+        static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setForegroundColor(m_aForegroundColor);
+    }
+
     sal_Int32 nScaleFactor = GetDPIScaleFactor();
     long nWidth = pParent->GetSizePixel().getWidth();
     SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * nScaleFactor));
@@ -170,10 +198,6 @@ void SfxInfoBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle
 
     drawinglayer::primitive2d::Primitive2DContainer aSeq(2);
 
-    BColor aLightColor;
-    BColor aDarkColor;
-    lclDetermineLightDarkColor(aLightColor, aDarkColor);
-
     // Light background
     B2DPolygon aPolygon;
     aPolygon.append(B2DPoint(aRect.Left(), aRect.Top()));
@@ -183,10 +207,10 @@ void SfxInfoBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle
     aPolygon.setClosed(true);
 
     PolyPolygonColorPrimitive2D* pBack =
-        new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor);
+        new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), m_aBackgroundColor);
     aSeq[0] = pBack;
 
-    LineAttribute aLineAttribute(aDarkColor, 1.0);
+    LineAttribute aLineAttribute(m_aForegroundColor, 1.0);
 
     // Bottom dark line
     B2DPolygon aPolygonBottom;
@@ -253,11 +277,11 @@ void SfxInfoBarContainerWindow::dispose()
     Window::dispose();
 }
 
-SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage)
+SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor)
 {
     Size aSize = GetSizePixel();
 
-    VclPtrInstance<SfxInfoBarWindow> pInfoBar(this, sId, sMessage);
+    VclPtrInstance<SfxInfoBarWindow> pInfoBar(this, sId, sMessage, pBackgroundColor, pForegroundColor);
     pInfoBar->SetPosPixel(Point(0, aSize.getHeight()));
     pInfoBar->Show();
     m_pInfoBars.push_back(pInfoBar);
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 0585085..068bbcd 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3191,7 +3191,7 @@ void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame )
     SfxGetpApp()->SetViewFrame_Impl( pFrame );
 }
 
-SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage )
+SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor )
 {
     const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
 
@@ -3203,7 +3203,7 @@ SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUStri
     if (pChild)
     {
         SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
-        SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage);
+        SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor);
         ShowChildWindow(nId);
         return pInfoBar;
     }
commit f3b0bd89a892d15179b9d6133c43e64bfcebbdf9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Feb 17 11:49:57 2016 +0100

    sfx2 classification: ignore non-BAILS properties early
    
    Change-Id: Ia32492965a0802a848215c86fdc07e14648d3d58

diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index c4e2245..7ad5cb3 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -55,6 +55,9 @@ SfxClassificationHelper::SfxClassificationHelper(SfxObjectShell& rObjectShell)
     uno::Sequence<beans::Property> aProperties = xPropertySet->getPropertySetInfo()->getProperties();
     for (const beans::Property& rProperty : aProperties)
     {
+        if (!rProperty.Name.startsWith("urn:bails:"))
+            continue;
+
         uno::Any aAny = xPropertySet->getPropertyValue(rProperty.Name);
         OUString aValue;
         if (aAny >>= aValue)


More information about the Libreoffice-commits mailing list