forms/source/helper/commandimageprovider.cxx   |   38 +------------------------
 forms/source/inc/commandimageprovider.hxx      |   29 +++++--------------
 forms/source/solar/component/navbarcontrol.cxx |    2 -
 forms/source/solar/control/navtoolbar.cxx      |    4 +-
 forms/source/solar/inc/navtoolbar.hxx          |    6 +--
 5 files changed, 18 insertions(+), 61 deletions(-)

New commits:
commit 1d1366bd15de157371cd3353d43fc7873dcaa3af
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Dec 2 09:57:02 2019 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Dec 3 10:57:41 2019 +0100

    loplugin:mergeclases ICommandImageProvider with DocumentCommandImageProvider
    
    Change-Id: Ia6997489a8f21f33287e11e39fab1bb059070c89
    Reviewed-on: https://gerrit.libreoffice.org/84195
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/forms/source/helper/commandimageprovider.cxx 
b/forms/source/helper/commandimageprovider.cxx
index 6569c8a4373e..ca2d7052567f 100644
--- a/forms/source/helper/commandimageprovider.cxx
+++ b/forms/source/helper/commandimageprovider.cxx
@@ -52,30 +52,7 @@ namespace frm
 
     namespace ImageType = ::com::sun::star::ui::ImageType;
 
-    namespace {
-
-    class DocumentCommandImageProvider : public ICommandImageProvider
-    {
-    public:
-        DocumentCommandImageProvider( const Reference<XComponentContext>& 
_rContext, const Reference< XModel >& _rxDocument )
-        {
-            impl_init_nothrow( _rContext, _rxDocument );
-        }
-
-        // ICommandImageProvider
-        virtual CommandImages getCommandImages( const css::uno::Sequence< 
OUString >& _rCommandURLs, const bool _bLarge ) const override;
-
-    private:
-        void    impl_init_nothrow( const Reference<XComponentContext>& 
_rContext, const Reference< XModel >& _rxDocument );
-
-    private:
-        Reference< XImageManager >    m_xDocumentImageManager;
-        Reference< XImageManager >    m_xModuleImageManager;
-    };
-
-    }
-
-    void DocumentCommandImageProvider::impl_init_nothrow( const 
Reference<XComponentContext>& _rContext, const Reference< XModel >& _rxDocument 
)
+    DocumentCommandImageProvider::DocumentCommandImageProvider( const 
Reference<XComponentContext>& _rContext, const Reference< XModel >& _rxDocument 
)
     {
         OSL_ENSURE( _rxDocument.is(), 
"DocumentCommandImageProvider::impl_init_nothrow: no document => no images!" );
         if ( !_rxDocument.is() )
@@ -112,10 +89,10 @@ namespace frm
     }
 
 
-    CommandImages DocumentCommandImageProvider::getCommandImages( const 
css::uno::Sequence< OUString >& _rCommandURLs, const bool _bLarge ) const
+    std::vector<Image> DocumentCommandImageProvider::getCommandImages( const 
css::uno::Sequence< OUString >& _rCommandURLs, const bool _bLarge ) const
     {
         const size_t nCommandCount = _rCommandURLs.getLength();
-        CommandImages aImages( nCommandCount );
+        std::vector<Image> aImages( nCommandCount );
         try
         {
             const sal_Int16 nImageType = ImageType::COLOR_NORMAL
@@ -150,15 +127,6 @@ namespace frm
         return aImages;
     }
 
-
-    PCommandImageProvider createDocumentCommandImageProvider(
-        const Reference<XComponentContext>& _rContext, const Reference< XModel 
>& _rxDocument )
-    {
-        PCommandImageProvider pImageProvider( new 
DocumentCommandImageProvider( _rContext, _rxDocument ) );
-        return pImageProvider;
-    }
-
-
 } // namespace frm
 
 
diff --git a/forms/source/inc/commandimageprovider.hxx 
b/forms/source/inc/commandimageprovider.hxx
index 560be1dc5c74..3a67df02256a 100644
--- a/forms/source/inc/commandimageprovider.hxx
+++ b/forms/source/inc/commandimageprovider.hxx
@@ -22,6 +22,7 @@
 
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/ui/XImageManager.hpp>
 
 #include <vcl/image.hxx>
 
@@ -31,32 +32,20 @@
 namespace frm
 {
 
-
-    //= ICommandImageProvider
-
-    typedef ::std::vector< Image >                 CommandImages;
-
-    class SAL_NO_VTABLE ICommandImageProvider
+    class DocumentCommandImageProvider
     {
     public:
-        virtual CommandImages   getCommandImages(
-                                    const css::uno::Sequence< OUString >& 
_rCommandURLs,
-                                    const bool _bLarge
-                                ) const = 0;
+        DocumentCommandImageProvider( const 
css::uno::Reference<css::uno::XComponentContext>& _rContext, const 
css::uno::Reference< css::frame::XModel >& _rxDocument );
 
-        virtual ~ICommandImageProvider() { }
-    };
-
-    typedef std::shared_ptr< const ICommandImageProvider >  
PCommandImageProvider;
+        std::vector<Image> getCommandImages( const css::uno::Sequence< 
OUString >& _rCommandURLs, bool _bLarge ) const;
 
+    private:
+        css::uno::Reference< css::ui::XImageManager >    
m_xDocumentImageManager;
+        css::uno::Reference< css::ui::XImageManager >    m_xModuleImageManager;
+    };
 
-    //= factory
 
-    PCommandImageProvider
-        createDocumentCommandImageProvider(
-            const css::uno::Reference<css::uno::XComponentContext>& _rContext,
-            const css::uno::Reference< css::frame::XModel >& _rxDocument
-        );
+    typedef std::shared_ptr< const DocumentCommandImageProvider >  
PCommandImageProvider;
 
 
 } // namespace frm
diff --git a/forms/source/solar/component/navbarcontrol.cxx 
b/forms/source/solar/component/navbarcontrol.cxx
index 680f3b84e312..c2fc4485a446 100644
--- a/forms/source/solar/component/navbarcontrol.cxx
+++ b/forms/source/solar/component/navbarcontrol.cxx
@@ -211,7 +211,7 @@ namespace frm
         VclPtrInstance<NavigationToolBar> pNavBar(
             _pParentWindow,
             lcl_getWinBits_nothrow( _rxModel ),
-            createDocumentCommandImageProvider( _rxORB, xContextDocument ),
+            std::make_shared<DocumentCommandImageProvider>( _rxORB, 
xContextDocument ),
             sModuleID
         );
 
diff --git a/forms/source/solar/control/navtoolbar.cxx 
b/forms/source/solar/control/navtoolbar.cxx
index 5acd1139e217..bbb717139e19 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -366,10 +366,10 @@ namespace frm
         }
 
         // retrieve the images for the command URLs
-        CommandImages aCommandImages = m_pImageProvider->getCommandImages( 
aCommandURLs, m_eImageSize == eLarge );
+        std::vector<Image> aCommandImages = 
m_pImageProvider->getCommandImages( aCommandURLs, m_eImageSize == eLarge );
 
         // and set them at the toolbar
-        CommandImages::const_iterator commandImage = aCommandImages.begin();
+        auto commandImage = aCommandImages.begin();
         for (auto const& formFeature : aFormFeatures)
         {
             m_pToolbar->SetItemImage( formFeature, *commandImage );
diff --git a/forms/source/solar/inc/navtoolbar.hxx 
b/forms/source/solar/inc/navtoolbar.hxx
index e5db22177383..1018ff6e16b3 100644
--- a/forms/source/solar/inc/navtoolbar.hxx
+++ b/forms/source/solar/inc/navtoolbar.hxx
@@ -31,10 +31,10 @@ namespace frm
 
 
     class IFeatureDispatcher;
-    class ICommandImageProvider;
+    class DocumentCommandImageProvider;
     class ICommandDescriptionProvider;
     class ImplNavToolBar;
-    typedef std::shared_ptr< const ICommandImageProvider >  
PCommandImageProvider;
+    typedef std::shared_ptr< const DocumentCommandImageProvider >  
PCommandImageProvider;
 
     class NavigationToolBar final : public vcl::Window
     {
@@ -55,7 +55,7 @@ namespace frm
 
     private:
         const IFeatureDispatcher*       m_pDispatcher;
-        const std::shared_ptr< const ICommandImageProvider >
+        const std::shared_ptr< const DocumentCommandImageProvider >
                                         m_pImageProvider;
         ImageSize                       m_eImageSize;
         VclPtr<ImplNavToolBar>          m_pToolbar;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to