[Libreoffice-commits] core.git: compilerplugins/clang include/toolkit toolkit/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Dec 19 06:05:10 UTC 2016


 compilerplugins/clang/mergeclasses.results |    1 
 include/toolkit/awt/scrollabledialog.hxx   |   39 +++++---------
 toolkit/source/awt/scrollabledialog.cxx    |   76 ++++++++++-------------------
 toolkit/source/awt/vclxcontainer.cxx       |    2 
 toolkit/source/awt/vclxtoolkit.cxx         |    4 -
 5 files changed, 45 insertions(+), 77 deletions(-)

New commits:
commit f9fd6390cd88b87ca81538385da028ff5b1783c0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Dec 15 12:55:54 2016 +0200

    ScrollableWrapper -> ScrollableDialog
    
    no point in having a template and a virtual base class when it's only
    used for one type
    
    Change-Id: Idb1a1a551064cc10896eff33652038eb5be0297e
    Reviewed-on: https://gerrit.libreoffice.org/32041
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/mergeclasses.results b/compilerplugins/clang/mergeclasses.results
index b76adfb..2a058f6 100644
--- a/compilerplugins/clang/mergeclasses.results
+++ b/compilerplugins/clang/mergeclasses.results
@@ -358,7 +358,6 @@ merge sw::mark::IBookmark with sw::mark::Bookmark
 merge sw::mark::ICheckboxFieldmark with sw::mark::CheckboxFieldmark
 merge sw::sidebarwindows::SwSidebarWin with sw::annotation::SwAnnotationWin
 merge sw::util::WrtRedlineAuthor with WW8_WrtRedlineAuthor
-merge toolkit::ScrollableInterface with toolkit::ScrollableWrapper
 merge unographic::GraphicTransformer with unographic::Graphic
 merge vcl::DeletionNotifier with SalFrame
 merge vcl::ExtOutDevData with vcl::PDFExtOutDevData
diff --git a/include/toolkit/awt/scrollabledialog.hxx b/include/toolkit/awt/scrollabledialog.hxx
index c414c8f..83c0123 100644
--- a/include/toolkit/awt/scrollabledialog.hxx
+++ b/include/toolkit/awt/scrollabledialog.hxx
@@ -26,19 +26,12 @@
 
 namespace toolkit
 {
-    class ScrollableInterface
+    class ScrollableDialog : public Dialog
     {
     public:
-        virtual ~ScrollableInterface() {}
-        virtual void    SetScrollWidth( long nWidth ) = 0;
-        virtual void    SetScrollHeight( long nHeight ) = 0;
-        virtual void    SetScrollLeft( long nLeft ) = 0;
-        virtual void    SetScrollTop( long Top ) = 0;
-    };
+        enum ScrollBarVisibility { None, Vert, Hori, Both };
 
-  template < class T >
-    class ScrollableWrapper : public T, public ScrollableInterface
-    {
+    private:
         VclPtr<ScrollBar>  maHScrollBar;
         VclPtr<ScrollBar>  maVScrollBar;
         Size               maScrollArea;
@@ -46,26 +39,24 @@ namespace toolkit
         bool               mbHasVertBar;
         Point              mnScrollPos;
         long               mnScrWidth;
-
-    public:
-        enum ScrollBarVisibility { None, Vert, Hori, Both };
-    private:
         ScrollBarVisibility maScrollVis;
+
         void    lcl_Scroll( long nX, long nY );
+        DECL_LINK( ScrollBarHdl, ScrollBar*, void );
+
     public:
-        ScrollableWrapper( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, Dialog::InitFlag eFlag = Dialog::InitFlag::Default );
-        virtual ~ScrollableWrapper() override;
+        ScrollableDialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, Dialog::InitFlag eFlag = Dialog::InitFlag::Default );
+        virtual ~ScrollableDialog() override;
         virtual void dispose() override;
-        virtual void    SetScrollWidth( long nWidth ) override;
-        virtual void    SetScrollHeight( long nHeight ) override;
-        virtual void    SetScrollLeft( long nLeft ) override;
-        virtual void    SetScrollTop( long Top ) override;
-
-        void setScrollVisibility( ScrollBarVisibility rState );
-        DECL_LINK( ScrollBarHdl, ScrollBar*, void );
-        void ResetScrollBars();
         // Window
         virtual void Resize() override;
+
+        void    SetScrollWidth( long nWidth );
+        void    SetScrollHeight( long nHeight );
+        void    SetScrollLeft( long nLeft );
+        void    SetScrollTop( long Top );
+        void    setScrollVisibility( ScrollBarVisibility rState );
+        void    ResetScrollBars();
     };
 
 } // namespacetoolkit
diff --git a/toolkit/source/awt/scrollabledialog.cxx b/toolkit/source/awt/scrollabledialog.cxx
index a74aab5..af8c928 100644
--- a/toolkit/source/awt/scrollabledialog.cxx
+++ b/toolkit/source/awt/scrollabledialog.cxx
@@ -30,16 +30,15 @@ namespace toolkit
 // as css::awt::WindowAttribute::NODECORATION and they are used
 // in the same bitmap :-( WB_VSCROLL & WB_HSCROLL apparently are only for
 // child classes ( whole thing is a mess if you ask me )
-template< class T>
-ScrollableWrapper<T>::ScrollableWrapper( vcl::Window* pParent, WinBits nStyle, Dialog::InitFlag eFlag )
-    : T( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ), eFlag ),
+ScrollableDialog::ScrollableDialog( vcl::Window* pParent, WinBits nStyle, Dialog::InitFlag eFlag )
+    : Dialog( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ), eFlag ),
       maHScrollBar( VclPtr<ScrollBar>::Create(this, WB_HSCROLL | WB_DRAG) ),
       maVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) ),
       mbHasHoriBar( false ),
       mbHasVertBar( false ),
       maScrollVis( None )
 {
-    Link<ScrollBar*,void> aLink( LINK( this, ScrollableWrapper, ScrollBarHdl ) );
+    Link<ScrollBar*,void> aLink( LINK( this, ScrollableDialog, ScrollBarHdl ) );
     maVScrollBar->SetScrollHdl( aLink );
     maHScrollBar->SetScrollHdl( aLink );
 
@@ -58,11 +57,10 @@ ScrollableWrapper<T>::ScrollableWrapper( vcl::Window* pParent, WinBits nStyle, D
         }
     }
     setScrollVisibility( aVis );
-    mnScrWidth = T::GetSettings().GetStyleSettings().GetScrollBarSize();
+    mnScrWidth = Dialog::GetSettings().GetStyleSettings().GetScrollBarSize();
 }
 
-template< class T>
-void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState )
+void ScrollableDialog::setScrollVisibility( ScrollBarVisibility rVisState )
 {
     maScrollVis = rVisState;
     if (  maScrollVis == Hori || maScrollVis == Both )
@@ -76,36 +74,33 @@ void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState )
         maVScrollBar->Show();
     }
     if ( mbHasHoriBar || mbHasVertBar )
-        this->SetStyle( T::GetStyle() | WB_CLIPCHILDREN | WB_AUTOSIZE );
+        this->SetStyle( Dialog::GetStyle() | WB_CLIPCHILDREN | WB_AUTOSIZE );
 }
 
-template< class T>
-ScrollableWrapper<T>::~ScrollableWrapper()
+ScrollableDialog::~ScrollableDialog()
 {
-    T::disposeOnce();
+    disposeOnce();
 }
 
-template< class T>
-void ScrollableWrapper<T>::dispose()
+void ScrollableDialog::dispose()
 {
     maHScrollBar.disposeAndClear();
     maVScrollBar.disposeAndClear();
-    T::dispose();
+    Dialog::dispose();
 }
 
-template< class T>
-void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY )
+void ScrollableDialog::lcl_Scroll( long nX, long nY )
 {
     long nXScroll = mnScrollPos.X() - nX;
     long nYScroll = mnScrollPos.Y() - nY;
     mnScrollPos = Point( nX, nY );
 
     Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() );
-    T::Scroll(nXScroll, nYScroll, aScrollableArea );
+    Scroll(nXScroll, nYScroll, aScrollableArea );
     // Manually scroll all children ( except the scrollbars )
-    for ( int index = 0; index < T::GetChildCount(); ++index )
+    for ( int index = 0; index < GetChildCount(); ++index )
     {
-        vcl::Window* pChild = T::GetChild( index );
+        vcl::Window* pChild = GetChild( index );
         if ( pChild && pChild != maVScrollBar.get() && pChild != maHScrollBar.get() )
         {
             Point aPos = pChild->GetPosPixel();
@@ -115,17 +110,7 @@ void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY )
     }
 }
 
-//Can't use IMPL_LINK with the template
-//IMPL_LINK( ScrollableWrapper, ScrollBarHdl, ScrollBar*, pSB, void )
-
-template< class T>
-void ScrollableWrapper<T>::LinkStubScrollBarHdl( void* pThis, ScrollBar* pCaller)
-{
-    static_cast<ScrollableWrapper<T>*>(pThis)->ScrollBarHdl( pCaller );
-}
-
-template< class T>
-void ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB )
+IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB, void )
 {
     sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos();
     if( pSB == maVScrollBar.get() )
@@ -134,8 +119,7 @@ void ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB )
         lcl_Scroll(nPos, mnScrollPos.Y() );
 }
 
-template< class T>
-void ScrollableWrapper<T>::SetScrollTop( long nTop )
+void ScrollableDialog::SetScrollTop( long nTop )
 {
     Point aOld = mnScrollPos;
     lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop );
@@ -143,8 +127,7 @@ void ScrollableWrapper<T>::SetScrollTop( long nTop )
     // new pos is 0,0
     mnScrollPos = aOld;
 }
-template< class T>
-void ScrollableWrapper<T>::SetScrollLeft( long nLeft )
+void ScrollableDialog::SetScrollLeft( long nLeft )
 {
     Point aOld = mnScrollPos;
     lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() );
@@ -152,45 +135,40 @@ void ScrollableWrapper<T>::SetScrollLeft( long nLeft )
     // new pos is 0,0
     mnScrollPos = aOld;
 }
-template< class T>
-void ScrollableWrapper<T>::SetScrollWidth( long nWidth )
+
+void ScrollableDialog::SetScrollWidth( long nWidth )
 {
     maScrollArea.Width() = nWidth;
     ResetScrollBars();
 }
 
-template< class T>
-void ScrollableWrapper<T>::SetScrollHeight( long nHeight )
+void ScrollableDialog::SetScrollHeight( long nHeight )
 {
     maScrollArea.Height() = nHeight;
     ResetScrollBars();
 }
 
-template< class T>
-void ScrollableWrapper<T>::Resize()
+void ScrollableDialog::Resize()
 {
     ResetScrollBars();
 }
 
-template< class T>
-void ScrollableWrapper<T>::ResetScrollBars()
+void ScrollableDialog::ResetScrollBars()
 {
-    Size aOutSz = T::GetOutputSizePixel();
+    Size aOutSz = GetOutputSizePixel();
 
     Point aVPos( aOutSz.Width() - mnScrWidth, 0 );
     Point aHPos( 0, aOutSz.Height() - mnScrWidth );
 
-    maVScrollBar->SetPosSizePixel( aVPos, Size( mnScrWidth,  T::GetSizePixel().Height() - mnScrWidth ) );
-    maHScrollBar->SetPosSizePixel( aHPos, Size(  T::GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
+    maVScrollBar->SetPosSizePixel( aVPos, Size( mnScrWidth,  GetSizePixel().Height() - mnScrWidth ) );
+    maHScrollBar->SetPosSizePixel( aHPos, Size(  GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
 
     maHScrollBar->SetRangeMax( maScrollArea.Width() + mnScrWidth  );
-    maHScrollBar->SetVisibleSize( T::GetSizePixel().Width() );
+    maHScrollBar->SetVisibleSize( GetSizePixel().Width() );
 
     maVScrollBar->SetRangeMax( maScrollArea.Height() + mnScrWidth );
-    maVScrollBar->SetVisibleSize( T::GetSizePixel().Height() );
+    maVScrollBar->SetVisibleSize( GetSizePixel().Height() );
 }
 
-template class ScrollableWrapper< Dialog >;
-
 } // toolkit
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/source/awt/vclxcontainer.cxx b/toolkit/source/awt/vclxcontainer.cxx
index 0bd1ecd..275ae9b 100644
--- a/toolkit/source/awt/vclxcontainer.cxx
+++ b/toolkit/source/awt/vclxcontainer.cxx
@@ -245,7 +245,7 @@ throw(css::uno::RuntimeException, std::exception)
             Size aSize( nVal, nVal );
             VclPtr<vcl::Window> pWindow = GetWindow();
             MapMode aMode( MapUnit::MapAppFont );
-            toolkit::ScrollableInterface* pScrollable = dynamic_cast< toolkit::ScrollableInterface* >( pWindow.get() );
+            toolkit::ScrollableDialog* pScrollable = dynamic_cast< toolkit::ScrollableDialog* >( pWindow.get() );
             if ( pWindow && pScrollable )
             {
                 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 28338f1..51e3321 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -984,9 +984,9 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
             {
                 // Modal/Modeless nur durch Show/Execute
                 if ( (pParent == nullptr ) && ( rDescriptor.ParentIndex == -1 ) )
-                    pNewWindow = VclPtr<toolkit::ScrollableWrapper<Dialog>>::Create( nullptr, nWinBits, Dialog::InitFlag::NoParent );
+                    pNewWindow = VclPtr<toolkit::ScrollableDialog>::Create( nullptr, nWinBits, Dialog::InitFlag::NoParent );
                 else
-                    pNewWindow = VclPtr<toolkit::ScrollableWrapper<Dialog>>::Create( pParent, nWinBits );
+                    pNewWindow = VclPtr<toolkit::ScrollableDialog>::Create( pParent, nWinBits );
                 // #i70217# Don't always create a new component object. It's possible that VCL has called
                 // GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() )
                 // which creates a component object.


More information about the Libreoffice-commits mailing list