[Libreoffice-commits] core.git: 4 commits - basctl/source include/vcl svtools/source vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Thu May 14 08:13:43 PDT 2015


 basctl/source/basicide/basicrenderable.hxx    |    2 -
 basctl/source/basicide/baside2.hxx            |   14 ++++----
 basctl/source/basicide/baside2b.cxx           |    4 +-
 include/vcl/button.hxx                        |    1 
 include/vcl/salnativewidgets.hxx              |    3 +
 include/vcl/window.hxx                        |    2 -
 svtools/source/misc/imagemgr.cxx              |   45 ++++++++++++--------------
 vcl/source/control/button.cxx                 |   14 ++++++++
 vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx |   21 ++++++++++--
 9 files changed, 70 insertions(+), 36 deletions(-)

New commits:
commit 994b9700f824869ade12b16b8a2ebe333642e9ec
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 14 14:15:29 2015 +0100

    gtk3: provide a scheme where NWF can render the focus rects itself
    
    Change-Id: Ide68e35964670f7acf7a9098b2e04451a17e335a

diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx
index 0732165..18b56e0 100644
--- a/include/vcl/button.hxx
+++ b/include/vcl/button.hxx
@@ -203,6 +203,7 @@ public:
     void            SetToggleHdl( const Link<>& rLink ) { maToggleHdl = rLink; }
     const Link<>&   GetToggleHdl() const { return maToggleHdl; }
     virtual bool    set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
+    virtual void    ShowFocus(const Rectangle& rRect) SAL_OVERRIDE;
 };
 
 inline void PushButton::Check( bool bCheck )
diff --git a/include/vcl/salnativewidgets.hxx b/include/vcl/salnativewidgets.hxx
index b61f6e9..6cab0ba 100644
--- a/include/vcl/salnativewidgets.hxx
+++ b/include/vcl/salnativewidgets.hxx
@@ -225,6 +225,9 @@ typedef sal_uInt32      ControlPart;
 //to draw natively the border of frames
 #define PART_BORDER             7000
 
+//to draw natively the focus rects
+#define PART_FOCUS              8000
+
 /* Control State:
  *
  *   Specify how a particular part of the control
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 1b23608..ae4b4e3 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1100,7 +1100,7 @@ public:
     /// Add all children to @rAllChildren recursively.
     SAL_DLLPRIVATE void                 CollectChildren(::std::vector<vcl::Window *>& rAllChildren );
 
-    void                                ShowFocus( const Rectangle& rRect );
+    virtual void                        ShowFocus(const Rectangle& rRect);
     void                                HideFocus();
 
     void                                Invert( const Rectangle& rRect, sal_uInt16 nFlags = 0 );
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index d545f2d..f6dec45 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -1657,6 +1657,20 @@ bool PushButton::set_property(const OString &rKey, const OString &rValue)
     return true;
 }
 
+void PushButton::ShowFocus(const Rectangle& rRect)
+{
+    bool bNativeOK;
+    if ((bNativeOK = IsNativeControlSupported(CTRL_PUSHBUTTON, PART_FOCUS)))
+    {
+        ImplControlValue aControlValue;
+        Rectangle aInRect(Point(), GetOutputSizePixel());
+        bNativeOK = GetOutDev()->DrawNativeControl(CTRL_PUSHBUTTON, PART_FOCUS, aInRect,
+                                                   ControlState::FOCUSED, aControlValue, OUString());
+    }
+    if (!bNativeOK)
+        Button::ShowFocus(rRect);
+}
+
 void OKButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
 {
     PushButton::ImplInit( pParent, nStyle );
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 37b00b1..bf0e331 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -82,6 +82,7 @@ enum {
     RENDER_SPINBUTTON = 9,
     RENDER_COMBOBOX = 10,
     RENDER_EXTENSION = 11,
+    RENDER_FOCUS = 12,
 };
 
 static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow )
@@ -801,7 +802,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
 {
     GtkStateFlags flags;
     GtkShadowType shadow;
-    gint renderType = RENDER_BACKGROUND_AND_FRAME;
+    gint renderType = nPart == PART_FOCUS ? RENDER_FOCUS : RENDER_BACKGROUND_AND_FRAME;
     GtkStyleContext *context = NULL;
     const gchar *styleClass = NULL;
 
@@ -1034,6 +1035,21 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
     case RENDER_COMBOBOX:
         PaintCombobox(flags, cr, rControlRegion, nType, nPart, rValue);
         break;
+    case RENDER_FOCUS:
+    {
+        GtkBorder border;
+
+        gtk_style_context_get_border(context, flags, &border);
+
+        nX += border.left;
+        nY += border.top;
+        nWidth -= border.left + border.right;
+        nHeight -= border.top + border.bottom;
+
+        gtk_render_focus(context, cr, nX, nY, nWidth, nHeight);
+
+        break;
+    }
     default:
         break;
     }
@@ -1626,7 +1642,7 @@ bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP
 //        case CTRL_PROGRESS:
 //        case CTRL_LISTNODE:
 //        case CTRL_LISTNET:
-            if(nPart==PART_ENTIRE_CONTROL)
+            if (nPart==PART_ENTIRE_CONTROL || nPart == PART_FOCUS)
                 return true;
             break;
 
@@ -1760,6 +1776,7 @@ void GtkData::initNWF()
     pSVData->maNWFData.mbCheckBoxNeedsErase = true;
     pSVData->maNWFData.mbCanDrawWidgetAnySize = true;
     pSVData->maNWFData.mbDDListBoxNoTextArea = true;
+    pSVData->maNWFData.mbNoFocusRects = true;
 }
 
 void GtkData::deInitNWF()
commit 6cbdd2a141d906d941831496e0e697823fac3753
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 14 13:38:34 2015 +0100

    cppcheck: noExplicitConstructor
    
    Change-Id: I42d135456c7f9ce8bbd77db553be96149e4e75af

diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx
index dd60f16..e48ffec 100644
--- a/basctl/source/basicide/basicrenderable.hxx
+++ b/basctl/source/basicide/basicrenderable.hxx
@@ -38,7 +38,7 @@ class Renderable :
 
     VclPtr<Printer> getPrinter();
 public:
-    Renderable (BaseWindow*);
+    explicit Renderable (BaseWindow*);
     virtual ~Renderable();
 
     // XRenderable
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 326c621e..401553a 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -242,8 +242,8 @@ protected:
 
 
 public:
-                    WatchWindow (Layout* pParent);
-                    virtual ~WatchWindow();
+    explicit WatchWindow (Layout* pParent);
+    virtual ~WatchWindow();
     virtual void    dispose() SAL_OVERRIDE;
 
     void            AddWatch( const OUString& rVName );
@@ -265,8 +265,8 @@ protected:
     virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
 
 public:
-                    StackWindow (Layout* pParent);
-                    virtual ~StackWindow();
+    explicit StackWindow (Layout* pParent);
+    virtual ~StackWindow();
     virtual void    dispose() SAL_OVERRIDE;
 
     void            UpdateCalls();
@@ -288,7 +288,7 @@ protected:
     DECL_LINK( ScrollHdl, ScrollBar * );
 
 public:
-                        ComplexEditorWindow( ModulWindow* pParent );
+    explicit ComplexEditorWindow( ModulWindow* pParent );
     virtual             ~ComplexEditorWindow();
     virtual void        dispose() SAL_OVERRIDE;
     BreakPointWindow&   GetBrkWindow()      { return *aBrkWindow.get(); }
@@ -496,7 +496,7 @@ private:
     ExtTextView* GetParentEditView();
 
 public:
-    CodeCompleteListBox( CodeCompleteWindow* pPar );
+    explicit CodeCompleteListBox( CodeCompleteWindow* pPar );
     virtual ~CodeCompleteListBox();
     virtual void dispose() SAL_OVERRIDE;
     void InsertSelectedEntry(); //insert the selected entry
@@ -519,7 +519,7 @@ private:
     void InitListBox(); // initialize the ListBox
 
 public:
-    CodeCompleteWindow( EditorWindow* pPar );
+    explicit CodeCompleteWindow( EditorWindow* pPar );
     virtual ~CodeCompleteWindow();
     virtual void dispose() SAL_OVERRIDE;
 
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 098c8d3..351bc13 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -179,7 +179,7 @@ class EditorWindow::ChangesListener:
     public cppu::WeakImplHelper1< beans::XPropertiesChangeListener >
 {
 public:
-    ChangesListener(EditorWindow & editor): editor_(editor) {}
+    explicit ChangesListener(EditorWindow & editor): editor_(editor) {}
 
 private:
     virtual ~ChangesListener() {}
@@ -1708,7 +1708,7 @@ struct WatchItem
 
     WatchItem*      mpArrayParentItem;
 
-    WatchItem (OUString const& rName):
+    explicit WatchItem (OUString const& rName):
         maName(rName),
         nDimLevel(0),
         nDimCount(0),
commit 4bdde3af25dee11c88d8c83409fa91788cc8dc71
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 14 13:34:15 2015 +0100

    first condition is always true
    
    Change-Id: Ie3934201d99c5dbd3107d6b184a1d575fa38d5c9

diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx
index 423d380..45eae76 100644
--- a/svtools/source/misc/imagemgr.cxx
+++ b/svtools/source/misc/imagemgr.cxx
@@ -533,33 +533,31 @@ OUString SvFileInformationManager::GetDescription_Impl( const INetURLObject& rOb
     if ( !bFolder )
     {
         bool bDetected = false;
-        if ( !bDetected )
+
+        if ( rObject.GetProtocol() == INetProtocol::PrivSoffice )
         {
-            if ( rObject.GetProtocol() == INetProtocol::PrivSoffice )
+            OUString aURLPath = sURL.copy( URL_PREFIX_PRIV_SOFFICE_LEN );
+            OUString aType = aURLPath.getToken( 0, '/' );
+            if ( aType == "factory" )
             {
-                OUString aURLPath = sURL.copy( URL_PREFIX_PRIV_SOFFICE_LEN );
-                OUString aType = aURLPath.getToken( 0, '/' );
-                if ( aType == "factory" )
-                {
-                    sDescription = GetDescriptionByFactory_Impl( aURLPath.copy( aURLPath.indexOf( '/' ) + 1 ) );
-                    bDetected = true;
-                }
+                sDescription = GetDescriptionByFactory_Impl( aURLPath.copy( aURLPath.indexOf( '/' ) + 1 ) );
+                bDetected = true;
             }
+        }
 
-            if ( !bDetected )
+        if (!bDetected)
+        {
+            // search a description by extension
+            bool bExt = !sExtension.isEmpty();
+            if ( bExt )
             {
-                // search a description by extension
-                bool bExt = !sExtension.isEmpty();
-                if ( bExt )
-                {
-                    sExtension = sExtension.toAsciiLowerCase();
-                    nResId = GetDescriptionId_Impl( sExtension, bShowExt );
-                }
-                if ( !nResId )
-                {
-                    nResId = STR_DESCRIPTION_FILE;
-                    bOnlyFile = bExt;
-                }
+                sExtension = sExtension.toAsciiLowerCase();
+                nResId = GetDescriptionId_Impl( sExtension, bShowExt );
+            }
+            if ( !nResId )
+            {
+                nResId = STR_DESCRIPTION_FILE;
+                bOnlyFile = bExt;
             }
         }
     }
commit df6d0af6dd2ccb7fbac0d0ff03bc8f843aa9c104
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 14 13:33:20 2015 +0100

    cppcheck: variableScope
    
    Change-Id: Idc6faf3e2291edbe7877308f9423516f9a08d0cc

diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx
index e341ec22..423d380 100644
--- a/svtools/source/misc/imagemgr.cxx
+++ b/svtools/source/misc/imagemgr.cxx
@@ -528,10 +528,11 @@ OUString SvFileInformationManager::GetDescription_Impl( const INetURLObject& rOb
     OUString sExtension(rObject.getExtension());
     OUString sDescription, sURL( rObject.GetMainURL( INetURLObject::NO_DECODE ) );
     sal_uInt16 nResId = 0;
-    bool bShowExt = false, bDetected = false, bOnlyFile = false;
+    bool bShowExt = false, bOnlyFile = false;
     bool bFolder = bDetectFolder && CONTENT_HELPER::IsFolder( sURL );
     if ( !bFolder )
     {
+        bool bDetected = false;
         if ( !bDetected )
         {
             if ( rObject.GetProtocol() == INetProtocol::PrivSoffice )


More information about the Libreoffice-commits mailing list