[Libreoffice-commits] core.git: sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Jan 22 16:19:43 PST 2014


 sc/source/ui/inc/tabvwsh.hxx   |    4 +---
 sc/source/ui/view/formatsh.cxx |    8 +++++---
 sc/source/ui/view/tabvwsh5.cxx |   18 +++++++-----------
 sc/source/ui/view/tabvwsha.cxx |   18 +++++++-----------
 4 files changed, 20 insertions(+), 28 deletions(-)

New commits:
commit dabf147d1d7e892ce07202fbe89a584f0d592a62
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jan 22 14:37:14 2014 -0500

    Use scoped_ptr for these.
    
    Change-Id: I9452950ad6a101c2b9299dca5ff6e1713cac774c

diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 285b68e..a60ca98 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -388,9 +388,7 @@ public:
 
     void    ForceMove()     { Move(); }
 
-    void    MakeNumberInfoItem      ( ScDocument*            pDoc,
-                                      ScViewData*            pViewData,
-                                      SvxNumberInfoItem**    ppItem );
+    SvxNumberInfoItem* MakeNumberInfoItem( ScDocument* pDoc, ScViewData* pViewData );
 
     void    UpdateNumberFormatter   ( const SvxNumberInfoItem&  rInfoItem );
 
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 3da636d..16412c4 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -81,6 +81,8 @@
 #include "scabstdlg.hxx"
 #include <editeng/fontitem.hxx>
 
+#include <boost/scoped_ptr.hpp>
+
 using namespace ::com::sun::star;
 
 namespace {
@@ -774,8 +776,6 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
         {
             if ( pStyleSheet )
             {
-                SvxNumberInfoItem* pNumberInfoItem = NULL;
-
                 SfxStyleFamily  eFam    = pStyleSheet->GetFamily();
                 SfxAbstractTabDialog* pDlg    = NULL;
                 sal_uInt16          nRsc    = 0;
@@ -818,7 +818,9 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
                                 }
                             }
 
-                            pTabViewShell->MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
+                            boost::scoped_ptr<SvxNumberInfoItem> pNumberInfoItem(
+                                pTabViewShell->MakeNumberInfoItem(pDoc, GetViewData()));
+
                             pDocSh->PutItem( *pNumberInfoItem );
                             nRsc = RID_SCDLG_STYLES_PAR;
 
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index c6fcace..52a2262 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -308,9 +308,7 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
 
 //------------------------------------------------------------------
 
-void ScTabViewShell::MakeNumberInfoItem( ScDocument*         pDoc,
-                                         ScViewData*         pViewData,
-                                         SvxNumberInfoItem** ppItem )
+SvxNumberInfoItem* ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc, ScViewData* pViewData )
 {
     //------------------------------
     // NumberInfo-Item konstruieren:
@@ -361,26 +359,24 @@ void ScTabViewShell::MakeNumberInfoItem( ScDocument*         pDoc,
     switch ( eValType )
     {
         case SVX_VALUE_TYPE_STRING:
-            *ppItem = new SvxNumberInfoItem(
+            return new SvxNumberInfoItem(
                                 pDoc->GetFormatTable(),
                                 aCellString,
                                 SID_ATTR_NUMBERFORMAT_INFO );
-            break;
 
         case SVX_VALUE_TYPE_NUMBER:
-            *ppItem = new SvxNumberInfoItem(
+            return new SvxNumberInfoItem(
                                 pDoc->GetFormatTable(),
                                 nCellValue,
                                 SID_ATTR_NUMBERFORMAT_INFO );
-            break;
 
         case SVX_VALUE_TYPE_UNDEFINED:
         default:
-            *ppItem = new SvxNumberInfoItem(
-                                pDoc->GetFormatTable(),
-                                (const sal_uInt16)
-                                SID_ATTR_NUMBERFORMAT_INFO );
+            ;
     }
+
+    return new SvxNumberInfoItem(
+        pDoc->GetFormatTable(), static_cast<const sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO));
 }
 
 //------------------------------------------------------------------
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 09f482b..9c064bd 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -464,17 +464,16 @@ void ScTabViewShell::GetState( SfxItemSet& rSet )
 //------------------------------------------------------------------
 void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName)
 {
-    SfxAbstractTabDialog * pDlg = NULL;
     ScDocument*             pDoc    = GetViewData()->GetDocument();
 
     SvxBoxItem              aLineOuter( ATTR_BORDER );
     SvxBoxInfoItem          aLineInner( ATTR_BORDER_INNER );
 
-    SvxNumberInfoItem*      pNumberInfoItem = NULL;
     const ScPatternAttr*    pOldAttrs       = GetSelectionPattern();
-    SfxItemSet*             pOldSet         = new SfxItemSet(
-                                                    pOldAttrs->GetItemSet() );
 
+    boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
+    boost::scoped_ptr<SfxItemSet> pOldSet(new SfxItemSet(pOldAttrs->GetItemSet()));
+    boost::scoped_ptr<SvxNumberInfoItem> pNumberInfoItem;
 
     // Get border items and put them in the set:
     GetSelectionFrame( aLineOuter, aLineInner );
@@ -503,7 +502,7 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName
     pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
         pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
 
-    MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
+    pNumberInfoItem.reset(MakeNumberInfoItem(pDoc, GetViewData()));
 
     pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
     pOldSet->Put(*pNumberInfoItem );
@@ -512,8 +511,8 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName
     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
 
-    pDlg = pFact->CreateScAttrDlg(GetViewFrame(), GetDialogParent(), pOldSet);
-    OSL_ENSURE(pDlg, "Dialog create fail!");
+    pDlg.reset(pFact->CreateScAttrDlg(GetViewFrame(), GetDialogParent(), pOldSet.get()));
+
     if (!rName.isEmpty())
         pDlg->SetCurPageId(rName);
     short nResult = pDlg->Execute();
@@ -530,13 +529,10 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName
             UpdateNumberFormatter((const SvxNumberInfoItem&)*pItem);
         }
 
-        ApplyAttributes( pOutSet, pOldSet );
+        ApplyAttributes(pOutSet, pOldSet.get());
 
         rReq.Done( *pOutSet );
     }
-    delete pOldSet;
-    delete pNumberInfoItem;
-    delete pDlg;
 }
 
 //------------------------------------------------------------------


More information about the Libreoffice-commits mailing list