[Libreoffice-commits] core.git: dbaccess/source include/svtools sd/source sfx2/source svtools/source svx/source sw/source

Stephan Bergmann sbergman at redhat.com
Mon Sep 28 04:07:25 PDT 2015


 dbaccess/source/ui/control/dbtreelistbox.cxx    |    8 ++++----
 dbaccess/source/ui/inc/dbtreelistbox.hxx        |    3 ++-
 include/svtools/treelistbox.hxx                 |    3 ++-
 sd/source/ui/animations/CustomAnimationList.cxx |    6 ++++--
 sd/source/ui/animations/CustomAnimationList.hxx |    6 +++++-
 sfx2/source/dialog/templdlg.cxx                 |    8 ++++----
 sfx2/source/inc/templdgi.hxx                    |   10 +++++++---
 svtools/source/contnr/fileview.cxx              |    8 ++++----
 svtools/source/contnr/svimpbox.cxx              |   19 ++++++++++---------
 svtools/source/contnr/treelistbox.cxx           |    2 +-
 svx/source/form/datanavi.cxx                    |   10 +++++++---
 svx/source/inc/datanavi.hxx                     |    4 +++-
 sw/source/uibase/inc/conttree.hxx               |    6 ++++--
 sw/source/uibase/utlui/content.cxx              |    4 ++--
 sw/source/uibase/utlui/glbltree.cxx             |    6 +++---
 15 files changed, 62 insertions(+), 41 deletions(-)

New commits:
commit d5b87dcce119f0cd69e65873833d98ed1660f9d0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Sep 28 13:06:39 2015 +0200

    Return std::unique_ptr from SvTreeListBox::CreateContextMenu
    
    Change-Id: I1e4c32099ec9741c0cab246eb627a2eb3b933e1a

diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
index cd213ba..8535e7b 100644
--- a/dbaccess/source/ui/control/dbtreelistbox.cxx
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -561,12 +561,12 @@ namespace
     }
 }
 
-PopupMenu* DBTreeListBox::CreateContextMenu()
+std::unique_ptr<PopupMenu> DBTreeListBox::CreateContextMenu()
 {
     ::std::unique_ptr< PopupMenu > pContextMenu;
 
     if ( !m_pContextMenuProvider )
-        return pContextMenu.release();
+        return pContextMenu;
 
     // the basic context menu
     pContextMenu.reset( m_pContextMenuProvider->getContextMenu( *this ) );
@@ -577,7 +577,7 @@ PopupMenu* DBTreeListBox::CreateContextMenu()
     // allow context menu interception
     ::cppu::OInterfaceContainerHelper* pInterceptors = m_pContextMenuProvider->getContextMenuInterceptors();
     if ( !pInterceptors || !pInterceptors->getLength() )
-        return pContextMenu.release();
+        return pContextMenu;
 
     ContextMenuExecuteEvent aEvent;
     aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
@@ -642,7 +642,7 @@ PopupMenu* DBTreeListBox::CreateContextMenu()
         lcl_adjustMenuItemIDs( *pModifiedMenu, m_pContextMenuProvider->getCommandController() );
     }
 
-    return pContextMenu.release();
+    return pContextMenu;
 }
 
 void DBTreeListBox::ExcecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry )
diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx
index 9e6c42b..edabc32 100644
--- a/dbaccess/source/ui/inc/dbtreelistbox.hxx
+++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx
@@ -27,6 +27,7 @@
 #include <svtools/treelistbox.hxx>
 #include <vcl/timer.hxx>
 
+#include <memory>
 #include <set>
 
 namespace dbaui
@@ -114,7 +115,7 @@ namespace dbaui
 
         virtual bool    DoubleClickHdl() SAL_OVERRIDE;
 
-        virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
+        virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
         virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) SAL_OVERRIDE;
 
         void            SetEnterKeyHdl(const Link<DBTreeListBox*,void>& rNewHdl) {m_aEnterKeyHdl = rNewHdl;}
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index b64b4ad..86a75da 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -23,6 +23,7 @@
 #include <svtools/svtdllapi.h>
 
 #include <deque>
+#include <memory>
 #include <vector>
 
 #include <vcl/ctrl.hxx>
@@ -794,7 +795,7 @@ public:
     void            ShowFocusRect( const SvTreeListEntry* pEntry );
     void            InitStartEntry();
 
-    virtual PopupMenu* CreateContextMenu();
+    virtual std::unique_ptr<PopupMenu> CreateContextMenu();
     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
 
     void            EnableContextMenuHandling();
diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx
index 7789f4b..03be564 100644
--- a/sd/source/ui/animations/CustomAnimationList.cxx
+++ b/sd/source/ui/animations/CustomAnimationList.cxx
@@ -46,6 +46,7 @@
 #include "glob.hrc"
 
 #include <algorithm>
+#include <memory>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::animations;
@@ -877,9 +878,10 @@ bool CustomAnimationList::DoubleClickHdl()
     return false;
 }
 
-PopupMenu* CustomAnimationList::CreateContextMenu()
+std::unique_ptr<PopupMenu> CustomAnimationList::CreateContextMenu()
 {
-    PopupMenu* pMenu = new PopupMenu(SdResId( RID_EFFECT_CONTEXTMENU ));
+    std::unique_ptr<PopupMenu> pMenu(
+        new PopupMenu(SdResId( RID_EFFECT_CONTEXTMENU )));
 
     sal_Int16 nNodeType = -1;
     sal_Int16 nEntries = 0;
diff --git a/sd/source/ui/animations/CustomAnimationList.hxx b/sd/source/ui/animations/CustomAnimationList.hxx
index 851ea67..72b2153 100644
--- a/sd/source/ui/animations/CustomAnimationList.hxx
+++ b/sd/source/ui/animations/CustomAnimationList.hxx
@@ -20,6 +20,10 @@
 #ifndef INCLUDED_SD_SOURCE_UI_ANIMATIONS_CUSTOMANIMATIONLIST_HXX
 #define INCLUDED_SD_SOURCE_UI_ANIMATIONS_CUSTOMANIMATIONLIST_HXX
 
+#include <sal/config.h>
+
+#include <memory>
+
 #include <com/sun/star/drawing/XShape.hpp>
 #include <svtools/treelistbox.hxx>
 #include <CustomAnimationEffect.hxx>
@@ -72,7 +76,7 @@ public:
 
     virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
 
-    virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
+    virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) SAL_OVERRIDE;
 
     virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 251990c9..992f1be 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -332,7 +332,7 @@ void SfxActionListBox::Recalc()
     }
 }
 
-PopupMenu* SfxActionListBox::CreateContextMenu()
+std::unique_ptr<PopupMenu> SfxActionListBox::CreateContextMenu()
 {
 
     if( !( GetSelectionCount() > 0 ) )
@@ -421,7 +421,7 @@ void StyleTreeListBox_Impl::MakeExpanded_Impl(ExpandedEntries_t& rEntries) const
     }
 }
 
-PopupMenu* StyleTreeListBox_Impl::CreateContextMenu()
+std::unique_ptr<PopupMenu> StyleTreeListBox_Impl::CreateContextMenu()
 {
     return pDialog->CreateContextMenu();
 }
@@ -2191,7 +2191,7 @@ void SfxCommonTemplateDialog_Impl::EnableExample_Impl(sal_uInt16 nId, bool bEnab
     EnableItem(nId, bEnable);
 }
 
-PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu()
+std::unique_ptr<PopupMenu> SfxCommonTemplateDialog_Impl::CreateContextMenu()
 {
     if ( bBindingUpdate )
     {
@@ -2199,7 +2199,7 @@ PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu()
         pBindings->Update( SID_STYLE_NEW );
         bBindingUpdate = false;
     }
-    PopupMenu* pMenu = new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG ) );
+    std::unique_ptr<PopupMenu> pMenu(new PopupMenu( SfxResId( MN_CONTEXT_TEMPLDLG ) ));
     pMenu->SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, MenuSelectHdl ) );
     pMenu->EnableItem( ID_EDIT, bCanEdit );
     pMenu->EnableItem( ID_DELETE, bCanDel );
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 0406451..afa26b5 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -21,6 +21,10 @@
 
 class SfxTemplateControllerItem;
 
+#include <sal/config.h>
+
+#include <memory>
+
 #include <vcl/button.hxx>
 #include <vcl/toolbox.hxx>
 #include <vcl/lstbox.hxx>
@@ -137,7 +141,7 @@ public:
     }
     void MakeExpanded_Impl(ExpandedEntries_t& rEntries) const;
 
-    virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
+    virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
 };
 
 class SfxActionListBox : public DropListBox_Impl
@@ -146,7 +150,7 @@ protected:
 public:
     SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
 
-    virtual PopupMenu*  CreateContextMenu() SAL_OVERRIDE;
+    virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
     void Recalc();
 };
 
@@ -332,7 +336,7 @@ public:
     }
 
     // normally for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
-    PopupMenu*  CreateContextMenu();
+    std::unique_ptr<PopupMenu> CreateContextMenu();
 };
 
 class DropToolBox_Impl : public ToolBox, public DropTargetHelper
diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx
index e2b8d5b..8b0e368 100644
--- a/svtools/source/contnr/fileview.cxx
+++ b/svtools/source/contnr/fileview.cxx
@@ -225,7 +225,7 @@ public:
 
     DECL_LINK_TYPED(ResetQuickSearch_Impl, Timer *, void);
 
-    virtual PopupMenu*  CreateContextMenu() SAL_OVERRIDE;
+    virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
     virtual void        ExcecuteContextMenuAction( sal_uInt16 nSelectedPopentry ) SAL_OVERRIDE;
 };
 
@@ -656,7 +656,7 @@ void ViewTabListBox_Impl::KeyInput( const KeyEvent& rKEvt )
 
 
 
-PopupMenu* ViewTabListBox_Impl::CreateContextMenu()
+std::unique_ptr<PopupMenu> ViewTabListBox_Impl::CreateContextMenu()
 {
     bool bEnableDelete = mbEnableDelete;
     bool bEnableRename = mbEnableRename;
@@ -733,8 +733,8 @@ PopupMenu* ViewTabListBox_Impl::CreateContextMenu()
 
     if ( bEnableDelete || bEnableRename )
     {
-        PopupMenu * pRet
-            = new PopupMenu( SvtResId( RID_FILEVIEW_CONTEXTMENU ) );
+        std::unique_ptr<PopupMenu> pRet(
+            new PopupMenu( SvtResId( RID_FILEVIEW_CONTEXTMENU ) ));
         pRet->EnableItem( MID_FILEVIEW_DELETE, bEnableDelete );
         pRet->EnableItem( MID_FILEVIEW_RENAME, bEnableRename );
         pRet->RemoveDisabledEntries( true, true );
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 35eae00..1e6f769 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -23,6 +23,7 @@
 #include <vcl/settings.hxx>
 
 #include <cstdlib>
+#include <memory>
 #include <stack>
 
 #include <svtools/treelistbox.hxx>
@@ -3042,16 +3043,16 @@ void SvImpLBox::Command( const CommandEvent& rCEvt )
                 aPopupPos = Point( 0, 0 );
         }
 
-        PopupMenu*  pPopup = pView->CreateContextMenu();
-
-        if( pPopup )
         {
-            // do action for selected entry in popup menu
-            sal_uInt16 nMenuAction = pPopup->Execute( pView, aPopupPos );
-            if ( nMenuAction )
-                pView->ExcecuteContextMenuAction( nMenuAction );
-            lcl_DeleteSubPopups(pPopup);
-            delete pPopup;
+            std::unique_ptr<PopupMenu> pPopup = pView->CreateContextMenu();
+            if( pPopup.get() )
+            {
+                // do action for selected entry in popup menu
+                sal_uInt16 nMenuAction = pPopup->Execute( pView, aPopupPos );
+                if ( nMenuAction )
+                    pView->ExcecuteContextMenuAction( nMenuAction );
+                lcl_DeleteSubPopups(pPopup.get());
+            }
         }
 
         if( bClickedIsFreePlace )
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 66d3a49..56fdc29 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -3810,7 +3810,7 @@ void SvTreeListBox::InitStartEntry()
         pImp->pStartEntry = GetModel()->First();
 }
 
-PopupMenu* SvTreeListBox::CreateContextMenu()
+std::unique_ptr<PopupMenu> SvTreeListBox::CreateContextMenu()
 {
     return NULL;
 }
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index 1ad3871..a49e23b 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <memory>
 
 #include <sal/macros.h>
 #include "datanavi.hxx"
@@ -217,9 +220,10 @@ namespace svxform
         pTransferable->StartDrag( this, DND_ACTION_COPY );
     }
 
-    PopupMenu* DataTreeListBox::CreateContextMenu()
+    std::unique_ptr<PopupMenu> DataTreeListBox::CreateContextMenu()
     {
-        PopupMenu* pMenu = new PopupMenu( SVX_RES( RID_MENU_DATANAVIGATOR ) );
+        std::unique_ptr<PopupMenu> pMenu(
+            new PopupMenu( SVX_RES( RID_MENU_DATANAVIGATOR ) ));
         if ( DGTInstance == m_eGroup )
             pMenu->RemoveItem( pMenu->GetItemPos( m_nAddId ) );
         else
@@ -240,7 +244,7 @@ namespace svxform
                 pMenu->SetItemText( m_nRemoveId, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING ) );
             }
         }
-        m_pXFormsPage->EnableMenuItems( pMenu );
+        m_pXFormsPage->EnableMenuItems( pMenu.get() );
         return pMenu;
     }
 
diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx
index dbb1180..b5a7867 100644
--- a/svx/source/inc/datanavi.hxx
+++ b/svx/source/inc/datanavi.hxx
@@ -52,6 +52,8 @@
 #include <com/sun/star/xml/dom/events/XEventTarget.hpp>
 
 #include "datalistener.hxx"
+
+#include <memory>
 #include <vector>
 
 class FmFormShell;
@@ -131,7 +133,7 @@ namespace svxform
         virtual ~DataTreeListBox();
         virtual void dispose() SAL_OVERRIDE;
 
-        virtual PopupMenu*      CreateContextMenu() SAL_OVERRIDE;
+        virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
         virtual void            ExcecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry ) SAL_OVERRIDE;
         virtual sal_Int8        AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
         virtual sal_Int8        ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index aa49b16..4dd8bdc 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -25,6 +25,8 @@
 #include "swcont.hxx"
 
 #include <map>
+#include <memory>
+
 #include <o3tl/enumarray.hxx>
 
 class SwWrtShell;
@@ -142,7 +144,7 @@ protected:
     void            GotoContent(SwContent* pCnt);
     static void     SetInDrag(bool bSet) {bIsInDrag = bSet;}
 
-    virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
+    virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) SAL_OVERRIDE;
 
 public:
@@ -305,7 +307,7 @@ protected:
     static void     SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
     DECL_STATIC_LINK_TYPED(SwGlobalTree, ShowFrameHdl, void*, void);
 
-    virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
+    virtual std::unique_ptr<PopupMenu> CreateContextMenu() SAL_OVERRIDE;
     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) SAL_OVERRIDE;
 
 public:
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 195771a..80beca9 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1115,9 +1115,9 @@ sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
 
 // Handler for Dragging and ContextMenu
 
-PopupMenu* SwContentTree::CreateContextMenu()
+std::unique_ptr<PopupMenu> SwContentTree::CreateContextMenu()
 {
-    PopupMenu* pPop = new PopupMenu;
+    std::unique_ptr<PopupMenu> pPop(new PopupMenu);
     PopupMenu* pSubPop1 = new PopupMenu;
     PopupMenu* pSubPop2 = new PopupMenu;
     PopupMenu* pSubPop3 = new PopupMenu;
diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx
index a926821..1cf278a 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -331,14 +331,14 @@ sal_Int8 SwGlobalTree::AcceptDrop( const AcceptDropEvent& rEvt )
     return nRet;
 }
 
-PopupMenu* SwGlobalTree::CreateContextMenu()
+std::unique_ptr<PopupMenu> SwGlobalTree::CreateContextMenu()
 {
-    PopupMenu* pPop = 0;
+    std::unique_ptr<PopupMenu> pPop;
     if(pActiveShell &&
         !pActiveShell->GetView().GetDocShell()->IsReadOnly())
     {
         const sal_uInt16 nEnableFlags = GetEnableFlags();
-        pPop = new PopupMenu;
+        pPop.reset(new PopupMenu);
         PopupMenu* pSubPop1 = new PopupMenu;
         PopupMenu* pSubPop2 = new PopupMenu;
 


More information about the Libreoffice-commits mailing list