[Libreoffice-commits] .: 4 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Mar 23 19:49:32 PDT 2011


 sc/inc/global.hxx               |   52 ++++++++++-----------
 sc/inc/pivot.hxx                |    5 --
 sc/source/core/data/global2.cxx |   98 ++++++++++++++++++++--------------------
 sc/source/ui/inc/cellsh.hxx     |    1 
 sc/source/ui/view/cellsh1.cxx   |   63 +++++++++++++++++++++++++
 sc/source/ui/view/cellsh2.cxx   |   60 ------------------------
 6 files changed, 139 insertions(+), 140 deletions(-)

New commits:
commit 755f704d23d8ee8b335535613fdf964d55c38c7a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Mar 23 22:48:07 2011 -0400

    Removed unused code.

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 19b45bb..98163f2 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -97,8 +97,6 @@ const sal_Unicode CHAR_ZWNBSP   = 0x2060;
 
 const SCSIZE MAXSUBTOTAL        = 3;
 const SCSIZE MAXQUERY           = 8;
-const SCSIZE PIVOT_MAXFIELD     = 8;
-const SCSIZE PIVOT_MAXPAGEFIELD = 10;
 
 #define SC_START_INDEX_DB_COLL 50000
                                         // Above this threshold are indices
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 87caf0a..63c52b5 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -114,11 +114,6 @@ struct ScPivotParam
     void            SetLabelData    (const ::std::vector<ScDPLabelDataRef>& r);
 };
 
-// -----------------------------------------------------------------------
-
-typedef PivotField			PivotFieldArr[PIVOT_MAXFIELD];
-typedef PivotField          PivotPageFieldArr[PIVOT_MAXPAGEFIELD];
-
 //------------------------------------------------------------------------
 
 struct ScDPName
commit f3d03c726365f3fb5d7584aa2338605025b25711
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Mar 23 22:39:34 2011 -0400

    Cleaned up ScSubTotalParam.

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 5bf9137..19b45bb 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -765,35 +765,35 @@ struct ScQueryEntry
 
 struct SC_DLLPUBLIC ScSubTotalParam
 {
-    SCCOL			nCol1;			// selected area
-    SCROW			nRow1;
-    SCCOL			nCol2;
-    SCROW			nRow2;
-    sal_Bool			bRemoveOnly;
-    sal_Bool			bReplace;					// replace existing results
-    sal_Bool			bPagebreak;					// page break at change of group
-    sal_Bool			bCaseSens;					//
-    sal_Bool			bDoSort;					// presort
-    sal_Bool			bAscending;					// sort ascending
-    sal_Bool			bUserDef;					// sort user defined
-    sal_uInt16			nUserIndex;                 // index into list
-    sal_Bool			bIncludePattern;			// sort formats
-    sal_Bool			bGroupActive[MAXSUBTOTAL];	// active groups
-    SCCOL			nField[MAXSUBTOTAL];		// associated field
-    SCCOL			nSubTotals[MAXSUBTOTAL];	// number of SubTotals
-    SCCOL*			pSubTotals[MAXSUBTOTAL];	// array of columns to be calculated
-    ScSubTotalFunc*	pFunctions[MAXSUBTOTAL];	// array of associated functions
+    SCCOL           nCol1;          // selected area
+    SCROW           nRow1;
+    SCCOL           nCol2;
+    SCROW           nRow2;
+    sal_uInt16      nUserIndex;                 // index into list
+    bool            bRemoveOnly:1;
+    bool            bReplace:1;                 // replace existing results
+    bool            bPagebreak:1;               // page break at change of group
+    bool            bCaseSens:1;                //
+    bool            bDoSort:1;                  // presort
+    bool            bAscending:1;               // sort ascending
+    bool            bUserDef:1;                 // sort user defined
+    bool            bIncludePattern:1;          // sort formats
+    bool            bGroupActive[MAXSUBTOTAL];  // active groups
+    SCCOL           nField[MAXSUBTOTAL];        // associated field
+    SCCOL           nSubTotals[MAXSUBTOTAL];    // number of SubTotals
+    SCCOL*          pSubTotals[MAXSUBTOTAL];    // array of columns to be calculated
+    ScSubTotalFunc* pFunctions[MAXSUBTOTAL];    // array of associated functions
 
     ScSubTotalParam();
     ScSubTotalParam( const ScSubTotalParam& r );
 
-    ScSubTotalParam&	operator=		( const ScSubTotalParam& r );
-    sal_Bool				operator==		( const ScSubTotalParam& r ) const;
-    void				Clear			();
-    void 				SetSubTotals	( sal_uInt16				nGroup,
-                                          const SCCOL*			ptrSubTotals,
-                                          const ScSubTotalFunc*	ptrFuncions,
-                                          sal_uInt16				nCount );
+    ScSubTotalParam& operator= ( const ScSubTotalParam& r );
+    bool operator== ( const ScSubTotalParam& r ) const;
+    void Clear();
+    void SetSubTotals( sal_uInt16 nGroup,
+                       const SCCOL* ptrSubTotals,
+                       const ScSubTotalFunc* ptrFuncions,
+                       sal_uInt16 nCount );
 };
 
 class ScArea;
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 0579f77..ae5bca7 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -245,21 +245,21 @@ ScSubTotalParam::ScSubTotalParam()
 //------------------------------------------------------------------------
 
 ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam& r ) :
-        nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),
+        nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),nUserIndex(r.nUserIndex),
         bRemoveOnly(r.bRemoveOnly),bReplace(r.bReplace),bPagebreak(r.bPagebreak),bCaseSens(r.bCaseSens),
-        bDoSort(r.bDoSort),bAscending(r.bAscending),bUserDef(r.bUserDef),nUserIndex(r.nUserIndex),
+        bDoSort(r.bDoSort),bAscending(r.bAscending),bUserDef(r.bUserDef),
         bIncludePattern(r.bIncludePattern)
 {
     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
     {
-        bGroupActive[i]	= r.bGroupActive[i];
-        nField[i]		= r.nField[i];
+        bGroupActive[i] = r.bGroupActive[i];
+        nField[i]       = r.nField[i];
 
         if ( (r.nSubTotals[i] > 0) && r.pSubTotals[i] && r.pFunctions[i] )
         {
             nSubTotals[i] = r.nSubTotals[i];
-            pSubTotals[i] = new SCCOL	[r.nSubTotals[i]];
-            pFunctions[i] = new ScSubTotalFunc	[r.nSubTotals[i]];
+            pSubTotals[i] = new SCCOL   [r.nSubTotals[i]];
+            pFunctions[i] = new ScSubTotalFunc  [r.nSubTotals[i]];
 
             for (SCCOL j=0; j<r.nSubTotals[i]; j++)
             {
@@ -284,12 +284,12 @@ void ScSubTotalParam::Clear()
     nRow1=nRow2 = 0;
     nUserIndex = 0;
     bPagebreak=bCaseSens=bUserDef=bIncludePattern=bRemoveOnly = false;
-    bAscending=bReplace=bDoSort = sal_True;
+    bAscending=bReplace=bDoSort = true;
 
     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
     {
-        bGroupActive[i]	= false;
-        nField[i]		= 0;
+        bGroupActive[i] = false;
+        nField[i]       = 0;
 
         if ( (nSubTotals[i] > 0) && pSubTotals[i] && pFunctions[i] )
         {
@@ -305,33 +305,33 @@ void ScSubTotalParam::Clear()
 
 ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r )
 {
-    nCol1			= r.nCol1;
-    nRow1			= r.nRow1;
-    nCol2			= r.nCol2;
-    nRow2			= r.nRow2;
-    bRemoveOnly		= r.bRemoveOnly;
-    bReplace		= r.bReplace;
-    bPagebreak		= r.bPagebreak;
-    bCaseSens		= r.bCaseSens;
-    bDoSort			= r.bDoSort;
-    bAscending		= r.bAscending;
-    bUserDef		= r.bUserDef;
-    nUserIndex		= r.nUserIndex;
-    bIncludePattern	= r.bIncludePattern;
+    nCol1           = r.nCol1;
+    nRow1           = r.nRow1;
+    nCol2           = r.nCol2;
+    nRow2           = r.nRow2;
+    bRemoveOnly     = r.bRemoveOnly;
+    bReplace        = r.bReplace;
+    bPagebreak      = r.bPagebreak;
+    bCaseSens       = r.bCaseSens;
+    bDoSort         = r.bDoSort;
+    bAscending      = r.bAscending;
+    bUserDef        = r.bUserDef;
+    nUserIndex      = r.nUserIndex;
+    bIncludePattern = r.bIncludePattern;
 
     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
     {
-        bGroupActive[i]	= r.bGroupActive[i];
-        nField[i]		= r.nField[i];
-        nSubTotals[i]	= r.nSubTotals[i];
+        bGroupActive[i] = r.bGroupActive[i];
+        nField[i]       = r.nField[i];
+        nSubTotals[i]   = r.nSubTotals[i];
 
         if ( pSubTotals[i] ) delete [] pSubTotals[i];
         if ( pFunctions[i] ) delete [] pFunctions[i];
 
         if ( r.nSubTotals[i] > 0 )
         {
-            pSubTotals[i] = new SCCOL	[r.nSubTotals[i]];
-            pFunctions[i] = new ScSubTotalFunc	[r.nSubTotals[i]];
+            pSubTotals[i] = new SCCOL   [r.nSubTotals[i]];
+            pFunctions[i] = new ScSubTotalFunc  [r.nSubTotals[i]];
 
             for (SCCOL j=0; j<r.nSubTotals[i]; j++)
             {
@@ -352,30 +352,30 @@ ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r )
 
 //------------------------------------------------------------------------
 
-sal_Bool ScSubTotalParam::operator==( const ScSubTotalParam& rOther ) const
-{
-    sal_Bool bEqual =   (nCol1			== rOther.nCol1)
-                 && (nRow1			== rOther.nRow1)
-                 && (nCol2			== rOther.nCol2)
-                 && (nRow2			== rOther.nRow2)
-                 && (bRemoveOnly	== rOther.bRemoveOnly)
-                 && (bReplace		== rOther.bReplace)
-                 && (bPagebreak		== rOther.bPagebreak)
-                 && (bDoSort		== rOther.bDoSort)
-                 && (bCaseSens		== rOther.bCaseSens)
-                 && (bAscending		== rOther.bAscending)
-                 && (bUserDef		== rOther.bUserDef)
-                 && (nUserIndex		== rOther.nUserIndex)
+bool ScSubTotalParam::operator==( const ScSubTotalParam& rOther ) const
+{
+    bool bEqual =   (nCol1          == rOther.nCol1)
+                 && (nRow1          == rOther.nRow1)
+                 && (nCol2          == rOther.nCol2)
+                 && (nRow2          == rOther.nRow2)
+                 && (nUserIndex     == rOther.nUserIndex)
+                 && (bRemoveOnly    == rOther.bRemoveOnly)
+                 && (bReplace       == rOther.bReplace)
+                 && (bPagebreak     == rOther.bPagebreak)
+                 && (bDoSort        == rOther.bDoSort)
+                 && (bCaseSens      == rOther.bCaseSens)
+                 && (bAscending     == rOther.bAscending)
+                 && (bUserDef       == rOther.bUserDef)
                  && (bIncludePattern== rOther.bIncludePattern);
 
     if ( bEqual )
     {
-        bEqual = sal_True;
+        bEqual = true;
         for ( sal_uInt16 i=0; i<MAXSUBTOTAL && bEqual; i++ )
         {
-            bEqual =   (bGroupActive[i]	== rOther.bGroupActive[i])
-                    && (nField[i]		== rOther.nField[i])
-                    && (nSubTotals[i]	== rOther.nSubTotals[i]);
+            bEqual =   (bGroupActive[i] == rOther.bGroupActive[i])
+                    && (nField[i]       == rOther.nField[i])
+                    && (nSubTotals[i]   == rOther.nSubTotals[i]);
 
             if ( bEqual && (nSubTotals[i] > 0) )
             {
@@ -396,10 +396,10 @@ sal_Bool ScSubTotalParam::operator==( const ScSubTotalParam& rOther ) const
 
 //------------------------------------------------------------------------
 
-void ScSubTotalParam::SetSubTotals( sal_uInt16					nGroup,
-                                    const SCCOL*			ptrSubTotals,
-                                    const ScSubTotalFunc*	ptrFunctions,
-                                    sal_uInt16					nCount )
+void ScSubTotalParam::SetSubTotals( sal_uInt16 nGroup,
+                                    const SCCOL* ptrSubTotals,
+                                    const ScSubTotalFunc* ptrFunctions,
+                                    sal_uInt16 nCount )
 {
     DBG_ASSERT( (nGroup <= MAXSUBTOTAL),
                 "ScSubTotalParam::SetSubTotals(): nGroup > MAXSUBTOTAL!" );
commit cd8e4f64b4e6f1864af30cc3cfe27e6a23f3706c
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Mar 23 22:22:03 2011 -0400

    Prefer early return and reduce indent level.

diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index b7041e7..792edca 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2337,57 +2337,56 @@ void ScCellShell::ExecuteSubtotals(SfxRequest& rReq)
         pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )).
                         GetSubTotalData() );
         rReq.Done();
+        return;
     }
-    else
-    {
-        SfxAbstractTabDialog * pDlg = NULL;
-        ScSubTotalParam aSubTotalParam;
-        SfxItemSet		aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
 
-        ScDBData* pDBData = pTabViewShell->GetDBData();
-        pDBData->GetSubTotalParam( aSubTotalParam );
-        aSubTotalParam.bRemoveOnly = false;
+    SfxAbstractTabDialog * pDlg = NULL;
+    ScSubTotalParam aSubTotalParam;
+    SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
 
-        aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
-        ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
-        DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+    ScDBData* pDBData = pTabViewShell->GetDBData();
+    pDBData->GetSubTotalParam( aSubTotalParam );
+    aSubTotalParam.bRemoveOnly = false;
 
-        pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
-        DBG_ASSERT(pDlg, "Dialog create fail!");
-        pDlg->SetCurPageId(1);
+    aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
+    ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+    DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
 
-        short bResult = pDlg->Execute();
+    pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
+    DBG_ASSERT(pDlg, "Dialog create fail!");
+    pDlg->SetCurPageId(1);
 
-        if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
-        {
-            const SfxItemSet* pOutSet = NULL;
+    short bResult = pDlg->Execute();
 
-            if ( bResult == RET_OK )
-            {
-                pOutSet = pDlg->GetOutputItemSet();
-                aSubTotalParam =
-                    ((const ScSubTotalItem&)
-                        pOutSet->Get( SCITEM_SUBTDATA )).
-                            GetSubTotalData();
-            }
-            else // if (bResult == SCRET_REMOVE)
-            {
-                pOutSet = &aArgSet;
-                aSubTotalParam.bRemoveOnly = sal_True;
-                aSubTotalParam.bReplace    = sal_True;
-                aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
-                                             GetViewData(),
-                                             &aSubTotalParam ) );
-            }
+    if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
+    {
+        const SfxItemSet* pOutSet = NULL;
 
-            pTabViewShell->DoSubTotals( aSubTotalParam );
-            rReq.Done( *pOutSet );
+        if ( bResult == RET_OK )
+        {
+            pOutSet = pDlg->GetOutputItemSet();
+            aSubTotalParam =
+                ((const ScSubTotalItem&)
+                    pOutSet->Get( SCITEM_SUBTDATA )).
+                        GetSubTotalData();
+        }
+        else // if (bResult == SCRET_REMOVE)
+        {
+            pOutSet = &aArgSet;
+            aSubTotalParam.bRemoveOnly = sal_True;
+            aSubTotalParam.bReplace    = sal_True;
+            aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
+                                         GetViewData(),
+                                         &aSubTotalParam ) );
         }
-        else
-            GetViewData()->GetDocShell()->CancelAutoDBRange();
 
-        delete pDlg;
+        pTabViewShell->DoSubTotals( aSubTotalParam );
+        rReq.Done( *pOutSet );
     }
+    else
+        GetViewData()->GetDocShell()->CancelAutoDBRange();
+
+    delete pDlg;
 }
 
 IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG )
commit efd08baa2b5e82353338a26a109d30819aab542b
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Mar 23 22:20:32 2011 -0400

    Extracted method for subtotals function.

diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx
index 6129fcf..685a3fb 100644
--- a/sc/source/ui/inc/cellsh.hxx
+++ b/sc/source/ui/inc/cellsh.hxx
@@ -67,6 +67,7 @@ private:
                     const String& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest );
 
     void ExecuteDataPilotDialog();
+    void ExecuteSubtotals(SfxRequest& rReq);
 
     DECL_LINK( ClipboardChanged, TransferableDataHelper* );
     DECL_LINK( DialogClosed, AbstractScLinkedAreaDlg* );
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index d474ed3..b7041e7 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -98,6 +98,8 @@
 #include "dpobject.hxx"
 #include "dpsdbtab.hxx"		// ScImportSourceDesc
 #include "dpshttab.hxx"		// ScSheetSourceDesc
+#include "dbcolect.hxx"
+#include "docsh.hxx"
 
 #include "globstr.hrc"
 #include "scui_def.hxx"
@@ -2326,6 +2328,68 @@ void ScCellShell::ExecuteDataPilotDialog()
     }
 }
 
+void ScCellShell::ExecuteSubtotals(SfxRequest& rReq)
+{
+    ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+    const SfxItemSet* pArgs = rReq.GetArgs();
+    if ( pArgs )
+    {
+        pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )).
+                        GetSubTotalData() );
+        rReq.Done();
+    }
+    else
+    {
+        SfxAbstractTabDialog * pDlg = NULL;
+        ScSubTotalParam aSubTotalParam;
+        SfxItemSet		aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
+
+        ScDBData* pDBData = pTabViewShell->GetDBData();
+        pDBData->GetSubTotalParam( aSubTotalParam );
+        aSubTotalParam.bRemoveOnly = false;
+
+        aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
+        ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+        DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+        pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
+        DBG_ASSERT(pDlg, "Dialog create fail!");
+        pDlg->SetCurPageId(1);
+
+        short bResult = pDlg->Execute();
+
+        if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
+        {
+            const SfxItemSet* pOutSet = NULL;
+
+            if ( bResult == RET_OK )
+            {
+                pOutSet = pDlg->GetOutputItemSet();
+                aSubTotalParam =
+                    ((const ScSubTotalItem&)
+                        pOutSet->Get( SCITEM_SUBTDATA )).
+                            GetSubTotalData();
+            }
+            else // if (bResult == SCRET_REMOVE)
+            {
+                pOutSet = &aArgSet;
+                aSubTotalParam.bRemoveOnly = sal_True;
+                aSubTotalParam.bReplace    = sal_True;
+                aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
+                                             GetViewData(),
+                                             &aSubTotalParam ) );
+            }
+
+            pTabViewShell->DoSubTotals( aSubTotalParam );
+            rReq.Done( *pOutSet );
+        }
+        else
+            GetViewData()->GetDocShell()->CancelAutoDBRange();
+
+        delete pDlg;
+    }
+}
+
 IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG )
 {
     DBG_ASSERT( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 3942c19..9a2b520 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -344,65 +344,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
             break;
 
         case SID_SUBTOTALS:
-            {
-                const SfxItemSet* pArgs = rReq.GetArgs();
-                if ( pArgs )
-                {
-                    pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )).
-                                    GetSubTotalData() );
-                    rReq.Done();
-                }
-                else
-                {
-                    SfxAbstractTabDialog * pDlg = NULL;
-                    ScSubTotalParam aSubTotalParam;
-                    SfxItemSet		aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
-
-                    ScDBData* pDBData = pTabViewShell->GetDBData();
-                    pDBData->GetSubTotalParam( aSubTotalParam );
-                    aSubTotalParam.bRemoveOnly = false;
-
-                    aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
-                    ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
-                    DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
-
-                    pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
-                    DBG_ASSERT(pDlg, "Dialog create fail!");
-                    pDlg->SetCurPageId(1);
-
-                    short bResult = pDlg->Execute();
-
-                    if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
-                    {
-                        const SfxItemSet* pOutSet = NULL;
-
-                        if ( bResult == RET_OK )
-                        {
-                            pOutSet = pDlg->GetOutputItemSet();
-                            aSubTotalParam =
-                                ((const ScSubTotalItem&)
-                                    pOutSet->Get( SCITEM_SUBTDATA )).
-                                        GetSubTotalData();
-                        }
-                        else // if (bResult == SCRET_REMOVE)
-                        {
-                            pOutSet = &aArgSet;
-                            aSubTotalParam.bRemoveOnly = sal_True;
-                            aSubTotalParam.bReplace    = sal_True;
-                            aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
-                                                         GetViewData(),
-                                                         &aSubTotalParam ) );
-                        }
-
-                        pTabViewShell->DoSubTotals( aSubTotalParam );
-                        rReq.Done( *pOutSet );
-                    }
-                    else
-                        GetViewData()->GetDocShell()->CancelAutoDBRange();
-
-                    delete pDlg;
-                }
-            }
+            ExecuteSubtotals(rReq);
             break;
 
         case SID_SORT_DESCENDING:


More information about the Libreoffice-commits mailing list